Bumped Cubemap, Inverse TBN, tangent to objectspac

I try to realize a bumped Cubemap.

Without a bumpmap affecting the cubemap its no problem.

I have the reflectVector for the cubemap lookup in object-space which works fine.

But the normal_t for the bumpmap is in tangent space.

I tried to calculate normal_t into objectspace for the cubemap lookup.

For this I created the TBN_InverseMatrix for test purpose just in fragment shader:

varying vec3 normal_o;
attribute vec3 rm_Tangent;
//where this attribute is just treated as a varying because of the interpolation

vec3 n = normal_o;
vec3 t = rm_Tangent;
vec3 b = cross(t,n);

//determinant

float d = t.xb.xn.z + b.xn.yt.z + n.xt.yb.z -
n.xb.xt.z + b.xt.yn.z + n.yt.xb.z;

vec3 ti = vec3 (b.yn.z - b.zn.y, n.yt.z - t.yn.z, t.yb.z - b.yt.z);
vec3 bi = vec3 (n.xb.z - b.xn.z, t.xn.z - n.xt.z, b.xt.z - t.xb.z);
vec3 ni = vec3 (b.xn.y - n.xb.y, n.xt.y - t.xn.y, t.xb.y - b.xt.y);

mat3 TBN_Matrix = mat3(t, b, n);
mat3 TBN_InverseMatrix = mat3(ti, bi, ni) / d;

vec3 normalb_o = normal_t * TBN_InverseMatrix;
reflectVector_vn_o = normalize(reflect(-viewVector_o, normalb_o));
//…
cubeColor = textureCube(cubeMap, reflectVector_vn_o, 1.0);

But now I don’t have a cubemap at all.

I have never seen a other shader having a bumped cubemap aslong the bump is from a texture.

Anyone an idea ?

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.