Sign in to follow this  

problem with shader

Recommended Posts

Hey, I'm trying to achieve this effect: one texture on the dark side, other on the light side. I asked this before somewhere in this forum and I got pretty good answers. But I tried to do it, and this is the result I get: notice the dark side isnt very well shaded... it should affect half the globe but it doesnt... what could be wrong? here the shaders: Vertex shader:
varying vec3 lightDir,normal, viewVec;
void main()
	normal = normalize(gl_NormalMatrix * gl_Normal);
	lightDir = normalize(vec3(gl_LightSource[0].position));
	gl_TexCoord[0] = gl_MultiTexCoord0;
	gl_Position = ftransform();

Fragmeng shader:
varying vec3 lightDir, normal;
uniform sampler2D tex, tex2;

void main()
	vec3 nnormal = normalize(normal);	
	float intensity = max(dot(lightDir, nnormal),0.0);
	gl_FragColor = mix(texture2D(tex,gl_TexCoord[0].st).rgba, texture2D(tex2,gl_TexCoord[0].st).rgba, intensity);

any help? thanks, once again

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