summaryrefslogtreecommitdiff
path: root/drivers/gles3
diff options
context:
space:
mode:
authorPedro J. Estébanez <pedrojrulez@gmail.com>2017-06-12 16:32:59 +0200
committerPedro J. Estébanez <pedrojrulez@gmail.com>2017-06-15 02:03:15 +0200
commit93ffd9023f0f685c7e0910397efa0a9b59326a81 (patch)
treeefac68542c0fd8728d6780b7105d73991c17dad0 /drivers/gles3
parent4d90750729ee79d11d207dc865db783ee6cab53a (diff)
Add 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. Depending on your game (number of items and lights), this can yield some performance gain.
Diffstat (limited to 'drivers/gles3')
-rw-r--r--drivers/gles3/shader_compiler_gles3.cpp1
-rw-r--r--drivers/gles3/shaders/canvas.glsl6
2 files changed, 7 insertions, 0 deletions
diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp
index b1f7b4c9bd..3376f99112 100644
--- a/drivers/gles3/shader_compiler_gles3.cpp
+++ b/drivers/gles3/shader_compiler_gles3.cpp
@@ -668,6 +668,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() {
actions[VS::SHADER_CANVAS_ITEM].renames["PROJECTION_MATRIX"] = "projection_matrix";
actions[VS::SHADER_CANVAS_ITEM].renames["EXTRA_MATRIX"] == "extra_matrix";
actions[VS::SHADER_CANVAS_ITEM].renames["TIME"] = "time";
+ actions[VS::SHADER_CANVAS_ITEM].renames["AT_LIGHT_PASS"] = "at_light_pass";
actions[VS::SHADER_CANVAS_ITEM].renames["COLOR"] = "color";
actions[VS::SHADER_CANVAS_ITEM].renames["NORMAL"] = "normal";
diff --git a/drivers/gles3/shaders/canvas.glsl b/drivers/gles3/shaders/canvas.glsl
index 017009015e..31fea8237a 100644
--- a/drivers/gles3/shaders/canvas.glsl
+++ b/drivers/gles3/shaders/canvas.glsl
@@ -59,6 +59,9 @@ out vec4 local_rot;
out highp vec2 pos;
#endif
+const bool at_light_pass = true;
+#else
+const bool at_light_pass = false;
#endif
@@ -191,6 +194,9 @@ in highp vec2 pos;
#endif
+const bool at_light_pass = true;
+#else
+const bool at_light_pass = false;
#endif
uniform mediump vec4 final_modulate;