cube map refraction

Blitz3D Forums/Blitz3D Programming/cube map refraction

Akat(Posted 2004) [#1]
how to do refraction effect using cube map?


aCiD2(Posted 2004) [#2]
i dont know, but its in the CEM fx demo, get that and analise the source. if any knows where to get it. please post a link - i wanna do the same thing!!


Ross C(Posted 2004) [#3]
I don't think you can do refraction...


Afrohorse(Posted 2004) [#4]
This is a big guess - but aren't the vertex normals used to lookup the texels in the cubemap?

So, inverting the normals to point in the opposite direction should give you refraction instead of reflection.

Worth a try ;)


Rob(Posted 2004) [#5]
check my sig.


Afrohorse(Posted 2004) [#6]
Nice cube map demo, I like it :)

Although the water is still only doing reflection * fresnel term, no refraction...

I was thinking if inverting the normals worked, then you could have two copies of the mesh, one with the normals the correct way (for lighting and reflection * fresnel alpha) and a copy with inverted normals (for refraction * 1-frensel alpha). Render both meshes and tada! - Reflection & refraction.

Should work (in theory!)


HNPhan(Posted 2004) [#7]
cant wait to see if ur theory works :)


Afrohorse(Posted 2004) [#8]
Ah well, it worked in theory - but not in practice (slim chance really) :(

Looks like the cubic environment mapping in blitz uses the vertex positions not the normals to provide the lookup, I tried several modes, but none of them what I wanted.

So, on to a new theory - even crazier :)

Setup the cubic environment map as normal and every frame render an inverted sphere with the cube map on it from the opposite direction the camera is facing. Then, copy this into a texture to provide as the source for a spherical environment map.

When rendering the object you want both reflection and refraction, you can multitexture with the first stage being the refraction, using the texture setup previously as a spherical environment map, then the reflection using the normal cubic environment map in the second stage.

Works in theory ;) - I'll give it a try...