Labels

September 20, 2011

//status update 01

I have moved from Latvia to France. I dont have my own computer here and the appartment/survival problems are chasing me right now.
So I have stalled all of the personal projects for the moment till I get back on my feet. Till then I will be collecting and refurbishing my old work and I will be posting it here.

September 19, 2011

box projected cube environment mapping

I have been quite busy moving to another country, so nothing new this time. Oh, yeah, I added donate button, hehe.

BPCEM or box projected cube environment mapping is a cube environment mapping technique made by Bartosz Czuba http://devlog.behc.pl/. I thank him for helping me get this to work in BGE.

Regular Cube Environment Mapping is a very common technique of making fast fake reflections. It works best in outdoors, when reflecting distant skies and stuff that reaches to infinity, but looks very wrong in indoors, especially on flat surfaces, like walls and floor. It is caused by cube-map coordinates that reaches to infinity.

What BPCEM basically does, it takes the cube-map coordinates and clamps them to the size of the room. This technique only looks best in simple box shaped rooms. The original thread about BPCEM is HERE.

comparison stills (regular cube mapping vs BPCEM):
regular cubemap still looks fine on spheres, but wrong on flat surfaces.




All the difference makes these few lines of code:


vec3 bpcem (in vec3 v, vec3 eMax, vec3 eMin, vec3 ePos)
{
vec3 nrdir = normalize(v);
vec3 rbmax = (eMax - pos)/nrdir;
vec3 rbmin = (eMin - pos)/nrdir;

vec3 rbminmax;
rbminmax.x = (nrdir.x>0.0)?rbmax.x:rbmin.x;
rbminmax.y = (nrdir.y>0.0)?rbmax.y:rbmin.y;
rbminmax.z = (nrdir.z>0.0)?rbmax.z:rbmin.z;
float fa = min(min(rbminmax.x, rbminmax.y), rbminmax.z);
vec3 posonbox = pos + nrdir * fa;
return posonbox - ePos;
}


here is GLSL code: http://dl.dropbox.com/u/11542084/bpcem

and a .blend file: http://dl.dropbox.com/u/11542084/bpcem_playground.blend