Mixing shadow maps with a diffuse bass texture

EDIT, for teh love of gord, err, hahaa. It was a pesky spelling mistake all along. I would have normally caught this but its been a long day, honest. I really need to start using and ide for these things.
I tried to delete the post but the message board insists on rubbing in a bit. Cheers :sleeping:

Hi, I’m trying to get my shadow maps to work over textured objects but after after having no luck at all and i’m clueless as to what to try next.

I’ve got my shadow map texture set up and projected as normal and that works fine, but if I try to load a diffuse texture into the fragment shader, the shadowing stops showing up and only the teh diffuse is shown. Here are the basic shaders.


varying vec4 ProjShadow;
varying vec2 Texcoord;


void main(void)
{
	ProjShadow = gl_TextureMatrix[1] * gl_ModelViewMatrix * gl_Vertex;
	Texcoord = gl_MultiTexCoord0.xy;
	gl_Position = ftransform();
}
________________________________________________________________

uniform sampler2D base_map;
varying vec2 Texcoord;

uniform sampler2DShadow shadowMap;
varying vec4 ProjShadow;

void main (void)
{
	vec3 color = vec3(1, 1, 1);
	//vec3 color = texture2D(base_map, Texcord); <- OOPS
	color *= shadow2DProj(shadowMap, ProjShadow).r;
	gl_FragColor = vec4(color, 1);
}

I’ve got my base_map set up on TEXTURE0 and the shadow map on TEXTURE1, like below.


        glActiveTexture(GL_TEXTURE0);
	glBindTexture(GL_TEXTURE_2D, texture);
	glUniform1i(glGetUniformLocation(shader1, "base_map"), 0);

	glActiveTexture(GL_TEXTURE1);
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, textureDepth);
	glUniform1i(glGetUniformLocation(shader1, "shadowMap"), 1);

	//Shadow texture compare funcs
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);

As I said before if I comment out the line “vec3 color = texture2D(base_map, Texcord);” in the frag shader the shadow works fine and I can set the solid color of the object with the color vec3, but if I uncomment the line I just mentioned the shadowing stops working and alls i’m left with is a base_map textured object.

So, how come its not working, is it because of the compare funcs or am I just doing something a bit daft somewhere?

Can I get shadow maps and textures working happily in the same shader, or will i need to do a multipass?

Many thanks.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.