Sign in to follow this  
BlackBox

Environment Mapping - top end.

Recommended Posts

BlackBox    150
I'm planning to learn environment mapping, but I just google it and I got many different ways of doing it: Cube maps, spherical coordinates, etc. So... I was wondering what method(algorithm) is used in todays top-end video cards to do environment mapping? Thanks a lot. ps. Any link will put a big smile in my face :)

Share this post


Link to post
Share on other sites
Yann L    1802
Cubemaps, dual paraboloid maps, spherical maps - they're all using the same principle, just different encodings.

The easiest, most widely used, and best in terms of visual quality, is cubemapping.

PS: oh yeah, the link [wink]

Share this post


Link to post
Share on other sites
BlackBox    150
Quote:
Original post by Yann L
Cubemaps, dual paraboloid maps, spherical maps - they're all using the same principle, just different encodings.

The easiest, most widely used, and best in terms of visual quality, is cubemapping.

PS: oh yeah, the link [wink]


Great Thanks a lot.

WOW, I know this forum is fast, but 5 minutes for an answer! WOW.

Thanks again `Yann L`.

I'll just get working hahah.

BTW, Yes, Im smiling now.


PS> any other link or comment is welcome.

:)

Share this post


Link to post
Share on other sites
Yann L    1802
Quote:
Original post by AxoDosS
Cube maps are great for static environments but I would suggest dual paraboloid maps if you plan to have real-time reflections of the surrounding, for the simple fact that they need less rendering passes.

I would actually not suggest dual paraboloid maps for dynamic reflections. Although cubemaps require six faces to be updated, straight world lines stay straight lines within the cube projection. DP maps, however, will transform your environment into a paraboloid coordinate system, where straight lines become curved. The problem with that is, that your scene/level needs to be highly tesselated (ie. needs to have a lot of redundant faces) in order to avoid serious visual artifacts. This problem does not exist with cubemaps.

DP maps used to be the only possible way to do shadowmapping on point lights, before the availability of pixel shaders. Now, even for this special application, cubemaps are to be preferred over DP maps.

Share this post


Link to post
Share on other sites
Jimfing    148
Sorry to high-jack the thread - but I just wanted to ask Yann L a question about using cubemaps for shadowmaps on pointlights:

Are you saying that cubemaps are better than DP maps for this case, even though you have to do 3 times the work? Is performance not a problem here?

Thanks!

Share this post


Link to post
Share on other sites
AxoDosS    284
Quote:
Original post by Yann L
I would actually not suggest dual paraboloid maps for dynamic reflections. Although cubemaps require six faces to be updated, straight world lines stay straight lines within the cube projection. DP maps, however, will transform your environment into a paraboloid coordinate system, where straight lines become curved. The problem with that is, that your scene/level needs to be highly tesselated (ie. needs to have a lot of redundant faces) in order to avoid serious visual artifacts. This problem does not exist with cubemaps.


You are correct about the scene need to be highly tesselated but could I not get away with it for some special cases maybe like for example I would have a model of a monster or something in the scene. The monster model is probably tesselated to the extent that it would look ok on the DP map? Besides my monster model would probably not cover such a large portion of the DP map for a person to notice the errors?

Share this post


Link to post
Share on other sites
Yann L    1802
Quote:
Original post by Jimfing
Are you saying that cubemaps are better than DP maps for this case, even though you have to do 3 times the work? Is performance not a problem here?

It depends on your scene and how often you update the maps, obviously. Cubemaps are better in terms of quality. Of course, they require 6 sides to be updated, if your object (environment mapping) or lightsource (shadowmapping) moves. OTOH, generating a shadowmap cubemap is very lightweight on fillrate, ie. you can disable everything except the fragment depth.

Here is a short DP vs. cubemap list, generally valid for both reflective environment mapping and shadowmapping:

Cubemaps:
* directly supported by the hardware, uses only one single texture unit
* Fast and euclidean projection (ie. straight lines stay straight, no visual artifacts)
* Continuous sampling space (ie. all regions are sampled at approximately the same resolution)
* No overlapping regions or connective seams (such as with DP maps), no additional separation logic required
* much easier to implement than DP maps

DP maps:
* only two maps to update, instead of six
* take slightly less memory than a cubemap of the same quality
* works on hardware without native cubemap support

Quote:

You are correct about the scene need to be highly tesselated but could I not get away with it for some special cases maybe like for example I would have a model of a monster or something in the scene.

Well, sure, if your environment is highly tesselated anyway, then they're OK. But be careful with your monster example: not the reflective object needs high tesselation, but the reflected object(s). In this case, as well as in the case of shadowmapping, that would be the entire scene or level.

Share this post


Link to post
Share on other sites
BlackBox    150
Well its me again. :)

Let see, so the best way to go is using cube maps. Right?
Now, I know its posible to load cube maps to the fragment shader, but what next?
For example in GLSL I have the function:
textureCube(samplerCube sampler, vec3 coord);
But what should I use for the 3D Coord vector (==vec3 coord)?

Thanks.

Share this post


Link to post
Share on other sites
Paul7    174
Quote:
But what should I use for the 3D Coord vector (==vec3 coord)?


Use the reflection vector. In HLSL this is calculated as reflect(ViewToPos, Normal); not sure if theres a similar function in GLSL.

Theres a tutorial for doing it in HLSL in the DirectX SDK which is also available here. Theres also this page too decribing the technique, its on the same site but just in case you miss it. The principles will be the same for GLSL.

Share this post


Link to post
Share on other sites
BlackBox    150
Quote:
Original post by Paul7
Quote:
But what should I use for the 3D Coord vector (==vec3 coord)?


Use the reflection vector. In HLSL this is calculated as reflect(ViewToPos, Normal); not sure if theres a similar function in GLSL.

Theres a tutorial for doing it in HLSL in the DirectX SDK which is also available here. Theres also this page too decribing the technique, its on the same site but just in case you miss it. The principles will be the same for GLSL.


Yes there is one! Yey. :)
reflect(I,N) >> result = i - 2 * dot(N, I) * N;

Ill try to implment this and surely return with more questions :)

BTW. The links are great! Thanks.

Share this post


Link to post
Share on other sites

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

Sign in to follow this