Graphics Reference
In-Depth Information
float4 RandomVector;
};
static const float3 direction[8] =
{
normalize( float3( l.0f, l.0f, l.0f ) ),
normalized float3( -l.0f, l.0f, l.0f ) ),
normalized float3( -l.0f, -l.0f, 1.0f ) ),
normalized float3( l.0f, -l.0f, l.0f ) ),
normalize( float3( l.0f, l.0f, -l.0f ) ),
normalize( float3( -l.0f, l.0f, -l.0f ) ),
normalize( float3( -l.0f, -l.0f, -l.0f ) ),
normalize( float3( l.0f, -l.0f, -l.0f ) )
};
[numthreads( 8, 1, 1)]
void CSMAIN( uint3 GroupThreadID : SV_GroupThreadID )
{
Particle p ;
II Initialize position to the current emitter location
p.position = EmitterLocation.xyz;
// Initialize direction to a randomly reflected vector
p.direction = reflect( direction[GroupThreadID.x], RandomVector.xyz ) * 5.ef;
// Initialize the lifetime of the particle in seconds
p.time = 0.0f;
// Append the new particle to the output buffer
NewSimulationState.Append( p );
}
Listing 12.9. The compute shader for dynamically adding particles into the system.
Figure 12.12. Particles emitted in randomized directions from an emission point.
Search WWH ::




Custom Search