1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-17 14:11:06 +00:00

Add optimizing AT_LIGHT_PASS builtin to canvas shaders

This one allows for complex shaders paired with a simple lighting shader to skip code that would otherwise be pointlessly (and wastefully) run during the light pass.
You can use `if (AT_LIGHT_PASS) , negated or not, and that will be converted to a preprocessed #if when the shader is compiled.
Depending on your game (number of items and lights), this can be a *significant* performance gain, or at least avoids relying on the driver's optimizing abilities.
This commit is contained in:
Pedro J. Estébanez
2017-06-09 19:19:43 +02:00
parent 5f98c16d59
commit 184ef18420
4 changed files with 61 additions and 7 deletions

View File

@@ -1124,6 +1124,7 @@ const ShaderLanguage::BuiltinsDef ShaderLanguage::ci_vertex_builtins_defs[] = {
{ "PROJECTION_MATRIX", TYPE_MAT4 },
{ "EXTRA_MATRIX", TYPE_MAT4 },
{ "TIME", TYPE_FLOAT },
{ "AT_LIGHT_PASS", TYPE_BOOL },
{ NULL, TYPE_VOID },
};
const ShaderLanguage::BuiltinsDef ShaderLanguage::ci_fragment_builtins_defs[] = {
@@ -1145,6 +1146,7 @@ const ShaderLanguage::BuiltinsDef ShaderLanguage::ci_fragment_builtins_defs[] =
// { "SCREEN_POS", TYPE_VEC2},
// { "SCREEN_TEXEL_SIZE", TYPE_VEC2},
{ "TIME", TYPE_FLOAT },
{ "AT_LIGHT_PASS", TYPE_BOOL },
{ NULL, TYPE_VOID }
};