From 0e56b64fc4bfefdc70f5a29bc0089404c24e597d Mon Sep 17 00:00:00 2001 From: sunfl0w Date: Sun, 26 May 2024 17:15:39 +0200 Subject: [PATCH] Fix albedo value wraparound in Compatibility render mode Using the Compatibility renderer results in wrapped albedo values if a custom shader returns albedo values outside the expected range of [0,1]. This commit fixed this issue by clamping the albedo value to [0,1] right after the custom shader is executed. Fixes #91919 --- drivers/gles3/shaders/scene.glsl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index 2b372cb88d4a..be7a6aba578c 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -1523,6 +1523,9 @@ void main() { #CODE : FRAGMENT } + // Keep albedo values in positive number range as negative values "wraparound" into positive numbers resulting in wrong colors + albedo = max(albedo, vec3(0.0)); + #ifdef LIGHT_VERTEX_USED vertex = light_vertex; #ifdef USE_MULTIVIEW