dynamic environment mapping

orange144
Unregistered
 
Post: #1
Hi all,

I'm working on a project on ocean simulation, and I need to reflect the sky on the water to achieve a decent look.

The point is that with "normal" environment mapping, you need to re-generate the environment texture everytime the camera moves, since the front texture, for example, is no longer in front of the camera. (Am I clear?)
But it seems to me a waste of CPU to regenerate 6 views (in case of cubemapping) since I only want to reflect the sky.
So I need an advice: should I calculate the texCoords by myself instead of relying on openGL to do this, or would you recommend me to modify the env textures each frame?

Thanks.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
Sounds like you could just use the texture matrix to rotate the cube map...
Quote this message in a reply
tod_baudais
Unregistered
 
Post: #3
To just reflect the sky, assuming it doesn't change, you shouldn't have to update the cube map every frame. You'd only have to update it if you were reflecting objects - say and island when the view position changes.

You can check out my "island in water" movie at http://homepage.mac.com/tod_baudais/ in the downloads section. Since I'm running it on an old G4 450, it's kinda choppy.

Tod.
Quote this message in a reply
orange144
Unregistered
 
Post: #4
OneSadCookie Wrote:Sounds like you could just use the texture matrix to rotate the cube map...

I managed to do this just on time to read your post. (Well, this wasn't very hard anyway)
Thanks very much guys for the quick answers.

The video is cool, Tod, thanks. I guess that you've been having the same problem as I do: whenever you look at "far" sea, you can hardly notice the waves because it's too flat, so it just looks like a shiny plate. I have considered solutions to visually enhance the crest of each wave (by coloring it whiter when the normal is close to vertical and height > 0), but I don't seem to find a good, general solution. Does anyone think of a good solution to eventually see the sines and waves ?

By the way, your video makes me think of another point (this one may be a silly question but I'm not confident enough with openGL yet...)
Once I've got my sky texture reflected on the sea, what's the best way to actually display that sky? draw a cube *far* from camera with textures mapped on? or is there an even more openGL-ish way? (Some time ago, I had to work in VRML where a world texture environment means just that... I'm a bit confused...)
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #5
Don't most games just draw the skybox first, enable the depth buffer and then draw the world?

I've actually got my own perhaps silly question. I've been tinkering around with a similar thing. How are you passing the normals? I tinkered around with the NewWave GLUT demo to make it tileable. I was just going to render the final image to a texture, and texture the water with the pre-enviroment mapped texture. Seeing the island movie makes me wonder how you are calculating and passing all the water data? Especially on a fairly dated G4.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Member
Posts: 64
Joined: 2005.06
Post: #6
I know some games put the entirety of the map inside a huge cube or sphere (which works as the sky, ground if you have a cliff (think of what Halo does), and allows you to easily change times a day (just by switching or moving textures).
Quote this message in a reply
tod_baudais
Unregistered
 
Post: #7
Glad you guys liked the movie.

The sky is a simple skybox large enough so that it doesn't get clipped to the view frustum. It is drawn with its center at the camera location and with glDepthMask(GL_FALSE). I have a separate cube map containing a lower res version of the sky for reflections - the video showed it updating dynamically but you don't have to do that.

The water is a static mesh distorted by a vertex program plus a bump map for the smaller ripples. Do a search on the ATI dev site for ocean water - they have a dx sample that I used as a guide along with a few tweaks of my own. Both normals and tangent vectors are calculated in the vertex program. So pretty much all of the processing is offloaded to the video card... that's why it runs nicely on my lowly G4. It's the updating of the cube maps that makes it crap out Sad

I haven't looked into enhancing waves that are far away - I haven't seen it as a problem yet.

Tod.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Environment Background With OpenGL spinner 14 10,107 Oct 19, 2006 06:38 AM
Last Post: ThemsAllTook
  Environment mapping MACnus 6 3,805 Jul 13, 2005 08:43 AM
Last Post: MACnus
  Character Environment Collision Detection NYGhost 1 2,567 Sep 30, 2003 09:05 AM
Last Post: MacFiend
  Cube Environment PowerMacX 3 3,013 Aug 7, 2003 09:36 PM
Last Post: MattDiamond