Skip to content

Render Usage

By default, Surface Shaders mainly output to the screen and display scenes.

However, sometimes we have some special needs, such as:

  • Render to shadow maps
  • Render to reflect maps

Different render usages have different processes and details, so they need special handling.

The Surface Shader framework has predefined the commonly used flows for different usages. They can be found in the Assets/internal/chunks/shading-entries/main-functions/ folder.

Here are built-in render usages.

Common Render UsagesLocationDescription
Render to Scene(default)render-to-scene
Render to ShadowMaprender-to-shadowmap
Render to ReflectionMaprender-to-reflectmapOptional
Render Cartoon Outlinesmisc/silhouette-edge
Render Skyboxmisc/sky
Post-processing or General Compute Passmisc/quadReserved

You only need to include the corresponding header files during the Surface Shader Assembly phase to complete the rendering process.

For example, in internal/effects/builtin-standard.effect, we can see the application cases as follows.

glsl
CCProgram standard-vs %{
    ...
    #include <shading-entries/main-functions/render-to-scene/vs>
}%

CCProgram shadow-caster-vs %{
    ...
    #include <shading-entries/main-functions/render-to-shadowmap/vs>
}%

CCProgram standard-fs %{
    ...
    #include <shading-entries/main-functions/render-to-scene/fs>
}%

CCProgram shadow-caster-fs %{
    ...
    #include <shading-entries/main-functions/render-to-shadowmap/fs>
}%

CCProgram reflect-map-fs %{
    ...
    #include <shading-entries/main-functions/render-to-shadowmap/fs>
}%