Jump to content
  • Advertisement
Sign in to follow this  
soconne

TexGeni not working with GSL ??

This topic is 4819 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 have the following code that transforms the texture matrix.
        static float planeS[4] = { 1.0f, 0.0f, 0.0f, 0.0f };
        static float planeT[4] = { 0.0f, 1.0f, 0.0f, 0.0f };
        static float planeR[4] = { 0.0f, 0.0f, 1.0f, 0.0f };
        static float planeQ[4] = { 0.0f, 0.0f, 0.0f, 1.0f };

        static float matProj[16];
        static float matModel[16];
        static float biasMatrix[16] = { 0.5f, 0.0f, 0.0f, 0.0f,
                                        0.0f, 0.5f, 0.0f, 0.0f,
                                        0.0f, 0.0f, 0.5f, 0.0f,
                                        0.5f, 0.5f, 0.5f, 1.0f };
		
        glPushAttrib(GL_ENABLE_BIT);

        glEnable(GL_TEXTURE_2D);
        glBindTexture(GL_TEXTURE_2D,textureID);

        glTexGeni(GL_S,GL_TEXTURE_GEN_MODE,GL_EYE_LINEAR);
        glTexGeni(GL_T,GL_TEXTURE_GEN_MODE,GL_EYE_LINEAR);
        glTexGeni(GL_R,GL_TEXTURE_GEN_MODE,GL_EYE_LINEAR);
        glTexGeni(GL_Q,GL_TEXTURE_GEN_MODE,GL_EYE_LINEAR);

        glTexGenfv(GL_S,GL_EYE_PLANE,planeS);
        glTexGenfv(GL_T,GL_EYE_PLANE,planeT);
        glTexGenfv(GL_R,GL_EYE_PLANE,planeR);
        glTexGenfv(GL_Q,GL_EYE_PLANE,planeQ);

        glEnable(GL_TEXTURE_GEN_S);
        glEnable(GL_TEXTURE_GEN_T);
        glEnable(GL_TEXTURE_GEN_R);
        glEnable(GL_TEXTURE_GEN_Q);

        glGetFloatv(GL_PROJECTION_MATRIX,matProj);
        glGetFloatv(GL_MODELVIEW_MATRIX,matModel);

        glMatrixMode(GL_TEXTURE);
        glPushMatrix();
        glMultMatrixf(biasMatrix);
        glMultMatrixf(matProj);
        glMultMatrixf(matModel);
        glMatrixMode(GL_MODELVIEW);


This is basically for setting up the texture matrices to correctly project a reflected scene onto a water plane. It all works just fine, but I tried to then create a pixel and vertex shader in GSL and all of the texture transformations went away and I did not get the correct result. Here are my vertex and texture shaders.
// VERTEX SHADER  
void main()
{			
	// get texture unit 0 coords
	gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
	
	// get vertex position
	gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;
}

// FRAGMENT SHADER

uniform sampler2D reflection;

void main()
{
	vec4 color_reflection 	= texture2D(reflection, gl_TexCoord[0].st);

	gl_FragColor = color_reflection;
}


Here are the results I get before using a pixel shader and after. Does anybody know what is wrong with my pixel shader or vertex shader ?

Share this post


Link to post
Share on other sites
Advertisement
I converted this code from CG and I had no problems with this at all. I did not have to manually do anything to the texture coordinates with CG.

But with this program I just disabled the vertex shader and only bound the fragment shader. Here is the result.



Any ideas ?

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!