summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorDave Houlton <euclid@lindenlab.com>2021-01-29 19:12:04 +0000
committerDave Houlton <euclid@lindenlab.com>2021-01-29 19:12:04 +0000
commit4ae7c00dc4afc85ede2d82d0269a8791f7e07761 (patch)
treef304321c53d6f1c81e4c1aa28834bda1805e1a6d /indra/newview
parent2a5abb4d6a4cfd3a0b7c0e702a70e275a4e6f3a2 (diff)
parent6f2cfaed0dab87dec8df88b28a8dfb3a11580f8e (diff)
Merged in euclid-13490 (pull request #453)
SL-13490 replace imperfect object-sized normals/tangents with constant length
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llspatialpartition.cpp19
1 files changed, 6 insertions, 13 deletions
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index b87551dab5..0186c1943f 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -2274,10 +2274,13 @@ void renderNormals(LLDrawable *drawablep)
// one forward scale will be re-applied via the MVP in the vertex shader)
LLVector3 scale_v3 = vol->getScale();
+ float scale_len = scale_v3.length();
LLVector4a obj_scale(scale_v3.mV[VX], scale_v3.mV[VY], scale_v3.mV[VZ]);
obj_scale.normalize3();
- float draw_length = gSavedSettings.getF32("RenderDebugNormalScale");
+ // Normals &tangent line segments get scaled along with the object. Divide by scale length
+ // to keep the as-viewed lengths (relatively) constant with the debug setting length
+ float draw_length = gSavedSettings.getF32("RenderDebugNormalScale") / scale_len;
// Create inverse-scale vector for normals
LLVector4a inv_scale(1.0 / scale_v3.mV[VX], 1.0 / scale_v3.mV[VY], 1.0 / scale_v3.mV[VZ]);
@@ -2303,12 +2306,7 @@ void renderNormals(LLDrawable *drawablep)
n.setMul(face.mNormals[j], 1.0);
n.mul(inv_scale); // Pre-scale normal, so it's left with an inverse-transpose xform after MVP
n.normalize3fast();
-
- // Since we send 2 vertices instead of a vertex and a vector, the drawn normal length ends up
- // getting stretched along with the object. To minimize that effect (imperfectly), reduce its
- // length by a dot factor with the dominant scale direction.
- float mvp_scale_factor = 0.95 * abs(n.dot3(obj_scale).getF32());
- n.mul((1.0 - mvp_scale_factor) * draw_length);
+ n.mul(draw_length);
p.setAdd(face.mPositions[j], n);
gGL.vertex3fv(face.mPositions[j].getF32ptr());
@@ -2328,12 +2326,7 @@ void renderNormals(LLDrawable *drawablep)
t.setMul(face.mTangents[j], 1.0f);
t.normalize3fast();
-
- // Since we send 2 vertices instead of a vertex and a vector, the drawn tangent length ends up
- // getting stretched along with the object. To minimize that effect (imperfectly), reduce its
- // length by a dot factor with the dominant scale direction.
- float mvp_scale_factor = 0.95 * abs(t.dot3(obj_scale).getF32());
- t.mul((1.0 - mvp_scale_factor) * draw_length);
+ t.mul(draw_length);
p.setAdd(face.mPositions[j], t);
gGL.vertex3fv(face.mPositions[j].getF32ptr());