Jump to content
  • Advertisement
Sign in to follow this  

problem with shader

This topic is 4371 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

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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!