Particle System Design - PowerPoint PPT Presentation

About This Presentation
Title:

Particle System Design

Description:

But in the case of particles, want to inherit motion from here, ... size, texture, 3D mesh, quat, etc, etc... My solution: class particlearray. int array_size; ... – PowerPoint PPT presentation

Number of Views:68
Avg rating:3.0/5.0
Slides: 16
Provided by: JulioGo4
Learn more at: http://www.cs.cmu.edu
Category:
Tags: design | particle | quat | system

less

Transcript and Presenter's Notes

Title: Particle System Design


1
Particle System Design
2
The Challenge
  • Particle systems vary so much
  • But want some code reuse
  • Option 1 parameterization
  • Option 2 inheritance
  • Option 3 subroutine library
  • Lets look at actual systems

3
Look for Custom Code
  • Motion
  • Rendering
  • Orientation
  • Interparticle Force
  • Color
  • Spawning
  • Emitters
  • Any of these could use custom code

4
Parameterization
  • Simply not general enough

5
Inheritance
  • Inheritance is usuallyhelpful for code reuse.
  • But in the case of particles,
  • want to inherit motion from here,
  • want to inherit rendering from there,
  • want to inherit spawning from that,
  • Inheritance doesnt work that way.

6
Subroutine Library
  • Each system is itsown module, however,
  • Library provides
  • routines for rendering
  • routines for calculating motion
  • routines for spawning
  • etc
  • Lets design this library

7
Rendering Routines
  • Render camera-aligned quads
  • pos, size, color, tex, theta, blend
  • Render soft trails
  • ie, for jet engine exhaust
  • or, for sparks from a grinder
  • Render each particle as 3D model

8
Soft Trails
  • For each point along trailgenerate two
    side-points.

9
Soft Trails
  • For each point along trailgenerate two
    side-points.

10
Soft Trails
  • For each point along trailgenerate two
    side-points.

for each point P eye vector from cam to P
lineseg1 one of two segments connected to P
lineseg2 two of two segments connected to P
v1 cross(lineseg1,eye) v2
cross(lineseg2,eye) if (dot(v1,v2) lt 0) v2
-v2 v normalize(average(v1,v2))
sidepoint1 P v sidepoint2 P v
11
Particle Motion
  • Two ways to do it
  • Option 1 Timestep simulation.
  • Calculate acceleration
  • Position Velocity
  • Velocity Acceleration
  • Option 2 Closed form equations.
  • Particle.X f(t)
  • Particle.Y g(t)
  • Why not always use timesteps?

12
Why closed form I
  • Can be hardware accelerated.
  • Example simple fountain.

struct vertex float3 startpos float3
initialvelocity float lifespan vertex
shader globals float3 gravity float
currentTime
13
Why closed form II
  • Can use prerecorded paths.
  • float positionX1024
  • float positionY1024
  • Can add several prerecorded paths
  • multiple circles
  • wiggle parabola
  • Can transform prerecorded path
  • smoke example
  • Library should contain many paths.

14
Why Timestepped
  • Particles that bounce.
  • or, interact with world in other ways.
  • simply cant do this in closed form.
  • Decouple frame rate from renderer.
  • This should be a class in your library.

ps.elapsed GetClock() ps.createtime timesteps
(int)(ps.elapsed / ps.framerate) while
(timesteps gt ps.timesteps) ps.update() ps.tim
esteps 1
15
Data Structures
  • Every particle systemneeds some form of particle
    list.
  • But, it seems every system has different particle
    attributes.
  • pos, vel, accel, theta, direction, age,history,
    color, rand seed, opacity, lifespan,size,
    texture, 3D mesh, quat, etc, etc...
  • My solution

class particlearray int array_size int
array_fill float3 pos float3 vel
float3 accel ...
Write a Comment
User Comments (0)
About PowerShow.com