RAMSES Documentation  27.0.130
Information for RAMSES users and developers
RAMSES Effects and Binary Shaders

Overview

A ramses::Effect describes how geometry is rendered to the screen. An effect consists mainly of vertex and fragment shaders and an optional geometry shader, written in the OpenGL Shading Language(GLSL). RAMSES supports shaders provided as source code strings or binary shaders.

Creating Effects from GLSL Source code

Effects can be created from GLSL source code during runtime. To do so, fill out a ramses::EffectDescription instance with the required data (refer to class documentation for more details) and pass it to ramses::RamsesClient::createEffect().

Loading from a resource file

Effects can also be stored in a RAMSES resource file, which can be loaded by ramses::RamsesClient::loadResources. RAMSES delivers utilities to pack effects to such resource files, see the RAMSES Shader Tools documentation.

Supported GLSL versions in RAMSES

RAMSES supports the following versions of GLSL:

Shader language version OpenGL version
GLSL-ES 1.00 OpenGL ES 2.0
GLSL-ES 3.00 OpenGL ES 3.0
GLSL-ES 3.10 OpenGL ES 3.1
GLSL-ES 3.20 OpenGL ES 3.2
GLSL 4.20 OpenGL 4.2

The platform dependent variables are set to the minimum values, depending on the used GLSL version. For concrete values, see chapter Built-In Constants (section 7.4 for GLSL-ES 1.00, and section 7.3 for GLSL-ES 3.00 and GLSL 4.20) in the documents above.

Note
Because OpenGL is backwards-compatible, a GLSL-ES 1.00 shader can also be used on a GL-ES 3.0 renderer. Refer to OpenGL documentation for exact compatibility rules.

Using binary shaders

Beside the source code GLSL shaders, RAMSES also supports the usage of binary shaders. There are two ways to do so:

  • as a preprocessing step (useful for shaders known in advance)
  • during runtime on renderer side (useful if shaders are not known in advance or coming from remote scenes)

Both techniques have in common that the RAMSES application has to implement the ramses::IBinaryShaderCache interface. The only difference is who provides the binary version of the Effect - the ramses renderer or an offline shader compiler.

For each new Effect which is not known to RAMSES renderer, the renderer will request a binary shader for this effect by calling ramses::IBinaryShaderCache::hasBinaryShader() with the associated ramses::effectId_t on the binary shader cache implementation. If the binary shader cache implementation has the precompiled binary shader for this effect, it will provide it to the RAMSES renderer. In case the requested shader is missing from the cache, the renderer compiles the shader from its own source and offers it to be stored in the cache.

Precompiled binary shaders can be generated by using the RAMSES shader tools (see documentation for more details) in combination with an offline shader compiler, usually shipped together with the SDK of the target system.

Note
Binary shaders once obtained from the renderer might not work anymore, when the graphic driver or hardware was updated.