Skip to main content
GameDev.net gamedev.net
🔒 Locked

water reflection question

Started by mictian Mar 20, 2005 at 10:58 AM 1 replies 2.2k views
Original Post
mictian
mictian
Hello all, sorry to drag up this already belaboured topic again, but I have a couple questions I want to sort out before I start coding my water renderer. Basically I am wondering how reflections are done. I know I will use a normal map, and use this to offset lookups into a projected reflection and refraction texture. But my problem is how do you make the reflected image. I know you have to invert the scene around the water plane, cull away anythign below the water etc. But then the water will only be able to reflect things that appear on the screen, there might be huge cliffs right in front of me, but if I am only looking at the water there will be no reflection... Therefore how do you position the camera / projector for doing water. Furthermore , say that there is nothign to reflect in certain areas, so the reflection map is black...for these pixels of the water do I make a cubemap lookup or something (water colored black would be weird). One last thing, when making the refraction map I assume I just raise the terrain a little (to simulate the refraction effect) then cull away everythign above the water plane and use that...right? Peace, Rob
¿We Create World?
Jason Z
Jason Z
It sounds like you have the basics down, and I bet once you get it all implemented that your questions will answer themselves. Even so, I'll give it a shot:

Quote:
I know you have to invert the scene around the water plane, cull away anythign below the water etc. But then the water will only be able to reflect things that appear on the screen, there might be huge cliffs right in front of me, but if I am only looking at the water there will be no reflection...


Think of the reflecting plane as reflecting the view frustum as well. So when you invert the scene (looking down at water) you are really just mirroring the frustum (frustum starts pointing downward, gets mirrored upward). With this thought in mind, then anything that is in the altered frustum will get drawn. So you have really two choices:

1) Draw everything in your world into the reflection buffer and let the hardware clipping figure out what is in the view.
2) Perform a query into your object system for objects that are in the new frustum and render them into your reflection buffer.

Quote:
Therefore how do you position the camera / projector for doing water. Furthermore , say that there is nothign to reflect in certain areas, so the reflection map is black...for these pixels of the water do I make a cubemap lookup or something (water colored black would be weird).


If there is anyplace in the world that would reflect black because nothing is there, then in normal viewing there would also be nothing there (i.e. a hole in the world). This is not likely to happen if you have a skybox or something similar - but the black hole problem should not happen if it is not already happening in normal rendering :)

Hope this helps, if not just post again.


Which one depends on the size and number of objects that you are rendering.
Jason Zink :: DirectX MVP   Direct3D 11 engine on CodePlex: Hieroglyph 3 Direct3D Books: 

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.