Tweak tangents.

This commit is contained in:
Shyotl
2017-03-17 00:54:48 -05:00
parent f4a713a500
commit 1ccd8cfd89

View File

@@ -1326,6 +1326,13 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
const LLTextureEntry *tep = mVObjp->getTE(f); const LLTextureEntry *tep = mVObjp->getTE(f);
const U8 bump_code = tep ? tep->getBumpmap() : 0; const U8 bump_code = tep ? tep->getBumpmap() : 0;
if ( bump_code && rebuild_tcoord && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TANGENT) )
{
LLMaterial* mat = tep->getMaterialParams().get();
if( !mat || mat->getNormalID().isNull() )
rebuild_tangent = true;
}
BOOL is_static = mDrawablep->isStatic(); BOOL is_static = mDrawablep->isStatic();
BOOL is_global = is_static; BOOL is_global = is_static;
@@ -1592,6 +1599,9 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
LLVector4a bump_t_primary_light_ray(0.f, 0.f, 0.f); LLVector4a bump_t_primary_light_ray(0.f, 0.f, 0.f);
LLQuaternion bump_quat; LLQuaternion bump_quat;
if (!LLPipeline::sRenderDeferred)
{
if (mDrawablep->isActive()) if (mDrawablep->isActive())
{ {
bump_quat = LLQuaternion(LLMatrix4(mDrawablep->getRenderMatrix().getF32ptr())); bump_quat = LLQuaternion(LLMatrix4(mDrawablep->getRenderMatrix().getF32ptr()));
@@ -1644,6 +1654,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
bump_s_primary_light_ray.load3((offset_multiple * s_scale * primary_light_ray).mV); bump_s_primary_light_ray.load3((offset_multiple * s_scale * primary_light_ray).mV);
bump_t_primary_light_ray.load3((offset_multiple * t_scale * primary_light_ray).mV); bump_t_primary_light_ray.load3((offset_multiple * t_scale * primary_light_ray).mV);
} }
}
U8 texgen = getTextureEntry()->getTexGen(); U8 texgen = getTextureEntry()->getTexGen();
if (rebuild_tcoord && texgen != LLTextureEntry::TEX_GEN_DEFAULT) if (rebuild_tcoord && texgen != LLTextureEntry::TEX_GEN_DEFAULT)
@@ -1913,7 +1924,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
mVertexBuffer->flush(); mVertexBuffer->flush();
} }
if (!mat && do_bump) if ( !LLPipeline::sRenderDeferred && do_bump )
{ {
mVertexBuffer->getTexCoord1Strider(tex_coords1, mGeomIndex, mGeomCount, map_range); mVertexBuffer->getTexCoord1Strider(tex_coords1, mGeomIndex, mGeomCount, map_range);
@@ -2090,11 +2101,21 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
LLVector4a* src = vf.mTangents; LLVector4a* src = vf.mTangents;
LLVector4a* end = vf.mTangents+num_vertices; LLVector4a* end = vf.mTangents+num_vertices;
LLVector4a* src2 = vf.mNormals;
LLVector4a* end2 = vf.mNormals+num_vertices;
LLMaterial* mat = tep->getMaterialParams().get();
F32 rot = RAD_TO_DEG * ( (mat && mat->getNormalID().notNull()) ? mat->getNormalRotation() : r);
bool rotate_tangent = src2 && !is_approx_equal(rot, 360.f) && !is_approx_zero(rot);
while (src < end) while (src < end)
{ {
LLVector4a tangent_out; LLVector4a tangent_out = *src;
mat_normal.rotate(*src, tangent_out); if (rotate_tangent && src2 < end2)
{
gGL.genRot(rot, *src2++).rotate(tangent_out, tangent_out);
}
mat_normal.rotate(tangent_out, tangent_out);
tangent_out.normalize3fast(); tangent_out.normalize3fast();
tangent_out.copyComponent<3>(*src); tangent_out.copyComponent<3>(*src);
tangent_out.store4a(tangents); tangent_out.store4a(tangents);