2.21. Deferred Rendering: Position Reconstruction | 2. Design And Implementation | 2.23. Normal Mapping |
Previous | Up | Next |
Forward rendering (Translucency)
Overview
Because the
deferred renderer in the
r2 package is incapable of rendering
translucent instances, a separate
forward renderer is provided. A
translucent instance is an instance that, when rendered, is simply blended with the current image. This is used to implement visual effects such as glass, water, smoke, fire, etc.
Instances
The
r2 package provides a slightly different abstraction for translucent instances. Because of the strict
ordering requirements when rendering translucent instances, it is simply not possible to batch translucent instances by material and shaders for performance reasons as is done with
opaque instances. The
r2 package therefore simply has users submit a list of values of type
R2TranslucentType in draw order. Each translucent value contains a
blending and
culling configuration, along with an
instance, and a
shader for rendering the instance.
Blending
Each translucent instance provides a blending configuration that states how the rendered instance is blended with the contents of the current framebuffer.
Culling
Typically, it is not desirable to render the back faces of opaque instances as they are by definition invisible. However, translucent instances are by definition translucent and therefore the back faces of the instances may be visible. A translucent instance therefore contains a value that specifies whether front faces, back faces, or both should be rendered.
Ordering
Unlike opaque instances which can be rendered in any order due to depth testing, translucent instances must be rendered in strict furthest-to-nearest order. The r2 package simply delegates the responsibility of submitting instances in the correct order to the user. This frees the package from having to know anything about the spatial properties of the scene being rendered.
Provided Shaders
Because translucent surface can have a massive range of appearances, the r2 package makes no attempt to provide a wide range of shaders for translucent surfaces.
Previous | Up | Next |
2.21. Deferred Rendering: Position Reconstruction | 2. Design And Implementation | 2.23. Normal Mapping |