I was sitting on ppl, and I think ran into limits w 3 light sources, though as far as I remember instruction count shouldn’t be the problem.
FX5200, FW 56.55
vp:
uniform vec3 tangent;
uniform vec3 binormal;
uniform vec3 eyepos;
uniform vec3 light1pos;
uniform vec3 light2pos;
uniform vec3 light3pos;
varying vec3 f_l1pos;
varying vec3 f_l2pos;
varying vec3 f_l3pos;
varying vec3 f_vpos;
varying vec3 TBNeye;
varying vec3 TBNlight1;
varying vec3 TBNlight2;
varying vec3 TBNlight3;void main(void)
{
vec3 vtoe = eyepos-gl_Vertex;
vec3 vtol1 = light1pos-gl_Vertex;
vec3 vtol2 = light2pos-gl_Vertex;
vec3 vtol3 = light3pos-gl_Vertex;
vec3 normal = cross(tangent, binormal);
mat3 TBN = mat3(tangent,binormal,normal);
TBNeye = mul(TBN, vtoe);
TBNlight1 = mul(TBN, vtol1);
TBNlight2 = mul(TBN, vtol2);
TBNlight3 = mul(TBN, vtol3);
f_l1pos = light1pos;
f_l2pos = light2pos;
f_l3pos = light3pos;
f_vpos = gl_Vertex.xyz;gl_Position = mul(gl_ModelViewProjectionMatrix, gl_Vertex);
gl_TexCoord[0] = gl_MultiTexCoord0;
}
debug output:
!!VP2.0
NV_vertex_program generated by NVIDIA Cg compiler
cgc version 1.2.0310 NDA Release, build date Jan 29 2004 17:16:19
command line args: -q -profile vp30 -entry main -oglsl
nv30vp backend compiling ‘main’ program
#vendor NVIDIA Corporation
#version 1.0.02
#profile vp30
#program main
#semantic tangent
#semantic binormal
#semantic eyepos
#semantic light1pos
#semantic light2pos
#semantic light3pos
#semantic gl_ModelViewProjectionMatrix
#var float3 tangent : : c[0] : -1 : 1
#var float3 binormal : : c[1] : -1 : 1
#var float3 eyepos : : c[2] : -1 : 1
#var float3 light1pos : : c[3] : -1 : 1
#var float3 light2pos : : c[4] : -1 : 1
#var float3 light3pos : : c[5] : -1 : 1
#var float4x4 gl_ModelViewProjectionMatrix : : c[6], 4 : -1 : 1
#var float3 f_l1pos : $vout.TEX1 : TEX1 : -1 : 1
#var float3 f_l2pos : $vout.TEX2 : TEX2 : -1 : 1
#var float3 f_l3pos : $vout. : : -1 : 0
#var float3 f_vpos : $vout.TEX3 : TEX3 : -1 : 1
#var float3 TBNeye : $vout.TEX4 : TEX4 : -1 : 1
#var float3 TBNlight1 : $vout.TEX5 : TEX5 : -1 : 1
#var float3 TBNlight2 : $vout.TEX6 : TEX6 : -1 : 1
#var float3 TBNlight3 : $vout.TEX7 : TEX7 : -1 : 1
#var float4 gl_Vertex : $vin.POSITION : ATTR0 : -1 : 1
#var float4 gl_MultiTexCoord0 : $vin.TEXCOORD0 : ATTR8 : -1 : 1
#var float4 gl_Position : $vout.POSITION : HPOS : -1 : 1
#var float4 gl_TexCoord[0] : $vout.TEX0 : TEX0 : -1 : 1
#var float4 gl_TexCoord[1] : $vout.TEX1 : : -1 : 0
#var float4 gl_TexCoord[2] : $vout.TEX2 : : -1 : 0
#var float4 gl_TexCoord[3] : $vout.TEX3 : : -1 : 0
#var float4 gl_TexCoord[4] : $vout.TEX4 : : -1 : 0
#var float4 gl_TexCoord[5] : $vout.TEX5 : : -1 : 0
#var float4 gl_TexCoord[6] : $vout.TEX6 : : -1 : 0
#var float4 gl_TexCoord[7] : $vout.TEX7 : : -1 : 0
#const c[10] = 0 1 2 0
b0:
MOV o[TEX1].xyz, c[3];
MOV o[TEX2].xyz, c[4];
MOV o[TEX3].xyz, v[0].xyzx;
MOV o[TEX0], v[8];
ADD R3.xyz, c[2].xyzx, -v[0].xyzx;
MOV R2.xyz, c[0];
DP3 o[TEX4].x, R2.xyzx, R3.xyzx;
DP3 o[TEX4].y, c[1].xyzx, R3.xyzx;
MUL R0.xyz, R2.zxyz, c[1].yzxy;
MAD R1.xyz, R2.yzxy, c[1].zxyz, -R0.xyzx;
DP3 o[TEX4].z, R1.xyzx, R3.xyzx;
ADD R0.xyz, c[3].xyzx, -v[0].xyzx;
DP3 o[TEX5].x, R2.xyzx, R0.xyzx;
DP3 o[TEX5].y, c[1].xyzx, R0.xyzx;
DP3 o[TEX5].z, R1.xyzx, R0.xyzx;
ADD R0.xyz, c[4].xyzx, -v[0].xyzx;
DP3 o[TEX6].x, R2.xyzx, R0.xyzx;
DP3 o[TEX6].y, c[1].xyzx, R0.xyzx;
DP3 o[TEX6].z, R1.xyzx, R0.xyzx;
ADD R0.xyz, c[5].xyzx, -v[0].xyzx;
DP3 o[TEX7].x, R2.xyzx, R0.xyzx;
DP3 o[TEX7].y, c[1].xyzx, R0.xyzx;
DP3 o[TEX7].z, R1.xyzx, R0.xyzx;
DP4 o[HPOS].x, c[6], v[0];
DP4 o[HPOS].y, c[7], v[0];
DP4 o[HPOS].z, c[8], v[0];
DP4 o[HPOS].w, c[9], v[0];
END
27 instructions
4 temp registers
27 instrs < 256
fp:
uniform sampler2D diffuse;
uniform sampler2D normal;
varying vec3 f_l1pos;
varying vec3 f_l2pos;
varying vec3 f_l3pos;
varying vec3 f_vpos;
varying vec3 TBNeye;
varying vec3 TBNlight1;
varying vec3 TBNlight2;
varying vec3 TBNlight3;vec3 expand(vec3 v)
{
return (v-0.5)*2;
}void main (void)
{
float d1 = length(f_l1pos-f_vpos)/3;
float attenuation1 = clamp(1/(d1d1),0,1);
float d2 = length(f_l2pos-f_vpos)/3;
float attenuation2 = clamp(1/(d2d2),0,1);
float d3 = length(f_l3pos-f_vpos)/3;
float attenuation3 = clamp(1/(d3d3),0,1);
TBNeye = normalize(TBNeye);
TBNlight1 = normalize(TBNlight1);
TBNlight2 = normalize(TBNlight2);
TBNlight3 = normalize(TBNlight3);
vec3 hway1 = normalize(TBNeye+TBNlight1);
vec3 hway2 = normalize(TBNeye+TBNlight2);
vec3 hway3 = normalize(TBNeye+TBNlight3);
vec4 dcol = texture2D(diffuse, gl_TexCoord[0]);
vec4 ncol = texture2D(normal, gl_TexCoord[0]);
ncol.rgb = expand(ncol.rgb);
vec3 lxh1 = pow(dot(hway1,ncol.rgb),32);
vec3 lxh2 = pow(dot(hway2,ncol.rgb),32);
vec3 lxh3 = pow(dot(hway3,ncol.rgb),32);
vec3 lxn1 = dot(TBNlight1,ncol.rgb);
vec3 lxn2 = dot(TBNlight2,ncol.rgb);
vec3 lxn3 = dot(TBNlight3,ncol.rgb);
float diffuse = clamp(lxn1attenuation1+lxn2attenuation2+lxn3attenuation3,0,1);
float specular = clamp(lxh1attenuation1+lxh2attenuation2+lxh3attenuation3,0,1);
gl_FragColor.rgb = clamp(diffusedcol.rgb+specular*dcol.w,0,1);
gl_FragColor.a = 1;
}
No debug output for fp, but compiler reports success. If I use 2 light sources with simplified prog, inst/reg usage stats are: