🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Some environment mapping thoughts

posted in Cypher's Journal
Published August 03, 2005
Advertisement
So right now in my demo I've got some fairly nice perpixel Blinn lighting going on, and some additional effects like Fresnel to modify the specular coefficient. However, as I observe the real world more and more, I've noticed the huge significance environment mapping can have. I recently decided to dynamic env maps to my todo list, and they were absent from it since the very beginning.

Anyways, here're some thoughts I have on the possible implementations I'm considering:

1) Have per-object env mapping. Obviously, this will produce the best results, but at a fairly high cost. Also, the easiest to do.
2) Have an env map made at the camera's location. A nice approximation, but I think I'll have flags for Renderable objects that can choose between this option or #2.
3) Have an env map solution similar to Half Life 2's, where areas in the environment already have them, and objects inside a certain environment map's bounding box will just use that. Despite the fact that I'm going for fairly high quality reflections, I think HL2's implementation could be fairly good...but not in its current state.

The big flaw behind HL2's system is shown below:
Image hosted by Photobucket.com
The black square is the env map bounding box, the red circle being some reflective object, the green thing being the camera, the green line being a camera->position vector, the blue arrow being the reflection vector (aside: Just so I can keep reflective consistency, I think I'll use the halfway vector as the reflection vector). What I show in this image is that the right reflection vector is generated, and is then basically placed onto the center of the env map BB (that pink dot), at which point the cubemap is just normally looked up. Obviously, this creates a large inconsistency with the object's position and the environment, and is quite evident in some parts of Half Life 2 (good example: Start up the beginning of the game, and play through until right before you enter Barney's interrogation room. In the hallway immediately prior, watch the reflection on the ground. It's supposed to be primarily the overhanging light, but as you get near the end of the hall, the reflection should instead be the backwall but it's STILL reflecting the light!). When I get around to implementing this, one thing I want to experiment with is to find the proper vector required for that area. That is, take into account the position of the pixel/object inside the env map BB, and find what the correct reflection vector should be.

So, those are three options that I'm considering. One that seems fairly appealing is HL2's method with the changes I suggested above. I would also make the env map fully dynamic, because I want to take advantage of skewbe mapping (it's not just for shadows, it's an extension of EVERY kind of cube map!) and also see how dynamic lighting (possibly dynamic shadows too? Oooh man that'd look cool, even if it would be a slideshow) affects the map as well.

One thing to note about the env map lighting/shadowing: Because I'd use skewbe mapping, just like with omni shadows I could take advantage of a fairly low resolution environment map. Like, omni shadows I feel require a 512x512 bare minimum, but an env map could very likely dip down into the 256x256 range and still look very good, before applying scaling due to reduction of the envmap BB in screenspace.

Any comments?
0 likes 2 comments

Comments

superpig
There was an article in GPU Gems 2 about using off-centered cube maps that I think you'll want to read.
August 06, 2005 04:06 AM
Cypher19
Dammit, another reason to get that book!
August 09, 2005 12:34 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement