Game Development Reference
In-Depth Information
4.7
Supporting Different Shaders
Like all forward rendering, we can attach different shaders and resources (tex-
tures, uniforms, etc.) to different chunks of geometry. Of course, if desired, we
can still use the ubershader approach in the forward rendering.
We have implemented three different shader types to test this, as seen in
Figure 4.1(d) : a default diffuse-specular shader, a shader emulating two-color car
paint (see transparent bubbles and lion), and a rim-light shader (see large fabric
in the middle of the scene).
The forward renderer uses the different shaders, compiled as different shader
programs, with different chunks of geometry. For comparison, we implemented
this as an ubershader for deferred rendering. An integer identifying which shader
should be used is stored in the G-buffer for each sample. (There were some
unused bits available in the G-buffer, so we did not have to allocate additional
storage.) The deferred shading code selects the appropriate shader at runtime
using runtime branches in GLSL.
Performance degradation for using different shaders seems to be slightly smaller
for the forward renderer; switching from diffuse-specular shading only to using
the different shaders described above caused performance to drop by 1 . 4mson
average. For the deferred shader, the drop was around 2 . 2ms. However,thevari-
ations in rendering time for different views are in the same order of magnitude.
4.8
Conclusion and Further Improvements
We have explored tiled forward shading in this chapter. Tiled forward shading
combines advantages from both tiled deferred shading and standard forward ren-
dering. It is quite adaptable to different conditions, by, for instance, omitting
steps in the algorithm made unnecessary by application-specific knowledge. An
example is the optional computation of minimum and/or maximum Z-bounds for
top-down views.
An extension that we have been exploring recently is clustered shading . Tiled
shading (both forward and deferred) mainly considers 2D groupings of samples,
which, while simple, cause performance and robustness issues in some scene and
view configurations. One example of this is in scenes with first-person-like cam-
eras where many discontinuities occur in the Z-direction ( Figure 4.5 ). In clus-
tered shading, we instead consider 3D groupings of samples, which handle this
case much more gracefully.
Clustered shading's main advantage is a much lower view dependency, deliver-
ing more predictable performance in scenes with high or unpredictable complexity
in the Z-direction. The disadvantages are increased complexity, requirements on
hardware (we rely heavily on compute shaders/CUDA), and several new constant
costs. For instance, with tiled shading, the subdivision of the screen into tiles is
basically free. In clustered shading, this step becomes much more expensive—in
 
 
Search Nedrilad ::




Custom Search