• Advertisement
Sign in to follow this  

glsl twist effect

This topic is 3943 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi: i write a effect of shader that a quad has two texture and the second texture inside the first texure.the shader as fellow:
vertex:
varying vec2 tex1;
void main()
{
	gl_TexCoord[0] = gl_MultiTexCoord0;
	gl_TexCoord[1] = gl_MultiTexCoord0;
	tex1 = gl_MultiTexCoord0;
	gl_Position = ftransform();
} 
fragment:
uniform sampler2D TextureUnit0;
uniform sampler2D TextureUnit1;
varying vec2 tex1;
void main()
{	
	vec4 value1 = texture2D(TextureUnit0, gl_TexCoord[0]);
	vec4 value2 = texture2D(TextureUnit1, gl_TexCoord[1]);

	if(tex1.x >= 0.2 && tex1.y >= 0.2 &&
		tex1.x <= 0.8 && tex1.y <= 0.8)
		gl_FragColor = value2;
	else
		gl_FragColor = value1;
}
the problem is there is a black quad below the effect quad. Is texture coordnate wrong?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement