![]() |
RAMSES Documentation
27.0.130
Information for RAMSES users and developers
|
Effects in RAMSES are immutable client resources, and as such follow the same lifecycle as any other client resources:
The typical lifecycle of an effect resource is:
It is important to note that effects and binary shaders are two different objects, and their IDs, despite having relationship to each other, have different values. Client-side effects have resource type ID same as any other ramses::Resource - ramses::resourceId_t. The renderer, however, refers to the binary shaders for effects by their ramses::effectId_t. Both are 128bit numbers, but their values are inherently different for the same effect. Tools which deal with effects reflect this behavior and offer the option to provide both types by providing a special command-line argument (–out-effect-id-type).
The client-side resourceId can be used to identify effects on the client side (e.g. when loading from files) while the renderer-side resourceId can be used with ramses::IBinaryShaderCache, or when using the resource caching interface ramses::IRendererResourceCache which follows similar principles.
One essential difference between Effects and other resources is that effects are considerably more expensive to create during runtime for two reasons:
To skip the GLSlang compilation step in ramses::RamsesClient::createEffect(), the client application can simply do this step in a preprocessing step for all known in advance effects and store the result in resource files. For convenience, ramses provides a tool for exactly this purpose. See (Storing effects in resource files) for more info how to use it.
To skip the compilation on the renderer side, it is enough to provide a binary shader when asked for it in ramses::IBinaryShaderCache::hasBinaryShader(). In order for this to work, the binary shader must match exactly the source code of the original effect. In particular, this means:
In order to make this task easier and avoid errors in the generation of binary shaders, RAMSES provides specialized tooling to convert GLSL code to binary shaders (Storing GLSL as binary shaders). RAMSES DOES NOT provide the specific offline shader compiler - this is something which is typically included in the development SDK of the target platform. RAMSES prepares the shaders only to the point where the generated source code can be passed to the offline shader compiler.