Jump to content

  • Log In with Google      Sign In   
  • Create Account


Box Projected Cubemap Environment Mapping


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
19 replies to this topic

#1 behc   Members   -  Reputation: 631

Like
9Likes
Like

Posted 20 April 2010 - 05:28 AM

Yes, I made up that name. Recently I was looking for technique to replace flat mirrors (when there are too many on screen at once) and while pre-rendered cubemap is good for complex objects, it is totally wrong for big flat elements (like polished floor in a room). After few weeks I came to technique that can be described as simplistic ray-tracing with cubemap texture lookup that gives good result if scene is modeled as empty AA boxes. you can try the demo at behc.pl/mapa02.exe (it's quite big) I was going to write some paper about this if anyone's interested (and if i didn't reinvent the wheel again :) ), so please let me known what you think. Quick comparison screens:
img1
img2


Sponsor:

#2 0xffffffff   Members   -  Reputation: 150

Like
0Likes
Like

Posted 20 April 2010 - 01:51 PM

This is lovely. I've toyed with this idea but was never brave enough to implement it. Nice job!

#3 Atrix256   Members   -  Reputation: 510

Like
0Likes
Like

Posted 20 April 2010 - 02:04 PM

That is really really pretty.

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

#4 Hodgman   Moderators   -  Reputation: 28500

Like
0Likes
Like

Posted 20 April 2010 - 02:26 PM

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]

#5 Digitalfragment   Members   -  Reputation: 768

Like
0Likes
Like

Posted 20 April 2010 - 04:20 PM

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

#6 Krypt0n   Crossbones+   -  Reputation: 2358

Like
0Likes
Like

Posted 20 April 2010 - 08:54 PM

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! :)

#7 behc   Members   -  Reputation: 631

Like
1Likes
Like

Posted 21 April 2010 - 06:00 AM

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:

Posted Image
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:

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);


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

#8 ArKano22   Members   -  Reputation: 646

Like
0Likes
Like

Posted 21 April 2010 - 12:57 PM

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.

#9 SashaRX   Members   -  Reputation: 100

Like
0Likes
Like

Posted 04 April 2011 - 11:57 PM

Hello, sorry for bad english, please tell us more about how you mix the cube map, which maps in the scene elsi 30

#10 Locater16   Members   -  Reputation: 100

Like
0Likes
Like

Posted 05 April 2011 - 10:06 AM

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.

#11 mind in a box   Members   -  Reputation: 558

Like
0Likes
Like

Posted 05 April 2011 - 01:45 PM

Oh, that is awesome! I will definitely build this into my engine.

#12 VISQI   Members   -  Reputation: 112

Like
0Likes
Like

Posted 20 June 2011 - 10:44 PM

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

#13 Ingenu   Members   -  Reputation: 827

Like
0Likes
Like

Posted 21 June 2011 - 03:01 AM

Made me think of that : http://developer.amd...pCorrection.pdf

You seem to apply the same idea to reflections while that was demonstrated for refraction.
-* So many things to do, so little time to spend. *-

#14 Trigle   Members   -  Reputation: 103

Like
0Likes
Like

Posted 25 June 2011 - 11:03 AM

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!

#15 CukyDoh   Members   -  Reputation: 220

Like
0Likes
Like

Posted 27 June 2011 - 05:53 AM

Simple but clever little technique, good job! :lol:

#16 gjoel   Members   -  Reputation: 144

Like
0Likes
Like

Posted 27 June 2011 - 06:04 AM

This appears quite similar to the localized cubemaps of Kevin Bjorke / Nvidia - e.g. http://http.developer.nvidia.com/GPUGems/gpugems_ch19.html .

Still, very cool demo!

#17 behc   Members   -  Reputation: 631

Like
0Likes
Like

Posted 06 September 2011 - 08:52 AM

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.

#18 SUN SONS   Members   -  Reputation: 148

Like
0Likes
Like

Posted 09 November 2012 - 01:11 AM

It's very good!Posted Image
Nothing is true, everything is permitted.

#19 MrOMGWTF   Members   -  Reputation: 433

Like
0Likes
Like

Posted 10 November 2012 - 03:03 AM

(•_•)
Classic enviroment mapping for planar surfaces is just...
( •_•)>⌐■-■
(⌐■_■)
... plane wrong.
YEAAAAAAAAAAAAAAH!

#20 gfxgangsta   Members   -  Reputation: 548

Like
0Likes
Like

Posted 10 November 2012 - 12:55 PM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS