From fc9bb19dce2e293a377f19a873d492a16f2312ab Mon Sep 17 00:00:00 2001 From: Axel Davy Date: Sun, 25 Sep 2016 19:58:33 +0200 Subject: [PATCH] st/nine: Fix condition for specular lightning Signed-off-by: Axel Davy --- 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 374e92fbd64..1db312cd94c 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.30.2