|
The DepthExplosion sample demonstrates the use of depth
sprites for rendering explosions. Depth sprites, like
billboards serve the purpose of simplifying the rendered
scene by rendering 2D images oriented towards the viewer
instead of complex 3D models. The problem with the billboards
is that they are flat images and when they intersect
the scene geometry they cannot represent complex depth
interaction of the object with the scene. The depth
sprites solve this problem by overwriting depth values
for the flat 2D billboard with pre-rendered depth stored
in 2D image.
The DepthExplosion samples renders two instances of
animated explosion, one using regular billboards and
another one using depth sprites. The later looks much
more realistic as it intersects scene geometry in non-planar
way and looks like a highly tessellated object. In both
cases just a single quad is used to render an explosion.
The sample uses 1.4 pixel shaders to render depth sprites
with "texdepth" instruction. The "texdepth"
instruction in 1.4 pixel shaders allows to overwrite
polygons depth information with values computed in the
shader as (r5.r / r5.g). The depth information for the
drawn object is encoded in a texture and in case of
this sample is a depth of a hemisphere. The sample computes
depth scale and bias to place the sprite object in the
proper place in the scene and passes those values through
texture coordinate interpolators to the shader. The
texture coordinate interpolators have higher precision
than shader constants which allows for very fine control
of depth values exported out of the pixel shader
|