[Mesa-dev] [PATCH 45/75] st/nine: Fix condition for specular lightning

Axel Davy axel.davy at ens.fr
Wed Oct 5 20:09:18 UTC 2016


Signed-off-by: Axel Davy <axel.davy at ens.fr>
---
 src/gallium/state_trackers/nine/nine_ff.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/src/gallium/state_trackers/nine/nine_ff.c b/src/gallium/state_trackers/nine/nine_ff.c
index 374e92f..1db312c 100644
--- a/src/gallium/state_trackers/nine/nine_ff.c
+++ b/src/gallium/state_trackers/nine/nine_ff.c
@@ -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 */
 
-- 
2.10.0



More information about the mesa-dev mailing list