Box Projected Cube Environment Mapping demo (Shiny!)

I already posted a YouTube video of this and it instantly got an awesome response from viewers, without even knowing what actually are they looking at.

Regular Cube Environment Mappingis 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. The original thread about BPCEM is HERE. It is made by Bartosz Czuba and thanks him for helping me get this to work in BGE.

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

video of shader in action

and a blend file of course: bpcem_playground.blendit is for 2.49, but should run fine on 2.5

mouselook: WASD + mouse (player can walk through walls :))
shoot a sphere: LMB
shoot a lot of spheres: MMB
zoom: RMB
1: Remove AA (Antialisaing)

thread about AA filters listed above is here -

PS. I haven`t tested this on ATI cards.

Wow, man! You’re just awesome. I’m very impressed. Thanks for sharing! :slight_smile: :slight_smile:

just awesome

great stuff!

Very, very impressive.
The color bleeding, is that true SSGI or has it to do with the BPCEM?

Works great on ATI cards, btw: I have an ATI HD4350 (not great at all) and I got 40 FPS with all shaders on…

Exceptional. It looks like a very real game, like Mirror’s Edge. Very, very good work.

Wow, impressive, wowowow, I m amased, thanks a lot!

That is amazing!

Looks quite stunning Martinsh, great work. Havent seen so much shiney in the BGE ever before :slight_smile:

Love the potential for this though, cant wait to see what you come up with next as well. Keep it up :smiley:

I wonder how much lag dynamically generated cube maps would introduce. I haven’t benchmarked the render to texture functions yet…

This is amazing… solid 60 fps with AO on @1920x1080!

Wow! Im speechless…

I already posted a YouTube video of this and it instantly got an awesome response from viewers, without even knowing what actually are they looking at.

Haha i get it though, will this feature reach blender as a ‘built in’ function soon?

really nice :slight_smile: I think if you make a Horror Game with Those graphics… ill shit on my pants:D

EDIT: Lol, I just realized Who you are!, your the creator Of the fantastic bathorm, That bathroom make me come here to blender You are a god of details, Exelent Work Very very impressive

It’s a great piece of technology although it seems to be rather static. For example, I moved one of the stacks of pallets back to the room you start in and noticed they didn’t have this shader applied to them. I also noticed that the spheres contain three environment textures. When you’d have a game with a lot of rooms how are you going to handle the textures in that case? (if you transfer the cubemapped objects from the first room to say the last room that is room 50 for example?)

Kind regards.

WAHOOOw! DUDE this is sick, man your little demo looks so real, PS blender foundation should get you and a few other guys I know to make a blender games trailer and they should have the next offical blender project yet another game… maybe this time we could get a shooter instead another furry adventure (yofrankie) :stuck_out_tongue: though it was kinda fun after all…

lovin it I want to examine every thing very closely

Thanks for the replies. seems like it is working well on different hardware.

yea well GLSL allows only 4 texture channels applied on them, not more, so boxes are using only single env-map.

That is why I am thinking of something like texture swapping, for dynamic objects. Something similar of what Source engine does. So when you enter a room with specific property, the script changes the the texture in the envmap channel.

This is nothing short of incredible stuff, and I personally find it a pleasant surprise that the BGE can actually do graphics like that.

Now if we can just convince Ton to allow Moguri to merge the branch and patches he has related to the BGE into trunk for the 2.6 final release if not to just give the BGE a better feature set to show for the big announcement.

Otherwise, we may still may only have to wait for a couple months or so because even Ton wrote in the Bmesh thread that the beta period has gone on for too long and anticipates seeing it conclude.

Has anyone actually mailed Ton about the game engine updates? I mean all the bug fixing can get very distracting so maybe he kind of forgot about it.

Kind regards.

Here is a fix for the DLAA filter on AMD cards. Read the comments in my pseudo diff.

float height = bgl_RenderedTextureHeight; //texture height
float oneThird = 1.0 / 3.0; //<--put this line below the one above.
... //<--snip
float avg(const in vec3 value) //<--was wrong return type (vec3).
  // static const float oneThird = 1.0 / 3.0; //<-- there is no 'static' in glsl. I declared oneThird in global scope which works as good as static. :)
   return dot(, vec3(oneThird, oneThird, oneThird) );

This fixes the ssao compilation. Thought i still have black artifacts all over the screen if i turn ssao on. Maybe sampling outside 2DSampler boundaries causes this? Don’t know, i didn’t study the code, just fixed the reported errors.

	vec3 black = vec3(0.0,0.0,0.0);
	vec3 treshold = vec3(0.2,0.2,0.2); //<-- glsl requires explicit type casting vec3.

The demo as such is pretty impressive. I noticed the weird reflections of the white windows when standing at the end of the coridor, looking left and right you can still see the reflections of the windows. But the overall illusion is pretty good.