Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

Some environment mapping thoughts

Sign in to follow this  


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?
Sign in to follow this  


Recommended Comments

There was an article in GPU Gems 2 about using off-centered cube maps that I think you'll want to read.

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!