|
The ProceduralFire sample demonstrates the use of pixel
shaders to procedurally generate natural phenomena such
as fire.
Rendering fire as an animation has the disadvantages
of looking unrealistic due to the cycling animation
and of requiring a lot of texture memory to store the
frames of animation. In addition to this, if there are
many flames in the scene, and all use the same animation,
the scene will look even more artificial.
The procedurally generated fire overcomes all these
disadvantages by generating long non-repeating animations
that can be fully controlled by the application and
requires only two textures. The sample uses 1.4 pixel
shader to implement the effect.
The ProceduralFire sample creates a fire effect by rendering
a billboard. This billboard has three perturbation textures
vertically scrolling at different speeds and a base
flame texture mapped onto it. Three perturbation values
are combined in the pixel shader and used to lookup
the base flame image with a dependent texture read.
The perturbation is attenuated in the vertical direction
to make top of the flame more turbulent than the base.
The sample can be further advanced for rendering multiple
unique flames simultaneously. The vertex shader can
be used to pass unique per-flame parameters to the pixel
shader through texture coordinate interpolators and
to vary perturbation maps scrolling speed and offset.
|