
A fragment structure with plenty of texCoords Now, you want to transform your other basis vectors, that is, the tangent and binormal, with the same matrix: In OpenGL, you can use GL_MATRIXi_ARB for this on a per-object basis, very handy indeed. Keep in mind this is not necessarily the ModelView matrix, but just the matrix used to transform the model. LightVec = lightPosInWorldSpace // where w=0.

You can begin this for the normals by multiplying by the inverse transpose of the matrix used to position the model in world space to begin with: Since you are bouncing rays of the model into a cubemap, presumably oriented with the world axes, the trick is to orient your model’s normals, light to vertex vector, and eye to vertex vector in the same space. = mul( TangentMatrix, ModelViewIT.xyz ) įloat4 NormalTex = tex2D( NormalMap, IN.TexCoord0 ) * 2.0 - 1.0 įloat3 EyeVector = float3( IN.TexCoord1.w, IN.TexCoord2.w, IN.TexCoord3.w ) įloat3 Normal = float3( dot( IN.TexCoord1.xyz, NormalTex.xyz ),ĭot( IN.TexCoord3.xyz, NormalTex.xyz ) ) įloat3 CubeTex = texCUBE( CubeMap, reflect( -EyeVector, Normal ) ) Īnother way to approach this problem is from the model’s perspective. = mul( TangentMatrix, ModelViewIT.xyz )


OUT.Position = mul( ModelViewProj, IN.Position ) įloat4 WSPosition = mul( ModelView, IN.Position ) Hi, i’ve done a reflective bump mapping demo but i think there’s something wrong in the code because if i move around the reflective object it reflects always rhe same part of enviroment.
