ureg_ENDIF(ureg);
/* directional factors, let's not use LIT because of clarity */
- ureg_DP3(ureg, ureg_saturate(tmp_x), vs->aNrm, ureg_src(rHit));
- ureg_MOV(ureg, tmp_y, ureg_imm1f(ureg, 0.0f));
- ureg_IF(ureg, _X(tmp), &label[l++]);
+
+ if (key->localviewer) {
+ ureg_normalize3(ureg, rMid, vs->aVtx);
+ ureg_SUB(ureg, rMid, ureg_src(rHit), ureg_src(rMid));
+ } else {
+ ureg_SUB(ureg, rMid, ureg_src(rHit), ureg_imm3f(ureg, 0.0f, 0.0f, 1.0f));
+ }
+ ureg_normalize3(ureg, rMid, ureg_src(rMid));
+ ureg_DP3(ureg, ureg_saturate(tmp_y), vs->aNrm, ureg_src(rMid));
+ ureg_IF(ureg, _Y(tmp), &label[l++]);
{
- /* midVec = normalize(hitDir + eyeDir) */
- if (key->localviewer) {
- ureg_normalize3(ureg, rMid, vs->aVtx);
- ureg_SUB(ureg, rMid, ureg_src(rHit), ureg_src(rMid));
- } else {
- ureg_SUB(ureg, rMid, ureg_src(rHit), ureg_imm3f(ureg, 0.0f, 0.0f, 1.0f));
- }
- ureg_normalize3(ureg, rMid, ureg_src(rMid));
- ureg_DP3(ureg, ureg_saturate(tmp_y), vs->aNrm, ureg_src(rMid));
ureg_POW(ureg, tmp_y, _Y(tmp), mtlP);
ureg_MUL(ureg, tmp_y, _W(rAtt), _Y(tmp)); /* power factor * att */
ureg_MAD(ureg, rS, cLColS, _Y(tmp), ureg_src(rS)); /* accumulate specular */
ureg_ENDIF(ureg);
ureg_MAD(ureg, rA, cLColA, _W(rAtt), ureg_src(rA)); /* accumulate ambient */
+ ureg_DP3(ureg, ureg_saturate(tmp_x), vs->aNrm, ureg_src(rHit));
ureg_MUL(ureg, tmp_x, _W(rAtt), _X(tmp)); /* dp3(normal,hitDir) * att */
ureg_MAD(ureg, rD, cLColD, _X(tmp), ureg_src(rD)); /* accumulate diffuse */