Download presentation
Presentation is loading. Please wait.
Published byJustin Shelton Modified over 10 years ago
1
A Complete XBox 360 GPU Particle System: Tech & Pipeline Sebastian Sylvan & Dr Simon Scarle Rare MGS
2
A Complete XBox 360 GPU Particle System: Tech & Pipeline Sebastian Sylvan & Dr Simon Scarle Rare MGS
3
A Note on Applicability
4
What is a Particle System?
6
Tech overview Why on the GPU? Some background Simulation Sorting Rendering
7
Why on the GPU?
8
No Synchronisation Headaches
9
Why on the GPU? Performance
10
Why on the GPU? Code Specialisation
11
Background : The Xbox 360
12
Flexible fetching VS_OUTPUT vs_main( int ix : INDEX ) { int index = (ix+0.5)/a_const.x; float4 pos; float2 uv; asm { vfetch pos, index, position0; vfetch uv, index, texcoord0; }; /*.... snip.... */ }
13
Background: The Xbox 360 Memory Export Main Memory DIP ME
14
Simulation void simulation_shader( int ix : INDEX ) { Particle p = decompress(fetch_particle(ix)); Particle newp = simulate( p, ix, delta_time ); write_particle( ix, compress(newp) ); }
15
Simulation Newtonian motion // a = (sum of forces) / mass newp.vel = p.vel + dt*a; newp.pos = p.pos + p.vel*dt;
16
Simulation Turbulence : Position-dependent random force a += f(tex3D(turb_tex, g(p.pos))); Scale/bias position into “turbulence space” Per-system scale/bias
17
Simulation Turbulence: Holy Cache Thrashing, Batman!
18
Simulation Alleviating Cache Thrashing Use small texture Use “thin” format (e.g. 10:11:11) Sort the particles
19
Simulation Collision detection (spheres, planes, height fields)
20
Simulation Emission float4 rnd; float x = (ix+rnd_offset) % rnd_size; asm{ tfetch1D rnd, x, rnd_tex, UnnormalizedTextureCoords=true }; Particle newp = create_particle(rnd); rnd = ix > half_N ? rnd.xyzw : rnd.wzyx;
21
Sorting
22
Why sort? Cache coherency Non-commutative rendering
23
Sorting Why sort?
24
Sorting Need parallel sort for parallel hardware Parallelize standard algorithms? Sorting networks?
25
Sorting Sorting Networks (Bitonic merge sort, odd-even merge sort)
26
Sorting Odd-Even merge merge(s) { n = size(s) if ( n == 2 ) { return CAS(s(0),s(1)) } else { odds = s(1,3,..,n-1) evens = s(0,2,..,n-2) result = interleave( merge(evens), merge(odds)) for ( i = (1,3,..,n-2) ) { (x,y) = CAS(result(i), result(i+1)) result(i)= x result(i+i)= y } Merge the two halves of the array s
27
Sorting Odd-Even merge 2381216710 2 8 6 31217 21 8 736 10 172 8 3 612 1326710 8 12
28
Sorting Odd-Even merge sort
29
Sorting Odd-Even merge sort Nested algorithm, needs manual flattening for parallelism:
30
Sorting Advice for staying sane Write “twin” version in GPPL Debugging: step through PIX and your “twin” simultaneously
31
Sorting Or, just copy my stuff! Google: “Particle System Simulation and Rendering on the Xbox 360 GPU“
32
Sorting Sorting for cache coherency
33
Sorting Sorting performance
34
Sorting When incremental sorting fails Whenever there the position changes too quickly Prime example: Respawns Solution: Delay simulation/rendering of newly spawned particle for a few frames for sorting
35
Rendering
36
Point sprites
37
Rendering Geometry Amplification Produce N vertices for each particle Index Buffer Particle Buffer...
38
Results
42
A Complete XBox 360 GPU Particle System: Tech & Pipeline Sebastian Sylvan & Dr Simon Scarle Rare MGS
43
A Complete XBox 360 GPU Particle System: Tech & Pipeline Sebastian Sylvan & Dr Simon Scarle Rare MGS
44
An Complete XBox 360 GPU Particle System: Tech & Pipeline Sebastian Sylvan & Dr Simon Scarle Rare MGS
45
Old System 1.Artist wants a new particle system 2.Artist talks to Programmer 3.Programmer implements code/shaders to produce the effect 4.Artist looks at particles and wants it exactly the same only completely different 5.Goto 2 : Rinse & Repeat
46
New System Rare usually takes an Art Driven approach Creation of particle effects via art tool Sebastian's Tech demos implemented in our pipeline with this in mind – highly customisable – efficiency
47
Overview Artist Input Runtime Asset Interim Build Format
48
Artist Input Particle.mb produced by Maya – Main art package at Rare – Use Maya particle options as base Extend – custom attributes on particle nodes Random Scaling/orientation Soft Particles Timing
49
Interim Build Format Parse particle data from artist input – Rparticle Currently undergoing a de-Maya-ification process – i.e. add another rparticle producer – rparticle objects produced in WorldBuilder/Viewer
50
Rparticle Collection of arrays of custom data storage classes – RparticleObject – RparticleEmitter – RparticleField – RparticleRamp And a couple of R1 data classes – RmodelShader – RmodelNurbsCurve
51
Runtime Asset Simulation Shader Parameters Render Shader (Sorting Shader)
52
Simulation Shader Lego-ized/modular construction “Death to the Über-Particle by meta-coding” RparticleObject is parsed into two lists of ISimulationFragment – Initialisation – Simulation Fragments output needed HLSL to build up the shader
53
Simulation Shader Helper mini-fragments Initialisation Frags – Create a new particle – Depends on emitter Directional Omni-directional Volume Curve/Texture Simulation Frags – Euler integration for Newtonian motion – Fields Gravity/Uniform Drag radial vortex – Collisions Sphere plane
54
InitFragmentOmni initcode << GetRandomNumGenerator() << ‘’ void InitParticle( int index, inout Part particle ){‘’ ‘’float4 rnd = Random( index );’’ ’’particle.pos = float3( 0, 0, 0);’’ ‘’float3 buildVel = 2 * ( rnd.x – 0.5 );“ “float fac = sqrt ( 1 - buildVel.z* buildVel.z );” << SinCos( ‘’theta’’, ‘’2* PI* rnd.y’’ )<< “buildVel.x = fac* cosTheta;" “buildVel.y = fac* sinTheta;” “particle. Vel = buildVel;“; initcode GetMinDist(), m_emitter- >GetMaxDist() )<< “particle.vel *= ( 2* rnd.w - 1) *” GetSpeedRandom() GetSpeed() <<‘’;’’ << Epilogue( 0, pdesc );
55
Simulation Shader Very easy to add new types of emitter and dynamics – implement HLSL code in a ISimulationFragment Not a huge Über-shader – Only the Code needed Slight problem adding a new Feature to an “Active” Asset – Shader rebuild not just a parameter tweak
56
Render Shader Three customizations of our standard shader builder – no Über-shader again – Easy use of current special effects Three standard base types – Pointsprites – Line / Streaks – Quad / billboards / sprites
57
Render Shader geometry amplification for non-point sprite primitives – Use velocity to get 2 nd vertex for line particles – Produce further vertices for camera facing quads Once again only required parts of shader are present Line fade / colour change ramp textures to rotate/scale sprites
58
Parameters Broadest sense – Parameters/Data for effects Softness Spread Emitter transform – Position, direction – Textures Ramps – scaleX, scaleY, rotation, RGBA Curve / texture emitters
59
DEMONSTRATION
60
Emitters – Directional – Omni-directional – Volume Box Sphere Cylinder Cone torus – Curve Visual Effects – Normal map – Cube Map – Projection Textures Fields – Gravity – Radial – Vortex – Drag Ramps – Scaling – Rotation – RGBA
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.