Water Reflections
by Travis Vroman · in General Discussion · 05/20/2003 (6:53 pm) · 11 replies
Has anyone thought about possibly adding water reflections to TGE? (hint, hint, Melv... you're awesome at this type of stuff). I would like to hear what you guys think.
-Barzahd
-Barzahd
#2
Thanks,
-Travis
05/24/2003 (3:31 pm)
LOL sounds like a great explanation, but I have no clue how to do ANY of that.... Maybe you could explain what some of that stuff means? Sorry, I'm new to the programming aspect of graphics... I've always been a designer...Thanks,
-Travis
#3
Sorry man, you always have to assume the knowledge of another on the forums. :)
Basically, I played with it as a demonstration for last years IGC but I never got it to a state where I'd say that it would integrate easily into the CVS although it did work.
I saw some other work going on with pixel shaders but I can't remember who it was. I'm sure they did a development snapshot.
- Melv.
05/25/2003 (1:45 am)
Travis,Sorry man, you always have to assume the knowledge of another on the forums. :)
Basically, I played with it as a demonstration for last years IGC but I never got it to a state where I'd say that it would integrate easily into the CVS although it did work.
I saw some other work going on with pixel shaders but I can't remember who it was. I'm sure they did a development snapshot.
- Melv.
#4
-Travis
05/30/2003 (6:47 pm)
ok searched all of the development screenshots - found nothing...lol. However, I was wondering if we may collaberate on this issue and maybe come up with something? I know I could learn from it, and maybe (a real BIG maybe...lol ) I could help on it.-Travis
#5
05/30/2003 (8:50 pm)
Good to see you around Melv :)
#6
@Travis: It's probably not realistic for me to say that I can do any work on this at the moment. I'm barely able to maintain a forum presence as I hard at work with 3 friends doing our game which we want finished in a few months.
- Melv.
05/31/2003 (1:11 am)
@Xavier: I'm trying to spend a little more time on the forums. :)@Travis: It's probably not realistic for me to say that I can do any work on this at the moment. I'm barely able to maintain a forum presence as I hard at work with 3 friends doing our game which we want finished in a few months.
- Melv.
#7
05/31/2003 (12:21 pm)
I don't know Melv but you rock. You have unknowingly brought me much mapping joy. Now if we could justr ADD those enhancements I could use them. Water reflection is something I'd be very happy with. I was hoping for radiosity, but apparently that's a bucket of memory waste.
#9
It certainly wouldn't be too difficult to do a scene-traversal on a stencil-water area. The trick is being able to distort the reflection according to the water surface and this is where render-to-texture comes in.
I'll definately be getting back to doing handy stuff for the community after we've done a Strategem release. To be more accurate, when I've removed any bugs that are found after a release. :)
- Melv.
10/29/2003 (9:29 am)
Unfortunately not at the moment.It certainly wouldn't be too difficult to do a scene-traversal on a stencil-water area. The trick is being able to distort the reflection according to the water surface and this is where render-to-texture comes in.
I'll definately be getting back to doing handy stuff for the community after we've done a Strategem release. To be more accurate, when I've removed any bugs that are found after a release. :)
- Melv.
#10
The easiest would be the "cheat" reflection - just use a cubemap with the skybox as the texture. That will give a distortion-free water reflection (unlike the current environment map), but it will just show the sky. Hmm, come to think of it, we should have done that for the 1.2 release and demo, prob wouldn't have been too hard.
Another couple ways have been brought up by Melv (Hi Melv!). Essentially you render the scene normally, but stenciling out the water. Then you render the scene from the point of view of the reflection. Because of the stencil buffer, this will only render to the water area. To save fill-rate and also set up pixel shader effects, you can render the reflection to a smaller texture and then blur it and distort it, bump it, etc. Then render it back in the same way using the stencil buffer. The big problem with render-to-texture is that it's a royal pain in OpenGL and I'm not even sure if it can be done without using hardware specific extentions. It's a piece of cake in D3D though ;)
In any case, the "true" reflection case is not trivial and can be pretty expensive since everything that's reflected gets drawn twice, plus all the render state changes of drawing the scene again. I'd be curious to see the performance hit of just rendering the terrain twice.
10/29/2003 (5:27 pm)
There's a few things that you can do to get some reflections going. The easiest would be the "cheat" reflection - just use a cubemap with the skybox as the texture. That will give a distortion-free water reflection (unlike the current environment map), but it will just show the sky. Hmm, come to think of it, we should have done that for the 1.2 release and demo, prob wouldn't have been too hard.
Another couple ways have been brought up by Melv (Hi Melv!). Essentially you render the scene normally, but stenciling out the water. Then you render the scene from the point of view of the reflection. Because of the stencil buffer, this will only render to the water area. To save fill-rate and also set up pixel shader effects, you can render the reflection to a smaller texture and then blur it and distort it, bump it, etc. Then render it back in the same way using the stencil buffer. The big problem with render-to-texture is that it's a royal pain in OpenGL and I'm not even sure if it can be done without using hardware specific extentions. It's a piece of cake in D3D though ;)
In any case, the "true" reflection case is not trivial and can be pretty expensive since everything that's reflected gets drawn twice, plus all the render state changes of drawing the scene again. I'd be curious to see the performance hit of just rendering the terrain twice.
#11
"I'd be curious to see the performance hit of just rendering the terrain twice."
I think its a question of an intelligent poligon, and surface cutter subsystem on the reflected terrains and-or other objects.
Anyway i think your tricky waz with cube env on water could be a good starting point, and for an initial release of the "project water reflection" ;)
ps : im ready to serve this project with any graphical needs if necessary. :)
10/30/2003 (3:09 am)
Brian"I'd be curious to see the performance hit of just rendering the terrain twice."
I think its a question of an intelligent poligon, and surface cutter subsystem on the reflected terrains and-or other objects.
Anyway i think your tricky waz with cube env on water could be a good starting point, and for an initial release of the "project water reflection" ;)
ps : im ready to serve this project with any graphical needs if necessary. :)
Associate Melv May
I have and did but I never got back to the code after the IGC. My intention was to get it working as a cool presentation then but I never finished it. I think I've got some screenshots somewhere that I could possibly post up.
Without using programmable hardware you've got a couple choices depending on the effect you desire. If you want a straight reflection, much like a mirror, with the surface textured over it then you can set this up using various techniques such as making a modified version of the new mirrorSubObject that Brian Rammage got working and stencil the reflection in prior to surface texturing.
When I did it, I wanted the reflection to distort with the surface and so I employed a render to texture call so that the scene could be distorted during the subsequent texturing. Unfortunately, this is an nVidia extension but I was only playing anyway. As part of the post multi-texturing of the surface, you can then do a DOT3 using a tessellated normal-map. You can also do a sun-specular pass by attenuating the sun/surface vector.
- Melv.