Jump to content
  • Advertisement
Sign in to follow this  

reflection (use GLSL)solved

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

hello, i've got the my reflection work in fixed pipeline, but i met some trouble when using shader. the reflection texture is already stored in ref_tex and set to texture0.
void main(void)
gl_Position = ftransform();
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_Vertex;

uniform sampler2D tex;
void main (void)
gl_FragColor= texture2DProj(tex, gl_TexCoord[0]);


// here i got the texture matrix i've setup, right?

// get location and set uniform
shader.setUniform1i("tex", 0);

glBindTexture(GL_TEXTURE_2D, ref_tex);

// draw water plane
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0, 0);
glVertex3f(-size, 0, -size);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1, 0);
glVertex3f(-size, 0, size);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1, 1);
glVertex3f( size, 0, size);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0, 1);
glVertex3f( size, 0, -size);


fixed pipeline(use automatically generated texcoord, the reflected image is right): use shader(the image was distorted): i dunno how this could happen. any help would be appreciated. [Edited by - bybw on December 31, 2004 9:13:34 AM]

Share this post

Link to post
Share on other sites
i render the reflection scene with pbuffer, then copy the image to the texutre.
the RTT pass is right, cos i can get the correct result in fixed function pipeline. And the shader is ok, then there must be somethin' wrong in the second pass..

anyone found out some mistakes?

Share this post

Link to post
Share on other sites
ok, solved the problem :)
just made a mistake when calculating the texcoord in vs.
the projtexcoord should be Mprojtex * inPos as Yann described in his article.

[Edited by - bybw on January 1, 2005 6:02:33 AM]

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!