Browse Source

Merge pull request #72695 from clayjohn/CanvasGroup-shading

Avoid shading CanvasGroup nodes twice
Yuri Sizov 2 years ago
parent
commit
2bd5302704

+ 1 - 0
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;
 

+ 2 - 0
drivers/gles3/rasterizer_canvas_gles3.cpp

@@ -2690,6 +2690,7 @@ RasterizerCanvasGLES3::RasterizerCanvasGLES3() {
 // Default CanvasGroup shader.
 
 shader_type canvas_item;
+render_mode unshaded;
 
 uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest;
 
@@ -2717,6 +2718,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;
 

+ 1 - 1
drivers/gles3/shaders/canvas.glsl

@@ -649,7 +649,7 @@ void main() {
 
 #ifdef MODE_LIGHT_ONLY
 	color = vec4(0.0);
-#else
+#elif !defined(MODE_UNSHADED)
 	color *= canvas_modulation;
 #endif
 

+ 2 - 0
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;