!!ARBvp1.0
PARAM mvp[4] = {state.matrix.mvp};
PARAM texgenS = state.texgen[0].object.s;
PARAM texgenT = state.texgen[0].object.t;
PARAM texgenR = state.texgen[0].object.r;
PARAM texgenQ = state.texgen[0].object.q;
PARAM texmat[4] = {state.matrix.texture};
TEMP texcoords;
MOV result.color, vertex.normal;
DP4 result.position.x, mvp[0], vertex.position;
DP4 result.position.y, mvp[1], vertex.position;
DP4 result.position.z, mvp[2], vertex.position;
DP4 result.position.w, mvp[3], vertex.position;
DP4 texcoords.x, texgenS, vertex.position;
DP4 texcoords.y, texgenT, vertex.position;
DP4 texcoords.z, texgenR, vertex.position;
DP4 texcoords.w, texgenQ, vertex.position;
DP4 texcoords.x, texmat[0], texcoords;
DP4 texcoords.y, texmat[1], texcoords;
DP4 texcoords.z, texmat[2], texcoords;
DP4 texcoords.w, texmat[3], texcoords;
MOV result.texcoord[0], texcoords;
END
!!ARBfp1.0
OUTPUT final = result.color;
ATTRIB normal = fragment.color;
TEMP temp, temp1, base;
# directional light vector
PARAM lightdir = {1.0, 0.5, 0.0, 1.0};
# base texture
TEX base, fragment.texcoord[0], texture[0], 2D;
# normalize the normal vector
DP3 temp, normal, normal;
RSQ temp, temp.r;
MUL temp, temp, normal;
# normalize the light vector
DP3 temp1, lightdir, lightdir;
RSQ temp1, temp1.r;
MUL temp1, temp1, lightdir;
# N.L
DP3 temp, temp, temp1;
# modulate with base texture
MUL temp, temp, base;
# make sure the alpha is set to 1.0
MOV temp.a, 1.0;
# output the result
MOV_SAT final, temp;
END
Try the TXP instructionOriginally posted by Ostsol
Here's my fragment program code, too:
Code:!!ARBfp1.0 OUTPUT final = result.color; ATTRIB normal = fragment.color; TEMP temp, temp1, base; # directional light vector PARAM lightdir = {1.0, 0.5, 0.0, 1.0}; # base texture [color=red]TEX base, fragment.texcoord[0], texture[0], 2D;[/color] # normalize the normal vector DP3 temp, normal, normal; RSQ temp, temp.r; MUL temp, temp, normal; # normalize the light vector DP3 temp1, lightdir, lightdir; RSQ temp1, temp1.r; MUL temp1, temp1, lightdir; # N.L DP3 temp, temp, temp1; # modulate with base texture MUL temp, temp, base; # make sure the alpha is set to 1.0 MOV temp.a, 1.0; # output the result MOV_SAT final, temp; END
!!ARBvp1.0
PARAM mvp[4] = {state.matrix.mvp};
PARAM texgenS = state.texgen[0].object.s;
PARAM texgenT = state.texgen[0].object.t;
PARAM texgenR = state.texgen[0].object.r;
PARAM texgenQ = state.texgen[0].object.q;
PARAM texmat[4] = {state.matrix.texture};
TEMP texcoords;
MOV result.color, vertex.normal;
DP4 result.position.x, mvp[0], vertex.position;
DP4 result.position.y, mvp[1], vertex.position;
DP4 result.position.z, mvp[2], vertex.position;
DP4 result.position.w, mvp[3], vertex.position;
DP4 texcoords.x, texgenS, vertex.position;
DP4 texcoords.y, texgenT, vertex.position;
DP4 texcoords.z, texgenR, vertex.position;
DP4 texcoords.w, texgenQ, vertex.position;
DP4 result.texcoord.x, texmat[0], texcoords;
DP4 result.texcoord.y, texmat[1], texcoords;
DP4 result.texcoord.z, texmat[2], texcoords;
DP4 result.texcoord.w, texmat[3], texcoords;
END
!!ARBvp1.0
PARAM mvp[4] = {state.matrix.mvp};
PARAM mv[4] = {state.matrix.modelview};
PARAM texgenS = state.texgen[0].eye.s;
PARAM texgenT = state.texgen[0].eye.t;
PARAM texgenR = state.texgen[0].eye.r;
PARAM texgenQ = state.texgen[0].eye.q;
PARAM texmat[4] = {state.matrix.texture};
TEMP texcoords, vertcoords;
MOV result.color, vertex.normal;
DP4 result.position.x, mvp[0], vertex.position;
DP4 result.position.y, mvp[1], vertex.position;
DP4 result.position.z, mvp[2], vertex.position;
DP4 result.position.w, mvp[3], vertex.position;
DP4 vertcoords.x, mv[0], vertex.position;
DP4 vertcoords.y, mv[1], vertex.position;
DP4 vertcoords.z, mv[2], vertex.position;
DP4 vertcoords.w, mv[3], vertex.position;
DP4 texcoords.x, texgenS, vertcoords;
DP4 texcoords.y, texgenT, vertcoords;
DP4 texcoords.z, texgenR, vertcoords;
DP4 texcoords.w, texgenQ, vertcoords;
DP4 result.texcoord.x, texmat[0], texcoords;
DP4 result.texcoord.y, texmat[1], texcoords;
DP4 result.texcoord.z, texmat[2], texcoords;
DP4 result.texcoord.w, texmat[3], texcoords;
END