Im trying to make a light in my vertex program but i want it (for now) to use the the most simple lighting calculations. I looked at the nvidia lit quad example and i hope i can do less than that to make a simple light. I dont quite understand all of what they are doing yet. Here is what i have so far, and my spinning quad (how exciting eh? ) is all black.
// c[0] - c[3] will contain the modelview + projection matrix
// c[10] - c[13] will contain the inverse modelview matrix
// c[4] will contain the diffuse color
// c[5] will contain the light vector
// c[6] will contain some zeros
// o[HPOS] will be the output vector
// o[COL0] will contain the diffuse color
// v[OPOS] will contain the vertex
// v[NRML] will contain the vertex normal
char vtx_prog[] =
"!!VP1.0 # This is a sample vertex program!.
"
“DP4 o[HPOS].x, c[0], v[OPOS];” // Perform the standard transform
“DP4 o[HPOS].y, c[1], v[OPOS];” // …
“DP4 o[HPOS].z, c[2], v[OPOS];” // …
“DP4 o[HPOS].w, c[3], v[OPOS];” // …
“MOV o[COL0], c[4];”
// Compute the object space light vector
“MOV R3, c[5];” // Move to a temp register so we dont get an error when the DP3 occurs
“DP3 R1.x, c[10], R3;” // An instruction wont work if the operands are the same ‘type’
“DP3 R1.y, c[11], R3;” // ie both c registers (DP3 R1.x, c[10], c[5]) << ERROR!
“DP3 R1.z, c[12], R3;”
“MOV R2, -R1;” // Why negate this?
“DP3 R0, v[NRML], R2;”
“MAX R0, R0, c[6].x;”
“MUL o[COL0], R0.x, v[4];”
“MOV o[TEX0], v[TEX0];” // Copy texture coords over
“END”;
Am i missing something here? I just want a simple diffuse light and nothing more right now.
-SirKnight