Hello,

I am trying to optimise my environment cube-map rendering shader for refraction/rendering.

I have a working vertex/fragment program pair

which interpolate tangent space between vertices using the following lines of code:

// Vertex shader

varying vec3 NewTangent;

varying vec3 NewBinormal;

varying vec3 NewNormal;

// Fragment shader

varying vec3 NewTangent;

varying vec3 NewBinormal;

varying vec3 NewNormal;

…

mat3 temp;

temp[0] = NewTangent;

temp[1] = NewBinormal;

temp[2] = NewNormal;

SurfNormal = Texture2d( bumpmap, texcoord.xy);

localnormal = SurfNormal * temp;

localnormal = normalize(localnormal);

This works. But when I attempt to replace these three varying vec3’s with a single mat3 matrix, interpolation doesn’t work ie…

// Vertex shader

varying mat3 TangentSpaceMatrix;

// Fragment shader

varying mat3 TangentSpaceMatrix;

…

SurfNormal = Texture2d( bumpmap, texcoord.xy);

localnormal = SurfNormal * TangentSpaceMatrix;

localnormal = normalize(localnormal);

This doesn’t work. Is this a bug?

I thought a mat3x3 should interpolate?