st/nine: Fix condition for specular lightning
authorAxel Davy <axel.davy@ens.fr>
Sun, 25 Sep 2016 17:58:33 +0000 (19:58 +0200)
committerAxel Davy <axel.davy@ens.fr>
Mon, 10 Oct 2016 21:43:50 +0000 (23:43 +0200)
Signed-off-by: Axel Davy <axel.davy@ens.fr>
src/gallium/state_trackers/nine/nine_ff.c

index 374e92fbd64b7b67c97c70dcd0e8cc82a516a0a8..1db312cd94c656cb3216a74462cb2f73952eef54 100644 (file)
@@ -874,19 +874,17 @@ nine_ff_build_vs(struct NineDevice9 *device, struct vs_build_ctx *vs)
         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 */
@@ -895,6 +893,7 @@ nine_ff_build_vs(struct NineDevice9 *device, struct vs_build_ctx *vs)
         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 */