Advertisement

reflections

Started by November 22, 2002 10:08 AM
83 comments, last by Crispy 22 years, 2 months ago
For modelview or texture?
For modelview.
Advertisement
Hey, I''m trying to do the same thing as Crispy. I''m using Direct3D8 but I can manage

I got everything working, even the projection. (I even took the time to but an environment bump map The texture is mapped on the screen perfectly (most of the time, as you''ll see).

There is still a simple problem though. Whenever I get close to the water plane, the projection "zooms out" a bit, and I see the texture tiling around the screen.

When I''ll get home, I''ll post screen shots.

Sorry I can''t really help you Crispy. I wrote hoping you''d share your learning experience with me.


----------------
Blaster
Computer game programmer and part time human being
Strategy First - http://www.strategyfirst.com
BlasterSoft - http://www.blastersoft.com
finally - it''s been a killer weekend - work-, school- and partywise... back to the topic now:

oh yay - it works at least on some ati cards - that''s something. unfortunate for radeon (and other ati card) owners i''m an nvidia proponent and won''t go into the extra trouble it takes to get something work unless some really good solution presents itself to me (such as somebody buying me an ati card )... an unfortuante thing, indeed is the fact that on my tnt2 the thing looks like a bent chess table - i even tried the latest drivers, but then i had it tried out on a regular tnt and it was all messed up there, too - guess the fault''s in the architecture or something.

as for vincoof''s remark about the clip plane - i guess there''s no way around that.

i don''t think i''m going to let this thread die yet however - it would be double nice if i got the stencil code working as well - not sure how much i will/won''t understand yet. as stated, i''ve been really busy doing some work stuff which is piling 8|

one relevant question, however - if wanted to cull (which i do) the reflected image properly, what would be the easiest way to tweak the frustum to match it. a simple matrix reflection over the water surface won''t do - rotation along x and z planes would help but i have no idea as to how much...

quote:
Original post by Blaster
Sorry I can''t really help you Crispy. I wrote hoping you''d share your learning experience with me.



np as for your problem with the zooming - beats me - afaiu it shouldn''t do that. you could run the thing on another computer to see what effects you''ll get there...

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
I have a GeForce4 Ti 4200 at home, and a GeForce 3 Ti 500 at work. Same drivers (latest) on both computers.

Using the same exe, I get different results on the two computers. At home it works fine, but on the GeForce3 the reflection is tiled just like in the screenshot you provided.

I don't have a screenshot of the tiling, but here is a screenshot that looks good.
http://www.blastersoft.com/images/3ddemo/Screenshots/5.jpg

Here is a composition of a camera movement, showing how the projection is deformed when near the water planer (the reflection is replaced by a dummy texture).
http://www.blastersoft.com/images/3ddemo/Screenshots/6_dev.jpg

Edit : links

----------------
Blaster
Computer game programmer and part time human being
Strategy First - http://www.strategyfirst.com
BlasterSoft - http://www.blastersoft.com

[edited by - Blaster on December 2, 2002 9:04:32 PM]
Still getting a white texture. I think it is because im trying to draw something with textures and i changed the viewport. How do i fix this?
Advertisement
Crispy: I''ve tried the prgram on a GeForce (NVIDIA obviously) and it works. I guess you''re experiencing a driver bug with TNT cards.
I''m sorry but I don''t understand what you do mean by "cull". Do you mean "clip reflections with the water surface" ?


Matrix: here''s a list of short things you should check/try (in order) :
- is your ''Dimen'' value a power-of-two ? Is it "big" (1024 or greater) ?
- how did you get the ''reflexture'' id ? Did you catch it with glGenTextures ?
- use GL_REPEAT instead of GL_CLAMP. If texture coordinates exceed the [0,1] range, they won''t be clamped.
- please don''t clear the viewport after rendering to the small viewport, and instead flush the viewport to your screen in order to be sure that the reflected scene is really rendered into this small viewport.
- try to upload your texture with something else than glCopyTexSubImage2D because maybe there''s a driver bug (btw what''s your graphics card / driver combo ?). First try to upload your texture with some other data (data that you''ve already loaded to OpenGL in order to be sure this data is correct, loaded from disk for instance) and see if the texture still appears white. If white, then there''s a texture parametrization problem, not texture uploading. If not white, then the upload is the problem, and you should try with glCopyTexImage2D instead (I wrote the line near the glCopyTexSubImage2D in my code) :
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, Dimen, Dimen, 0);
quote:
Original post by vincoof
I'm sorry but I don't understand what you do mean by "cull". Do you mean "clip reflections with the water surface" ?



Heh. No, I mean simple frustum culling to eliminate a whole bunch of polys when drawing the reflections - should speed things up a lot. The fustum, by default, is always "facing the right way" - hence it produces the following effect (red areas are not drawn):



I'd provide actual screenshots, but as mentioned, it doesn't work on my tnt2 the way it shoud - hence the mock-up in MS Paint...

Crispy


edit: quotemarks


[edited by - crispy on December 3, 2002 11:30:04 AM]
"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
If you perform your own culling, all you have to do is computing the position of the mirrored camera center and its mirrored frustum. Since I don't know how you represented your culling into your software, I obviously can't tell you more of how you would implement it !
That's a good thing that you found yourself that culling to the frustum needs a special case for reflections btw

[edited by - vincoof on December 3, 2002 1:35:15 PM]
I''m using a modified version of Mark Morley''s frustum tutorial. Too lazy to look up the link just now - basically it''s a simple matrix derived from the modelview and projection matrices through the clip matrix.

quote:
Original post by vincoof
If you perform your own culling, all you have to do is computing the position of the mirrored camera center and its mirrored frustum. Since I don''t know how you represented your culling into your software, I obviously can''t tell you more of how you would implement it !


Here''s why I see that won''t work:

1) I need to know relative to which point I need to reflect the frustum matrix - one guess would be the reflective plane, but...
2) won''t that also flip the up-vector of the frustum (?), which would mean that:
3) I get the same picture of the world as I would from the normal frustum viewpoint, only the terrain I''d be seeing is the reflected one from below - everything else remains the same, which in turn would mean that the reflection that is finally mapped on the water is taken from above whereas it should be taken from below (as reflections traditionally are )...

Anyway - that''s what my head tells me. Other than that - I spent quite a few hours searching the Web for an authentic matrix reflection formula. Is this authentic?

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

This topic is closed to new replies.

Advertisement