• Advertisement
Sign in to follow this  

Box Projected Cubemap Environment Mapping

This topic is 1900 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
That is really really pretty.

I cant wait to get home and check out the demo to see what kind of performance it gives

Share this post


Link to post
Share on other sites
Cool - I'm definitely interested in the details.

I'm guessing that it involves taking the position that the cube-map was rendered from into account when sampling it?

[EDIT]
To get your demo to run I had to download OpenAL - here is the installer for anyone else who needs it.

Is your demo using one cube-map for each "room" (4 cubes)?

Got to say I am very impressed if those reflections are done with a shared cube-map (shared between all objects/walls in a room) - they look as good as doing individual planar maps for each wall (except for when you go deliberately hunting for the artefacts at the edge-cases). For 100% reflective mirrors, the artefacts might be too much (for large mirrored areas, anyway), but for subtle glossy surfaces this is absolutely great!
If you don't publish your details I'm going to have to study your demo until I can reinvent it myself :P


[Edited by - Hodgman on April 20, 2010 8:26:12 PM]

Share this post


Link to post
Share on other sites
The ATi SDK had something similar a while back, they traced the reflection vector to a cube of a specific size and then downscaled the contact point to fit a cubemap lookup. Don't think they gave it any specific name though.

Works really nicely as a cheap alternative to calculating reflection images for each planar surface.

You can do the same for refraction too by the way :D

Share this post


Link to post
Share on other sites
The nvidia "mike" demo used some offsetting in the blured enviropment cubemap for better results of their radiosity emulation.

http://www.nzone.com/object/nzone_madmodmike_home.html

I think it might be the nearest thing I've seen to what you're doing.

But the demo looks qutie nice! :)

Share this post


Link to post
Share on other sites
I forgot to mention about OpenAL, this demo uses snapshot of my (always-)work-in-progress engine that normally goes with an installer, but in single-exe mode it doesn't install anything.

@Hodgman, you are correct, there are 4 cube-maps pre-rendered at somewhere near center of each room. Edge artifacts can't be eliminated because cube-map contains limited information about scene and using different AABB's size produces some discontinuities in projection.

@Exorcist, that Ati method sounds very much the same, I've searched current SDK (and that from 2006) and archives but I couldn't find anything similar. Do you remember year (or target hardware) of that demo? (Speaking of Ati, I remember "treasure chest" demo that comes with 8500 model, there was some magical vector passed as fourth component in their env-mapping code, but I don't think that's it)

@Krypt0n, that demo is nVidia only, I will try that at work tomorrow

To explain my (or Ati's :) ) technique I've prepared an image:

graph1.png
where, S is sample point, and Bmin/max defines our AABB (these are 3 extra constants you have to provide). The key is to find PB. Fortunately when using AABB, this can be quickly solved (without digging into math) using this code:

[font="'Courier New"]float3 dir = WrlPos - CamPos;
float3 rdir = reflect(dir, WrlTexNorm);

//BPCEM
float3 nrdir = normalize(rdir);
float3 rbmax = (EnvBoxMax - WrlPos)/nrdir;
float3 rbmin = (EnvBoxMin - WrlPos)/nrdir;

float3 rbminmax = (nrdir>0.0f)?rbmax:rbmin;
float fa = min(min(rbminmax.x, rbminmax.y), rbminmax.z);

float3 posonbox = WrlPos + nrdir*fa;
rdir = posonbox - EnvBoxPos;
//PBCEM end

float3 env = texCUBE(envMap, rdir);[/font]

of course using AABB is not the most convenient way, but most of the scenes (at least in architectural presentations) can be described/approximated as set of AABB. Or you can use more complex description at cost of additional instructions (OBB? half-spaces? distance-maps?)

//edit: fixing code box after forum upgrade

Share this post


Link to post
Share on other sites
That, my sir, is seriously cool. I´ll try to implement it and see how much it rocks :).
It could even be used for cheap GI, with a blurred cubemap (?). The first screen looks like color bleeding, due to the red wall reflecting on the other wall.

Share this post


Link to post
Share on other sites
Hello, sorry for bad english, please tell us more about how you mix the cube map, which maps in the scene elsi 30

Share this post


Link to post
Share on other sites
Lionhead recently published a paper having to do with how they did a semi realtime single bounce of GI. In it, for their irradiance probes, they stored the max distance each probe could "see" to before reaching an occluder to prevent light bleeding. It occurs to me that pretty much the same thing could be done for this.

Share this post


Link to post
Share on other sites
i just have a few questions to wrap this thing around my head:
- what is the green box??
- what is the blue box??
- i thought that env-mapping just needed a reflection vector and the cube-map and that is it, what does an AABB have to do with anything??

I still am a beginner so please help me get this thing

Share this post


Link to post
Share on other sites
One day.. one day I hope to be as talented with this as you behc that is one seriously impressive demo; it's better than tech demo from a graphics card manufacturer!

Share this post


Link to post
Share on other sites
Sorry for such late reply (for some reasons I have got no notifications that thread was active)

Many thanks for the links, looks like both nvidia and ati developed similar technique based on sphere. Idea is the same: apply some correction to reflection vector to account for finite environment. I choose box (instead of sphere) because it's more common to have environment built from boxes (especially in urban areas). Also I had more ALU instructions to spend :)

@VISQI - green box is just abstract represetation of cubemap, it's size doesn't matter, only position is important, blue box is a room (or some box approximation of environment visible in cubemap). Having only cubemap and reflection vector is enough, when you render cubemap every frame (from the center of every glossy object), AABB part improves quality when you use cubemaps pre-rendered from some fixed locations.

Share this post


Link to post
Share on other sites
(•_•)
Classic enviroment mapping for planar surfaces is just...
( •_•)>??-?
(??_?)
... plane wrong.
YEAAAAAAAAAAAAAAH!

Share this post


Link to post
Share on other sites
FYI, I downloaded your demo file, and my AntiVirus blocked it (it named the following trojan):

TR/Crypt.XPACK.Gen

Might be a red herring, but you might want to run a scan of your PC, just to be safe.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement