[Bf-blender-cvs] [4510f30026d] blender2.8: GPUMaterial: Fix nearest sampling

Clément Foucault noreply at git.blender.org
Wed Aug 1 22:10:39 CEST 2018


Commit: 4510f30026da8eb090062687f386b9e3a7cf3fa3
Author: Clément Foucault
Date:   Wed Aug 1 18:07:19 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB4510f30026da8eb090062687f386b9e3a7cf3fa3

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

===================================================================

M	source/blender/gpu/shaders/gpu_shader_material.glsl

===================================================================

diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl
index 464851bae21..8cc603696df 100644
--- a/source/blender/gpu/shaders/gpu_shader_material.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material.glsl
@@ -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;
 }



More information about the Bf-blender-cvs mailing list