yeah, that was a dumb/wrong explanation; my bad. What I was trying to say was that if I used any one of the glstate matrices, it would break things not even related to or dependent on that matrix.
This is the vertex program:
/*
Tex0: passthru
Tex1: reflection map
color0: diffuse
color1: specular
*/
#if 0
#define MVP glstate.matrix.mvp
#define MV glstate.matrix.modelview[0]
#define ITMV glstate.matrix.invtrans.modelview[0]
#else
#define MVP modelview_proj
#define MV modelview
#define ITMV modelviewIT
#endif
void main(in float4 pos : POSITION,
in float4 norm : NORMAL,
in float3 tex0 : TEXCOORD0,
out float4 Opos : POSITION,
out float3 Ocol0 : COLOR0,
out float3 Ocol1 : COLOR1,
out float3 Otex0 : TEXCOORD0,
out float3 Otex1 : TEXCOORD1,
uniform float4x4 modelview,
uniform float4x4 modelview_proj,
uniform float4x4 modelviewIT,
uniform float4 lightvec, // direction TO light, in EYE space
uniform float3 light_d,
uniform float3 light_s // lighting colours
)
{
// clip-space position
Opos = mul(MVP, pos);
// transform normal to view space
float3 normal=normalize(mul(ITMV, norm).xyz);
// pass-thru first texcoord
Otex0 = tex0;
// bad approx of vector to eye
// float3 eye=float3(0.0, 0.0, 1.0);
// actual eye-vector (from eye to vertex)
float3 eye=normalize(mul(MV, pos));
// reflection map for 2nd texcoord
Otex1 = reflect(eye, normal);
// Otex1 = normalize(2*normal+eye);
// half-angle vector
float3 halfa=normalize(lightvec - eye);
// brightnesses
float diffuse=dot(normal, lightvec);
float specular=dot(normal, halfa);
// y = diffuse, z = specular (1-facedness + power)
float4 lighting=lit(diffuse, specular, 32);
Ocol0.rgb = lighting.y * light_d;
// specular colour
Ocol1 = lighting.z * light_s;
// debugging purposes...
Ocol1 = Otex1;
}
Anyway. Using explicitly-passed matrices, it works properly. Using the glstate matrices, I discovered that the reflect() was returning its first argument instead of the reflection, also that the lit operation was returning bogus results. The glstate matrices seem to have the correct value.
See the debugging thing at the end - when working, the specular colour will be the reflection vector. When using the glstate stuff, it still contains the eye vector.
PS: shadertech forums seem to be down, so I figured I’d bother you guys instead
And I’ve been too slack to install Cg 1.4 yet, but will hopefully soon.