Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2019-04-05 15:37:38 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-04-05 15:38:27 +0300
commitf0d6879f5c7998be98ac406bd6ddaa5104961206 (patch)
tree520e2e08c12d215e29c790dd9b85a3aa7e41f226
parenta180b754eb40637a5d37eeb0ae60066f5a6f93d8 (diff)
Fix T62892 EEVEE HDRI lightning glitch
Clamp the texture at sampling time. This is not the best way to do it but this is the fastest/simplest. The cost is rather negligeable.
-rw-r--r--source/blender/gpu/shaders/gpu_shader_material.glsl17
1 files changed, 10 insertions, 7 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl
index 5f54b53987e..9f3ea4acfb1 100644
--- a/source/blender/gpu/shaders/gpu_shader_material.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material.glsl
@@ -2081,22 +2081,25 @@ void node_tex_environment_empty(vec3 co, out vec4 color)
color = vec4(1.0, 0.0, 1.0, 1.0);
}
+/* 16bits floats limits. Higher/Lower values produce +/-inf. */
+#define safe_color(a) (clamp(a, -65520.0, 65520.0))
+
void node_tex_image_linear(vec3 co, sampler2D ima, out vec4 color, out float alpha)
{
- color = texture(ima, co.xy);
+ color = safe_color(texture(ima, co.xy));
alpha = color.a;
}
void node_tex_image_linear_no_mip(vec3 co, sampler2D ima, out vec4 color, out float alpha)
{
- color = textureLod(ima, co.xy, 0.0);
+ color = safe_color(textureLod(ima, co.xy, 0.0));
alpha = color.a;
}
void node_tex_image_nearest(vec3 co, sampler2D ima, out vec4 color, out float alpha)
{
ivec2 pix = ivec2(fract(co.xy) * textureSize(ima, 0).xy);
- color = texelFetch(ima, pix, 0);
+ color = clamp(texelFetch(ima, pix, 0));
alpha = color.a;
}
@@ -2138,10 +2141,10 @@ void node_tex_image_cubic_ex(vec3 co, sampler2D ima, float do_extend, out vec4 c
}
final_co /= tex_size.xyxy;
- color = textureLod(ima, final_co.xy, 0.0) * s0.x * s0.y;
- color += textureLod(ima, final_co.zy, 0.0) * s1.x * s0.y;
- color += textureLod(ima, final_co.xw, 0.0) * s0.x * s1.y;
- color += textureLod(ima, final_co.zw, 0.0) * s1.x * s1.y;
+ color = safe_color(textureLod(ima, final_co.xy, 0.0)) * s0.x * s0.y;
+ color += safe_color(textureLod(ima, final_co.zy, 0.0)) * s1.x * s0.y;
+ color += safe_color(textureLod(ima, final_co.xw, 0.0)) * s0.x * s1.y;
+ color += safe_color(textureLod(ima, final_co.zw, 0.0)) * s1.x * s1.y;
#else /* Reference bruteforce 16 tap. */
color = texelFetch(ima, ivec2(tc + vec2(-1.0, -1.0)), 0) * w0.x * w0.y;