Jump to content
  • Advertisement
Sign in to follow this  
skow

Help projecting a reflected texture (distorting)

This topic is 5215 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’m rendering my scene to a texture that I then want to project to a flat plane. I’m thinking I want to draw a plane at the water level to the 2 side and back and front of the frustum. Is this how I should do this? Next comes the actual projecting part. I was doing it like :
    glMatrixMode(GL_TEXTURE);
    glLoadIdentity();
	glPushMatrix();
    glTranslatef(0.5, 0.5, 0.0);
    glScalef(0.05, 0.05, 1.0);

	gluLookAt(nCamera.pos.x, nCamera.pos.y, nCamera.pos.z, nCamera.view.x, -3, nCamera.view.z, 
		nCamera.up.x, nCamera.up.y, nCamera.up.z);	
    glMatrixMode(GL_MODELVIEW);
But I am not sure how to adjust the scale so it using gluLookAt() so the texture is fits perfect. I found an old Yann post with this, but when I did that the entire plane was colored a solid color.
	glMatrixMode(GL_TEXTURE);
	glLoadIdentity();
	glPushMatrix();
	glScalef(0.5f, 0.5f, 1.0f);
	glTranslatef(1.0f, 1.0f, 0.0f);

	glMultMatrixf(camPointer->projMatrix);
	glMultMatrixf(camPointer->modelMatrix);

	// OK, the matrix is set, get back to modelview

	glMatrixMode(GL_MODELVIEW);
Any help is greatly appreciated. [Edited by - skow on August 27, 2004 7:49:52 PM]

Share this post


Link to post
Share on other sites
Advertisement
I wrote a small class called "Reflection Matrix And Render To Texture In OpenGL". Check out the code on my home page.

Share this post


Link to post
Share on other sites
Quote:
Original post by skow
I'm getting a "The page cannot be displayed"


Thanks for pointing that out, I will try and find the error and fix it.

Share this post


Link to post
Share on other sites
Cool it works now, that reflection matrix is nice to have.

Got it basicly working, now I need to try and distort the text cords, hopfully this will go smoothly.

Share this post


Link to post
Share on other sites
Hmm I'm getting this flaw when I distort the texture cords.



As you can see at the edges, the texture is distorted and leaves gaps. I really can't think of what I can do to to solve this problem other than fidning out where verts are near the edge of the screem and not distorting them (doesn't seem like a good solution).

Any suggestions?

Share this post


Link to post
Share on other sites
How did you distorted the texture coords ?
As far as i know, we cannot change them when texgen is enabled

Share this post


Link to post
Share on other sites
I'm passing in 3d cords for the projection matrix, and I'm simply adding sin(x)+cos(z) to the y component and sin(x) to x component and cos(z) to the z component. This isn't the final way I'll be distoring but the problem is taht distorting them at the edge will case the texture near the edges to extend past the 1.0, 0.0 marks causing those ugly things you see in the screenshot.

Share this post


Link to post
Share on other sites
There are couple of ways around it if you can use vertex programs. But I don't know how this can be solved using fixed function pipeline.

Share this post


Link to post
Share on other sites
Dark would I not have the same problem using a vertex shader? It would be faster but the same translation of 3d text cords would yeild the same result, would it not?

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!