Sign in to follow this  
huaner

glsl twist effect

Recommended Posts

huaner    100
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this