Is it sensible to compile a shadestyle written in GLSL once, so that it is reused every frame, and if so, how do I do that? Also if there is a way to use a separate file for better organization and so my IDE can do syntax highlighting, that would be useful.
ShadeStyleManager
attempts to cache and prevent shader compilations. It uses two mechanisms for caching:
First it looks for a shader by looking up ShadeStyle
by its identity. If a shader is found it uses that. If a shader is not found it looks for a shader by hashing the active ShadeStyle
. If no shader is found it generates it.
In practice you can reduce a bit of hashing overhead by creating shade styles inside program {}
program {
val someShadeStyle = shadeStyle {
fragmentTransforms = ...
}
extend {
drawer.shadeStyle = someShadeStyle
... draw things here ...
}
}
2 Likes