summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclayjohn <claynjohn@gmail.com>2023-02-03 15:40:19 -0800
committerclayjohn <claynjohn@gmail.com>2023-02-03 15:40:42 -0800
commitdfbf4390816bee93b373549afc125969d9f13d17 (patch)
tree80c24bdaa604fb54dc3c9158eb801930c26d3469
parentb0598dcdb7cd96e2614b687a57a64ce12245e19e (diff)
Avoid shading CanvasGroup nodes twice
-rw-r--r--doc/classes/CanvasGroup.xml1
-rw-r--r--drivers/gles3/rasterizer_canvas_gles3.cpp2
-rw-r--r--drivers/gles3/shaders/canvas.glsl2
-rw-r--r--servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp2
4 files changed, 6 insertions, 1 deletions
diff --git a/doc/classes/CanvasGroup.xml b/doc/classes/CanvasGroup.xml
index 6eeff8fef3..45f77ba484 100644
--- a/doc/classes/CanvasGroup.xml
+++ b/doc/classes/CanvasGroup.xml
@@ -8,6 +8,7 @@
[b]Note:[/b] The [CanvasGroup] uses a custom shader to read from the backbuffer to draw its children. Assigning a [Material] to the [CanvasGroup] overrides the builtin shader. To duplicate the behavior of the builtin shader in a custom [Shader] use the following:
[codeblock]
shader_type canvas_item;
+ render_mode unshaded;
uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest;
diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp
index d08f7ba7b6..05d7ac4719 100644
--- a/drivers/gles3/rasterizer_canvas_gles3.cpp
+++ b/drivers/gles3/rasterizer_canvas_gles3.cpp
@@ -2684,6 +2684,7 @@ RasterizerCanvasGLES3::RasterizerCanvasGLES3() {
// Default CanvasGroup shader.
shader_type canvas_item;
+render_mode unshaded;
uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest;
@@ -2711,6 +2712,7 @@ void fragment() {
// Default clip children shader.
shader_type canvas_item;
+render_mode unshaded;
uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest;
diff --git a/drivers/gles3/shaders/canvas.glsl b/drivers/gles3/shaders/canvas.glsl
index 1631c65385..12a8302231 100644
--- a/drivers/gles3/shaders/canvas.glsl
+++ b/drivers/gles3/shaders/canvas.glsl
@@ -645,7 +645,7 @@ void main() {
#ifdef MODE_LIGHT_ONLY
color = vec4(0.0);
-#else
+#elif !defined(MODE_UNSHADED)
color *= canvas_modulation;
#endif
diff --git a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp
index bd8c11186e..f102bc0650 100644
--- a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp
@@ -2634,6 +2634,7 @@ RendererCanvasRenderRD::RendererCanvasRenderRD() {
// Default CanvasGroup shader.
shader_type canvas_item;
+render_mode unshaded;
uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest;
@@ -2661,6 +2662,7 @@ void fragment() {
// Default clip children shader.
shader_type canvas_item;
+render_mode unshaded;
uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest;