deferred lighting

21
Inferred rendering http://ozlael.egloos.com/

Upload: ozlael-ozlael

Post on 10-May-2015

3.912 views

Category:

Technology


4 download

DESCRIPTION

Deferred lighting

TRANSCRIPT

Page 1: Deferred lighting

Inferred rendering

http://ozlael.egloos.com/

Page 2: Deferred lighting

Forward Rendering

● Traditional Render

● Single Pass Lighting

● Multipass Lighting

Page 3: Deferred lighting

Forward Rendering:Single Pass Lighting

● For each object:

Render mesh, applying all lights in one shader

● Good for scenes with small numbers of lights (eg.outdoor sunlight)

● Difficult to organize if there are many lights

● Shader combinations explosion

Page 4: Deferred lighting

Forward Rendering:Multipass Lighting

● For each light:

– For each object affected by the light:

● framebuffer += object * light

● Worst case complexity is num_objects * num_lights

● Shader for each material and light type

Page 5: Deferred lighting

Forward Rendering:Multipass Lighting

● Wasted shader cycles

– Invisible surfaces / overdraw

– Triangles outside light influence

● Ideally the scene should be split exactly along lightboundaries, but getting this right for dynamic lightscan be a lot of CPU work

Page 6: Deferred lighting

Deferred Rendering

● For each object:

– Render to multiple targets

– Render surface properties into the G-Buffer

● For each light:

– Apply light as a 2D postprocess

– Use G-Buffer to compute lighting

– Add result to frame buffer

Page 7: Deferred lighting

Deferred Rendering

● Worst case complexity is num_objects + num_lights

● Simpler shaders

Page 8: Deferred lighting

Deferred RenderingG-buffer

Page 9: Deferred lighting

Deferred RenderingG-buffer

Page 10: Deferred lighting

Deferred RenderingG-buffer

Page 11: Deferred lighting

Deferred RenderingResult

Page 12: Deferred lighting

MRT

Page 13: Deferred lighting

Determine Lit Pixels

Page 14: Deferred lighting

Determine Lit Pixels

Page 15: Deferred lighting

Early-Z Pass

● Similar to Early-Z Pass

– 1st Pass: Visibility tests

– 2nd Pass: Shading

● Different than Early-Z Pass

– Geometry is only transformed once

Page 16: Deferred lighting

Deferred RenderingWeak point

● Does not handle transparent objects

– Forward Rendering Pass

● H/W Anti-aliasing difficult

● Material limited

● Many memory bandwidth

Page 17: Deferred lighting

Pre-light Pass

● Geometry pass:

– fill up normal and depth buffer

● Lighting pass:

– store light properties in light buffer

● 2. Geometry pass:

– fetch light buffer and apply different material terms per surface by re-constructing the lighting equation

Page 18: Deferred lighting

Pre-light Pass

● Geometry pass:

– fill up normal and depth buffer

● Lighting pass:

– store light properties in light buffer

● 2. Geometry pass:

– fetch light buffer and apply different material terms per surface by re-constructing the lighting equation

Page 19: Deferred lighting

Pre-light Pass

NormalsSpecular Power Depth

Light Buffer

Frame Buffer

Render opaque Geometry sorted front-to-back

Blit Lights into Light Buffer (sorted front-to-back)

Render opaque Geometry sorted front-to-backorBlit ambient term and other lighting terms into final image

Color

Page 20: Deferred lighting

Pre-light Pass

Resistance 2TM in-game screenshot; first row on the left is the depth buffer, on the right is the normal buffer; in the second row is the diffuse light buffer

and on the right is the specular light buffer; in the last row is the final result.

Page 21: Deferred lighting

Pre-light Pass

● Flexible Materials

● H/W MSAA

● Not Lighting/Shadowing Alpha Geometry