Choosing a shading model

REDsdk offers a few built-in material models or it can be used in a custom and flexible way by defining custom shaders and materials. The guidelines and hints below all apply to hardware rendering.

Using built in materials

A complete material can be created in one call: RED::IMaterial::SetupGenericMaterial or RED::IMaterial::SetupRealisticMaterial. Resulting materials will be both made of several REDsdk built-in shaders. For instance a simple generic material will use (among other shaders):

So we can see that this will potentially imply several rendering passes for the scene (see Accumulating rendering passes), so potentially, this can slow down the display of the model.

Of course, then, this is very flexible, as lights can be dynamically added and removed and the rendering will dynamically show changes that have occurred. Each built-in REDsdk shader for the RED::MTL_LIT pass supports all kinds of lights that exist in REDsdk, so it's easy to assemble a high quality real-time view of a model.

So often, the drawback is there: this flexibility comes at the expense of a rendering pass per light present in the model, plus one pass for the pre-lighting and another one for the post-lighting. If lights are focused and have limited effect areas, this may not be a problem; but if lights have wide effect areas and if there are many of them to render each frame, this can consume time, and it may be somehow interesting to switch to a custom shading model.

Using a custom shading model

REDsdk materials can be customized. Custom shaders can be written. See Writing a custom material for details. A deferred lighting pipeline can be setup (see Deferred shading using multiple render targets), so there's no real limitation to the level of customization that can take place for the rendering of a given model in a REDsdk based application.

That being said, most important is the fact that the geometry should be processed once. One single rendering pass is a must have, to avoid rendering all the triangles, lines or primitives that are contained in the scene, when this number of primitives is the performance bottleneck.

The RED::RenderShaderViewport is also a all-in-one CAD style viewporting shader that can be used to speed-up the display of a given model. The book Improving CAD graphics also detail a customized "one pass" shading model.