Fixed bad basis matrix; eliminated normalization of binormal, since tangent and normal should be orthogonal
parent
78117e1aa1
commit
fd0a7b798f
|
@ -22,19 +22,19 @@ DP4 o[HPOS].w, c[3], v[OPOS];
|
|||
MOV R1, v[NRML];
|
||||
MOV R2, v[6];
|
||||
|
||||
# Compute the binormal--cross product of tangent and normal
|
||||
MUL R3, R2.zxyw, R1.yzxw;
|
||||
MAD R3, R2.yzxw, R1.zxyw, -R3;
|
||||
# Compute the binormal--cross product of normal and tangent
|
||||
MUL R3, R1.zxyw, R2.yzxw;
|
||||
MAD R3, R1.yzxw, R2.zxyw, -R3;
|
||||
|
||||
# Assume that the tangent and normal are orthonormal; otherwise
|
||||
# we need to normalize R2
|
||||
DP3 R0.w, R3, R3;
|
||||
RSQ R0.w, R0.w;
|
||||
MUL R3.xyz, R3, R0.w;
|
||||
# we need to normalize R3
|
||||
#DP3 R0.w, R3, R3;
|
||||
#RSQ R0.w, R0.w;
|
||||
#MUL R3.xyz, R3, R0.w;
|
||||
|
||||
# Transform the light direction from object space into surface space
|
||||
DP3 R0.x, R3, c[16];
|
||||
DP3 R0.y, R2, c[16];
|
||||
DP3 R0.x, R2, c[16];
|
||||
DP3 R0.y, R3, c[16];
|
||||
DP3 R0.z, R1, c[16];
|
||||
# Compress the light direction to fit in the primary color and output it
|
||||
MOV R5, c[40];
|
||||
|
|
|
@ -27,16 +27,17 @@ DP4 oPos.w, mvp[3], iPos;
|
|||
|
||||
# Compute the binormal--cross product of tangent and normal
|
||||
MOV t, iTangent;
|
||||
MUL binormal, t.zxyw, iNormal.yzxw;
|
||||
MAD binormal, t.yzxw, iNormal.zxyw, -binormal;
|
||||
MUL binormal, iNormal.zxyw, t.yzxw;
|
||||
MAD binormal, iNormal.yzxw, t.zxyw, -binormal;
|
||||
|
||||
DP3 binormal.w, binormal, binormal;
|
||||
RSQ binormal.w, binormal.w;
|
||||
MUL binormal.xyz, binormal, binormal.w;
|
||||
# Normalization should not be necessary
|
||||
#DP3 binormal.w, binormal, binormal;
|
||||
#RSQ binormal.w, binormal.w;
|
||||
#MUL binormal.xyz, binormal, binormal.w;
|
||||
|
||||
# Transform the light direction from object space into surface space
|
||||
DP3 light_surf.x, binormal, lightDir;
|
||||
DP3 light_surf.y, iTangent, lightDir;
|
||||
DP3 light_surf.x, iTangent, lightDir;
|
||||
DP3 light_surf.y, binormal, lightDir;
|
||||
DP3 light_surf.z, iNormal, lightDir;
|
||||
|
||||
# Compress the light direction to fit in the primary color and output it
|
||||
|
|
|
@ -40,19 +40,19 @@ MUL o[FOGC].x, R2.x, R2.y;
|
|||
MOV R1, v[NRML];
|
||||
MOV R2, v[6];
|
||||
|
||||
# Compute the binormal--cross product of tangent and normal
|
||||
MUL R3, R2.zxyw, R1.yzxw;
|
||||
MAD R3, R2.yzxw, R1.zxyw, -R3;
|
||||
# Compute the binormal--cross product of normal and tangent
|
||||
MUL R3, R1.zxyw, R2.yzxw;
|
||||
MAD R3, R1.yzxw, R2.zxyw, -R3;
|
||||
|
||||
# Assume that the tangent and normal are orthonormal; otherwise
|
||||
# we need to normalize R2
|
||||
DP3 R0.w, R3, R3;
|
||||
RSQ R0.w, R0.w;
|
||||
MUL R3.xyz, R3, R0.w;
|
||||
# we need to normalize R3
|
||||
#DP3 R0.w, R3, R3;
|
||||
#RSQ R0.w, R0.w;
|
||||
#MUL R3.xyz, R3, R0.w;
|
||||
|
||||
# Transform the light direction from object space into surface space
|
||||
DP3 R0.x, R3, c[16];
|
||||
DP3 R0.y, R2, c[16];
|
||||
DP3 R0.x, R2, c[16];
|
||||
DP3 R0.y, R3, c[16];
|
||||
DP3 R0.z, R1, c[16];
|
||||
# Compress the light direction to fit in the primary color and output it
|
||||
MOV R5, c[40];
|
||||
|
|
|
@ -53,18 +53,19 @@ MUL oFog.x, diffuseFactor.x, diffuseFactor.y;
|
|||
|
||||
# Haze is complete; now do the bump mapping setup
|
||||
|
||||
# Compute the binormal--cross product of tangent and normal
|
||||
# Compute the binormal--cross product of normal and tangent
|
||||
MOV t, iTangent;
|
||||
MUL binormal, t.zxyw, iNormal.yzxw;
|
||||
MAD binormal, t.yzxw, iNormal.zxyw, -binormal;
|
||||
MUL binormal, iNormal.zxyw, t.yzxw;
|
||||
MAD binormal, iNormal.yzxw, t.zxyw, -binormal;
|
||||
|
||||
DP3 binormal.w, binormal, binormal;
|
||||
RSQ binormal.w, binormal.w;
|
||||
MUL binormal.xyz, binormal, binormal.w;
|
||||
# Normalization should not be necessary
|
||||
#DP3 binormal.w, binormal, binormal;
|
||||
#RSQ binormal.w, binormal.w;
|
||||
#MUL binormal.xyz, binormal, binormal.w;
|
||||
|
||||
# Transform the light direction from object space into surface space
|
||||
DP3 light_surf.x, binormal, lightDir;
|
||||
DP3 light_surf.y, iTangent, lightDir;
|
||||
DP3 light_surf.x, iTangent, lightDir;
|
||||
DP3 light_surf.y, binormal, lightDir;
|
||||
DP3 light_surf.z, iNormal, lightDir;
|
||||
|
||||
# Compress the light direction to fit in the primary color and output it
|
||||
|
|
Loading…
Reference in New Issue