Jump to content
  • Advertisement
Sign in to follow this  
Eitsch

TexCoord generation in shader

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

i am trying to implement the texture coordinate generation like GL_EYE_LINEAR. the vertex shader:
void main()
{
	vec4 xEyePlane = vec4(1.0,0.0,0.0,0.0) * gl_ModelViewMatrixInverse;
	vec4 yEyePlane = vec4(0.0,1.0,0.0,0.0) * gl_ModelViewMatrixInverse;
	vec4 zEyePlane = vec4(0.0,0.0,1.0,0.0) * gl_ModelViewMatrixInverse;
	vec4 wEyePlane = vec4(0.0,0.0,0.0,1.0) * gl_ModelViewMatrixInverse;

	vec4 eyeVertex = gl_Vertex * gl_ModelViewMatrix;


	
	gl_TexCoord[0].s = xEyePlane.x * eyeVertex.x + xEyePlane.y * eyeVertex.y + xEyePlane.z * eyeVertex.z + xEyePlane.w * eyeVertex.w;
	gl_TexCoord[0].t = yEyePlane.x * eyeVertex.x + yEyePlane.y * eyeVertex.y + yEyePlane.z * eyeVertex.z + yEyePlane.w * eyeVertex.w;
	gl_TexCoord[0].r = zEyePlane.x * eyeVertex.x + zEyePlane.y * eyeVertex.y + zEyePlane.z * eyeVertex.z + zEyePlane.w * eyeVertex.w;
	gl_TexCoord[0].q = wEyePlane.x * eyeVertex.x + wEyePlane.y * eyeVertex.y + wEyePlane.z * eyeVertex.z + wEyePlane.w * eyeVertex.w;


	gl_Position = ftransform();
}
i don't get the correct results....please help /EDIT: i changed vec4 xEyePlane = vec4(1.0,0.0,0.0,0.0) * gl_ModelViewMatrixInverse; and so on with vec4 xEyePlane = gl_ModelViewMatrixInverse * vec4(1.0,0.0,0.0,0.0); [Edited by - Eitsch on March 12, 2006 7:11:50 AM]

Share this post


Link to post
Share on other sites
Advertisement
sorry i dont know how eye_linear works (itll be discussed in the red book no doubt)
btw this looks unneseccary
vec4 xEyePlane = vec4(1.0,0.0,0.0,0.0) * gl_ModelViewMatrixInverse;

also u can use gl_FragCoord.xy + the frag shader to do what eye_linear does (i believe)
eg
vec2 texcoord = gl_FragCoord.xy / 100.0;

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!