GPUMaterial: Fix nearest sampling

texelFetch return vec4(0.0) if the target pixel is outside the texture
rect. So we mimic the default repeate mode that we have for linear
interpolation.

Fix T56156 Mapping-Node doesn't work
This commit is contained in:
Clément Foucault
2018-08-01 18:07:19 +02:00
parent c6f55fb0db
commit 4510f30026

View File

@@ -1809,7 +1809,7 @@ void node_tex_image_linear(vec3 co, sampler2D ima, out vec4 color, out float alp
void node_tex_image_nearest(vec3 co, sampler2D ima, out vec4 color, out float alpha)
{
ivec2 pix = ivec2(co.xy * textureSize(ima, 0).xy);
ivec2 pix = ivec2(fract(co.xy) * textureSize(ima, 0).xy);
color = texelFetch(ima, pix, 0);
alpha = color.a;
}