Graphics Reference
In-Depth Information
if (p.Position.y == p.OldPosition.y && p.Energy > 1.0f)
p.Energy = 1.0f;
if (p.Energy > 0) {
// If particle is alive add back to append buffer
NewState.Append(p);
}
}
This completes our HLSL code. Now, we will create our C# renderer class.
8.
Add a new renderer class named ParticleRenderer that inherits from the
Common.RendererBase instance, and implement an empty default constructor.
9.
Within the ParticleRenderer class, we will define the C# structures for the HLSL
structures declared earlier.
// Structure for particle
public struct Particle
{
public Vector3 Position;
public float Radius;
public Vector3 OldPosition;
public float Energy;
}
// Particle constants (updated on initialization)
public struct ParticleConstants
{
public Vector3 DomainBoundsMin;
public float ForceStrength;
public Vector3 DomainBoundsMax;
public float MaxLifetime;
public Vector3 ForceDirection;
public int MaxParticles;
public Vector3 Attractor;
public float Radius;
}
// particle constant buffer updated per frame
public struct ParticleFrame
{
public float Time;
public float FrameTime;
public uint RandomSeed;
// use CopyStructureCount for last component
uint _padding0;
}
 
Search WWH ::




Custom Search