|
Submitted by , posted on 05 August 2003
|
|
Image Description, by
This is a demo of my research into deferred lighting, using pixel shader 2
and high precision render targets, all lighting is done as a post process to
the geometry rendering. An article is also provided describing the maths and
techniques that are used by the demo.
The article and source code is at http://www.beyond3d.com/articles/deflight
This demo has 18 lights, a hemisphere, 2 directionals (with shadow maps) and
15 point lights. All affect all surfaces equally, all surfaces can have
diffuse, specular and bump maps effectively for free (the cost to use a
bump-map over not using one, is simple a texture lookup once in the geometry
phase). Cost per light is totally seperate from polygon count, each light is
simple the cost of running the pixel shader at each pixel it covers. Per
polygon cost is the cost of setting up the G-Buffer only, for cards with 4
channel 16 bit integers and multiple render-targets this is a single pass.
It also uses hardware z-reject for lights, which skips the pixel shader if
the result would not be visible. The has an interesting property, where
dense geometry can speed up the lighting. The shadow maps are also very
cheap, apart from the cost of generating the depth map, it only costs around
10 pixel shader instructions in the light shader. This is independent of the
number of surfaces/objects receiving the shadow, giving a lights shadow cost
of 1 simple vertex and pixel program per triangle (to generate the depth
map) and a few pixel shader instructions per screen pixel covered.
As each light is an actual geometric entity with size, shape and its own
shader that has full access to the view (depth and G-buffers), there is a
lot of potential for future expansion (atmoshperic scattering, translucent
objects etc).
Full source code including HLSL is provided.
|
|