Help projecting a reflected texture (distorting)

Started by
17 comments, last by toucel 19 years, 7 months ago
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]
Advertisement
I wrote a small class called "Reflection Matrix And Render To Texture In OpenGL". Check out the code on my home page.
I'm getting a "The page cannot be displayed"
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.
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.
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?
How did you distorted the texture coords ?
As far as i know, we cannot change them when texgen is enabled
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.
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.
You should never let your fears become the boundaries of your dreams.
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?

This topic is closed to new replies.

Advertisement