Projective texture shader

trying to replicate the OGL fixed function pipeline for projective textures:

vert shader:

  
void main()
{
	gl_TexCoord[0] = gl_TextureMatrix[0] * gl_Vertex; 
	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}

frag shader:

  
uniform sampler2D shadowMap;

void main()
{
	vec4 shadowValue = texture2D(shadowMap, vec2(gl_TexCoord[0]));
	gl_FragColor = shadowValue;

}

the vertex shader is actually causing my PC to crash! i run it in window mode, and it causes my screen to go blank and i have to reboot :-/

am i doing something wrong? i think i have to do something with model matrix and texture matrix?

hm…
Your shader source code seems to be correct. I think there’s a problem with your OpenGL commands.

You probably want to do a projective texture lookup:

vec4 shadowValue = texture2DProj(shadowMap, gl_TexCoord[0]));

the actual line causing the problem is:

gl_TexCoord[0] = gl_TextureMatrix[0] * gl_Vertex;

is this line correct btw?
yeah i have temporarily used a texture2D sample instead of proj. sample just to see if that was possibly the problem

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