How to do custom subj in fragment program with filtering mode set to GL_NEAREST ?
What does “subj” mean in your question?
I think subj is an alias for the title.
You can do something quick and cheap with clamping the texcoord, then do sampling at the 4 local texels :
{x, y)
(x+1, y)
(x, y+1)
(x+1, y+1)
then do a weighted blend between the 4.
I’ve understood how to do it!
float OneTexel = 1.0/TextureSize;
vec2 coord1 = TexCoord0+vec2(0.0, OneTexel);
vec2 coord2 = TexCoord0+vec2(OneTexel, 0.0 );
vec2 coord3 = TexCoord0+vec2(OneTexel, OneTexel);
vec2 coord4 = TexCoord0;
vec4 s1 = vec4(texture2D(Texture0, coord1));
vec4 s2 = vec4(texture2D(Texture0, coord2));
vec4 s3 = vec4(texture2D(Texture0, coord3));
vec4 s4 = vec4(texture2D(Texture0, coord4));
vec2 Dimensions = vec2(TexCoord0) * TextureSize;
float fu = fract(Dimensions.x);
float fv = fract(Dimensions.y);
vec4 tmp1 = mix(s4, s2, fu);
vec4 tmp2 = mix(s1, s3, fu);
vec4 t0 = mix(tmp1, tmp2, fv);
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.