If anyone is following this thread, here''s a link that might be of use: link.
A couple of questions, still:
1. Well, this is not a question really, but a suspicion.
I think you''ve got the r and q equations swapped in the identity matrix.
2.
gluPerspective(45.0f, (GLfloat)width / (GLfloat)height, 0.1f, 100.0f);
Does width / height represent the previous window aspect ratio (eg if previously the window was 800x600, this value would be 4/3)?
3.
glTranslatef(.5f, .5f, 0);
glScalef(.5f, .5f, 1.f);
These lines make almost perfect sense, but map the texture so that it is tiled and the tiles are really small (while the quad is 1024x1024, the tiles seem to be just 2 or 4 units in either dimension). The texture seems to be facing the right way and looks generally ok close up. Passing 1/1024.0f seems to fix the scaling problem, but the texture is now warped. Why do I want to "map the texture coordinates to [-1,+1]x[-1,+1] range. instead of the [0,1]x[0,1] range."? Is it because of the matrix mode that I have to scale the texture on x and y axis instead of x and z? I must admit reading the article and your code along with RipTorn''s drawing are slowly starting to paint a picture in my head. I just regret being so slow :/.
4.
One thing''s been bothering me for a while now. It''s something that RipTorn said: "this is where you render the water... preferably as a mesh, so there are a decent number of verticies to generate tex coords off of (NOT as one gigantic huge quad!)..". Why not as one large quad - I mean, that''s what I''m doing right now...
Gotta get some sleep now - it''s been a looong day...
PS: I gotta buy you guys a beer or something - it''s been long since anyone''s had so much patience with me... :/
Crispy
reflections
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
also, have a look here:
http://realtimecg.gamedev-pt.net/tutorials/projective_texturing.rar
quote:
4.
One thing's been bothering me for a while now. It's something that RipTorn said: "this is where you render the water... preferably as a mesh, so there are a decent number of verticies to generate tex coords off of (NOT as one gigantic huge quad!)..". Why not as one large quad - I mean, that's what I'm doing right now...
well, because tex coord gen will generate the texture coords at ever vertex.... and interpolate the results... It's the same for depth values... If you use a mesh, it will simply increase the accuracy of the generated coordinates, and the depth values (the classic sign of this is when the water is jittering up and down 5 pixels, or such..)
btw. when I did the water undulations in my old demo, the way I did that was to let tex gen generate the STR coords, and I'd generate the Q coord... Usually the Q coord was just 1, so I fudged it with a sin pattern... which gave the undulating effect.. (note though, if you do this, the further away from the plane and the origin you are, the greater this effect is visually, so you have to scale it back linearly)
| - Project-X - my mega project.. big things comming soon - | - adDeath - an ad blocker I made - | - email me - |
[edited by - RipTorn on November 28, 2002 5:48:42 AM]
quote:
1. I think you''ve got the r and q equations swapped in the identity matrix.
No I don''t think so. S is the first coordinate, T is the second, R the third and Q the fourth (the homogeneous coordinate).
What makes you think there''s a swap ?
quote:
2. gluPerspective(45.0f, (GLfloat)width / (GLfloat)height, 0.1f, 100.0f);
Does width / height represent the previous window aspect ratio (eg if previously the window was 800x600, this value would be 4/3)?
Yes, exactly.
quote:
3.
glTranslatef(.5f, .5f, 0);
glScalef(.5f, .5f, 1.f);
.../...
Why do I want to "map the texture coordinates to [-1,+1]x[-1,+1] range. instead of the [0,1]x[0,1] range."?
Because mapping [-1,+1]x[-1,+1] means that the center of the texture is [0,0], which makes computations easier (especially scales).
Passing 1/1024.f should *not* help *unless* you''re using texture rectangles (thanks to the NV_texture_rectangle extension). You don''t use texture rectangles, do you ?
quote:
Original post by vincoof
What makes you think there''s a swap ?
Here''s why - I tried to take all of the screenshots from the same viewpoint (it seems something''s up with the blue channel in my bmp dumper (probably just outputting rgb instead of bgr)):
1) The identity matrix is built as you suggested (and as I understant it should be) - strq

2) This one''s with the r and q coords swapped:

3) This is the same as the last one, only camera is "more parallel" to the water surface:

These shots are taken with tex coords mapped as vincoof showed (scaled and translated by .5) - the second one seems to be ok, just scaled down tremendously; I can''t figure out why the third one''s stretched as it is and the first one seems to be mapping the tex coords wrong.
And no, I''m not using NV_texture_rectangle - I don''t even know what texture rectangles are really.
If I can''t scale the texture up by passing stuff like 1/1024 to glScale(), then how can I do it?
RipTorn - is what you have in mind, that I should draw a grid of quads instead of the one giant one?
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
May I take a look at your (new) source code please ?
Also could you post the lines of code where you set your GL_PROJECTION matrix ?
Also, if you''re capturing a 1024x1024 texture, you have to make sure that the window is at least 1024x1024 otherwise exceeding pixels will be clamped.
For instance, if you have a 640x480 window and you''re rendering to a 512x512 texture, the texture will only get 512x480 pixels with glCopyTexImage2D or glCopyTexSubImage2D.
And yes RipTorn asks you to tesselate your geometry. It''s better there.
Also could you post the lines of code where you set your GL_PROJECTION matrix ?
Also, if you''re capturing a 1024x1024 texture, you have to make sure that the window is at least 1024x1024 otherwise exceeding pixels will be clamped.
For instance, if you have a 640x480 window and you''re rendering to a 512x512 texture, the texture will only get 512x480 pixels with glCopyTexImage2D or glCopyTexSubImage2D.
And yes RipTorn asks you to tesselate your geometry. It''s better there.
quote:
Original post by vincoof
May I take a look at your (new) source code please ?
Also could you post the lines of code where you set your GL_PROJECTION matrix ?
The executable and source are here. Here's the piece of code where I set up the projection matrix (in the window class) - everything to it is pretty straightforward... pWidth x pHeight == 800 x 600 in this case (always), fov is 45, near plane is at .1 and far plane 10000.
glViewport(0, 0, pWidth, pHeight); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(FieldOfView, (GLfloat)pWidth / (GLfloat)pHeight, NearPlane, DrawDistance); glMatrixMode(GL_MODELVIEW); glLoadIdentity();
quote:
Also, if you're capturing a 1024x1024 texture, you have to make sure that the window is at least 1024x1024 otherwise exceeding pixels will be clamped.
I'm capturing a 512x512 image while the viewport is set to 512x512. or do you mean that the physical window size has to change?!?
quote:
And yes RipTorn asks you to tesselate your geometry. It's better there.
Would the texture (which isn't quite mapped properly currently) be mapped properly then at all.
Note: I hope you have at least a gf class card - the fps on my comp (tnt2) is around 10 since I'm doing no culling or anything.
Crispy
edit: linux servers are case sensitive :
[edited by - crispy on November 28, 2002 2:49:30 PM]
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
quote:
I''m capturing a 512x512 image while the viewport is set to 512x512. or do you mean that the physical window size has to change?!?
I mean that when the physical window is resized, you should make sure that the size is at least as big as the texture being captured for the reflection.
quote:
Would the texture (which isn''t quite mapped properly currently) be mapped properly then at all.
Not sure it would be enough to make it working now, but it would help sooner or later.
Thanks for the code I''ll take a look at it right now
Isn''t it working right now ? The executable I downloaded is almost good (except the fact that there''s a slight offset for your reflected terrain) but the texture mapping is fine for me.
could you take a screenshot with Ctrl+S - this is very weird.
Crispy
Crispy
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
could you also tell me your sys params - cpu and gfx card - i''d be especially excited if the thing ran on an ati card - no one i know has one. if you have an nvidia chipset - could you also tell me the driver version you''re running. i''m using some old ones (detonator) because they have refresh rate fix.
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement