Tweak tangents.
This commit is contained in:
@@ -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,57 +1599,61 @@ 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 (mDrawablep->isActive())
|
|
||||||
{
|
|
||||||
bump_quat = LLQuaternion(LLMatrix4(mDrawablep->getRenderMatrix().getF32ptr()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bump_code)
|
if (!LLPipeline::sRenderDeferred)
|
||||||
{
|
{
|
||||||
mVObjp->getVolume()->genTangents(f);
|
if (mDrawablep->isActive())
|
||||||
F32 offset_multiple;
|
|
||||||
switch( bump_code )
|
|
||||||
{
|
{
|
||||||
|
bump_quat = LLQuaternion(LLMatrix4(mDrawablep->getRenderMatrix().getF32ptr()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bump_code)
|
||||||
|
{
|
||||||
|
mVObjp->getVolume()->genTangents(f);
|
||||||
|
F32 offset_multiple;
|
||||||
|
switch (bump_code)
|
||||||
|
{
|
||||||
case BE_NO_BUMP:
|
case BE_NO_BUMP:
|
||||||
offset_multiple = 0.f;
|
offset_multiple = 0.f;
|
||||||
break;
|
break;
|
||||||
case BE_BRIGHTNESS:
|
case BE_BRIGHTNESS:
|
||||||
case BE_DARKNESS:
|
case BE_DARKNESS:
|
||||||
if( mTexture[LLRender::DIFFUSE_MAP].notNull() && mTexture[LLRender::DIFFUSE_MAP]->hasGLTexture())
|
if (mTexture[LLRender::DIFFUSE_MAP].notNull() && mTexture[LLRender::DIFFUSE_MAP]->hasGLTexture())
|
||||||
{
|
{
|
||||||
// Offset by approximately one texel
|
// Offset by approximately one texel
|
||||||
S32 cur_discard = mTexture[LLRender::DIFFUSE_MAP]->getDiscardLevel();
|
S32 cur_discard = mTexture[LLRender::DIFFUSE_MAP]->getDiscardLevel();
|
||||||
S32 max_size = llmax( mTexture[LLRender::DIFFUSE_MAP]->getWidth(), mTexture[LLRender::DIFFUSE_MAP]->getHeight() );
|
S32 max_size = llmax(mTexture[LLRender::DIFFUSE_MAP]->getWidth(), mTexture[LLRender::DIFFUSE_MAP]->getHeight());
|
||||||
max_size <<= cur_discard;
|
max_size <<= cur_discard;
|
||||||
const F32 ARTIFICIAL_OFFSET = 2.f;
|
const F32 ARTIFICIAL_OFFSET = 2.f;
|
||||||
offset_multiple = ARTIFICIAL_OFFSET / (F32)max_size;
|
offset_multiple = ARTIFICIAL_OFFSET / (F32)max_size;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
offset_multiple = 1.f/256;
|
offset_multiple = 1.f / 256;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: // Standard bumpmap textures. Assumed to be 256x256
|
default: // Standard bumpmap textures. Assumed to be 256x256
|
||||||
offset_multiple = 1.f / 256;
|
offset_multiple = 1.f / 256;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
F32 s_scale = 1.f;
|
F32 s_scale = 1.f;
|
||||||
F32 t_scale = 1.f;
|
F32 t_scale = 1.f;
|
||||||
if( tep )
|
if (tep)
|
||||||
{
|
{
|
||||||
tep->getScale( &s_scale, &t_scale );
|
tep->getScale(&s_scale, &t_scale);
|
||||||
}
|
}
|
||||||
// Use the nudged south when coming from above sun angle, such
|
// Use the nudged south when coming from above sun angle, such
|
||||||
// that emboss mapping always shows up on the upward faces of cubes when
|
// that emboss mapping always shows up on the upward faces of cubes when
|
||||||
// it's noon (since a lot of builders build with the sun forced to noon).
|
// it's noon (since a lot of builders build with the sun forced to noon).
|
||||||
LLVector3 sun_ray = gSky.mVOSkyp->mBumpSunDir;
|
LLVector3 sun_ray = gSky.mVOSkyp->mBumpSunDir;
|
||||||
LLVector3 moon_ray = gSky.getMoonDirection();
|
LLVector3 moon_ray = gSky.getMoonDirection();
|
||||||
LLVector3& primary_light_ray = (sun_ray.mV[VZ] > 0) ? sun_ray : moon_ray;
|
LLVector3& primary_light_ray = (sun_ray.mV[VZ] > 0) ? sun_ray : moon_ray;
|
||||||
|
|
||||||
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();
|
||||||
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user