Graphics Reference
In-Depth Information
The completed project and the following textures can be found in the downloadable
companion code as well as the following textures for use within our particle renderer:
Two semitransparent particle textures (the transparent area is black). Particle on left-hand side
and Snowflake on right-hand side
How to do it…
To begin with, we will add our new HLSL shader code, then create a particle renderer to run
the compute shaders to generate/update the particles, and lastly render the particles:
1. Add four new HLSL source files, Particle.hlsl , ParticleCS.hlsl ,
ParticlePS.hlsl , and ParticleVS.hlsl . Include them in the project and
select Copy if newer as the build action. Remember to change the text encoding
or copy from the existing HLSL files (as described in the Rendering primitives
recipe of Chapter 2 , Rendering with Direct3D ).
2.
Within Particle.hlsl , add our particle constant buffers and structures.
// Particle system constants
cbuffer ParticleConstants : register(b0)
{
float3 DomainBoundsMin;
float ForceStrength;
float3 DomainBoundsMax;
float MaxLifetime;
float3 ForceDirection;
uint MaxParticles;
float3 Attractor;
float Radius;
};
// Particles per frame constant buffer
cbuffer ParticleFrame : register(b1)
{
 
Search WWH ::




Custom Search