GPUMaterial: Fix issue with coloramp and constant interpolation
authorClément Foucault <foucault.clem@gmail.com>
Mon, 10 Sep 2018 16:29:14 +0000 (18:29 +0200)
committerClément Foucault <foucault.clem@gmail.com>
Tue, 11 Sep 2018 14:15:43 +0000 (16:15 +0200)
It was not respecting the clamp to edge texture param because we use
texelFetch directly in this case.

source/blender/gpu/shaders/gpu_shader_material.glsl

index 5ea888ca774d1e138515af7885b2b9b3113512a4..84e4165ac00fe7813a620b22939cb1987e70df22 100644 (file)
@@ -820,7 +820,8 @@ void valtorgb(float fac, sampler1DArray colormap, float layer, out vec4 outcol,
 
 void valtorgb_nearest(float fac, sampler1DArray colormap, float layer, out vec4 outcol, out float outalpha)
 {
-       outcol = texelFetch(colormap, ivec2(fac * textureSize(colormap, 0).x, layer), 0);
+       fac = clamp(fac, 0.0, 1.0);
+       outcol = texelFetch(colormap, ivec2(fac * (textureSize(colormap, 0).x - 1), layer), 0);
        outalpha = outcol.a;
 }