diff options
Diffstat (limited to 'indra/newview/llvovolume.cpp')
-rw-r--r-- | indra/newview/llvovolume.cpp | 80 |
1 files changed, 57 insertions, 23 deletions
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 42e764b492..853c580964 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -628,6 +628,14 @@ void LLVOVolume::animateTextures() LLGLTFMaterial *gltf_mat = te->getGLTFRenderMaterial(); const bool is_pbr = gltf_mat != nullptr; + if (!facep->mTextureMatrix) + { + facep->mTextureMatrix = new LLMatrix4(); + } + + LLMatrix4& tex_mat = *facep->mTextureMatrix; + tex_mat.setIdentity(); + if (!is_pbr) { if (!(result & LLViewerTextureAnim::ROTATE)) @@ -642,32 +650,50 @@ void LLVOVolume::animateTextures() { te->getScale(&scale_s, &scale_t); } - } - - if (!facep->mTextureMatrix) - { - facep->mTextureMatrix = new LLMatrix4(); - } - LLMatrix4& tex_mat = *facep->mTextureMatrix; - tex_mat.setIdentity(); + LLVector3 trans ; - LLVector3 trans ; + trans.set(LLVector3(off_s+0.5f, off_t+0.5f, 0.f)); + tex_mat.translate(LLVector3(-0.5f, -0.5f, 0.f)); - trans.set(LLVector3(off_s+0.5f, off_t+0.5f, 0.f)); - tex_mat.translate(LLVector3(-0.5f, -0.5f, 0.f)); + LLVector3 scale(scale_s, scale_t, 1.f); + LLQuaternion quat; + quat.setQuat(rot, 0, 0, -1.f); + + tex_mat.rotate(quat); - LLVector3 scale(scale_s, scale_t, 1.f); - LLQuaternion quat; - quat.setQuat(rot, 0, 0, -1.f); - - tex_mat.rotate(quat); + LLMatrix4 mat; + mat.initAll(scale, LLQuaternion(), LLVector3()); + tex_mat *= mat; + + tex_mat.translate(trans); + } + else + { + // For PBR materials, use Blinn-Phong rotation as hint for + // translation direction. In a Blinn-Phong material, the + // translation direction would be a byproduct the texture + // transform. + F32 rot_frame; + te->getRotation(&rot_frame); + + tex_mat.translate(LLVector3(-0.5f, -0.5f, 0.f)); + + LLQuaternion quat; + quat.setQuat(rot, 0, 0, -1.f); + tex_mat.rotate(quat); + + LLMatrix4 mat; + LLVector3 scale(scale_s, scale_t, 1.f); + mat.initAll(scale, LLQuaternion(), LLVector3()); + tex_mat *= mat; + + LLVector3 off(off_s, off_t, 0.f); + off.rotVec(rot_frame, 0, 0, 1.f); + tex_mat.translate(off); - LLMatrix4 mat; - mat.initAll(scale, LLQuaternion(), LLVector3()); - tex_mat *= mat; - - tex_mat.translate(trans); + tex_mat.translate(LLVector3(0.5f, 0.5f, 0.f)); + } } } else @@ -5105,6 +5131,7 @@ LLFace** LLVolumeGeometryManager::sSimpleFaces[2] = { NULL }; LLFace** LLVolumeGeometryManager::sNormFaces[2] = { NULL }; LLFace** LLVolumeGeometryManager::sSpecFaces[2] = { NULL }; LLFace** LLVolumeGeometryManager::sNormSpecFaces[2] = { NULL }; +LLFace** LLVolumeGeometryManager::sPbrFaces[2] = { NULL }; LLFace** LLVolumeGeometryManager::sAlphaFaces[2] = { NULL }; LLVolumeGeometryManager::LLVolumeGeometryManager() @@ -5141,6 +5168,7 @@ void LLVolumeGeometryManager::allocateFaces(U32 pMaxFaceCount) sNormFaces[i] = static_cast<LLFace**>(ll_aligned_malloc<64>(pMaxFaceCount * sizeof(LLFace*))); sSpecFaces[i] = static_cast<LLFace**>(ll_aligned_malloc<64>(pMaxFaceCount * sizeof(LLFace*))); sNormSpecFaces[i] = static_cast<LLFace**>(ll_aligned_malloc<64>(pMaxFaceCount * sizeof(LLFace*))); + sPbrFaces[i] = static_cast<LLFace**>(ll_aligned_malloc<64>(pMaxFaceCount * sizeof(LLFace*))); sAlphaFaces[i] = static_cast<LLFace**>(ll_aligned_malloc<64>(pMaxFaceCount * sizeof(LLFace*))); } } @@ -5155,6 +5183,7 @@ void LLVolumeGeometryManager::freeFaces() ll_aligned_free<64>(sNormFaces[i]); ll_aligned_free<64>(sSpecFaces[i]); ll_aligned_free<64>(sNormSpecFaces[i]); + ll_aligned_free<64>(sPbrFaces[i]); ll_aligned_free<64>(sAlphaFaces[i]); sFullbrightFaces[i] = NULL; @@ -5163,6 +5192,7 @@ void LLVolumeGeometryManager::freeFaces() sNormFaces[i] = NULL; sSpecFaces[i] = NULL; sNormSpecFaces[i] = NULL; + sPbrFaces[i] = NULL; sAlphaFaces[i] = NULL; } } @@ -5596,6 +5626,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) U32 norm_count[2] = { 0 }; U32 spec_count[2] = { 0 }; U32 normspec_count[2] = { 0 }; + U32 pbr_count[2] = { 0 }; static LLCachedControl<S32> max_vbo_size(gSavedSettings, "RenderMaxVBOSize", 512); static LLCachedControl<S32> max_node_size(gSavedSettings, "RenderMaxNodeSize", 65536); @@ -5877,8 +5908,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) { if (gltf_mat != nullptr) { - // all gltf materials have all vertex attributes for now - add_face(sNormSpecFaces, normspec_count, facep); + add_face(sPbrFaces, pbr_count, facep); } else { @@ -5977,6 +6007,8 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) U32 normspec_mask = norm_mask | LLVertexBuffer::MAP_TEXCOORD2; U32 spec_mask = simple_mask | LLVertexBuffer::MAP_TEXCOORD2; + U32 pbr_mask = LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_COLOR | LLVertexBuffer::MAP_TANGENT; + if (emissive) { //emissive faces are present, include emissive byte to preserve batching simple_mask = simple_mask | LLVertexBuffer::MAP_EMISSIVE; @@ -5986,6 +6018,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) norm_mask = norm_mask | LLVertexBuffer::MAP_EMISSIVE; normspec_mask = normspec_mask | LLVertexBuffer::MAP_EMISSIVE; spec_mask = spec_mask | LLVertexBuffer::MAP_EMISSIVE; + pbr_mask = pbr_mask | LLVertexBuffer::MAP_EMISSIVE; } BOOL batch_textures = LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_OBJECT) > 1; @@ -6016,6 +6049,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) geometryBytes += genDrawInfo(group, norm_mask | extra_mask, sNormFaces[i], norm_count[i], FALSE, FALSE, rigged); geometryBytes += genDrawInfo(group, spec_mask | extra_mask, sSpecFaces[i], spec_count[i], FALSE, FALSE, rigged); geometryBytes += genDrawInfo(group, normspec_mask | extra_mask, sNormSpecFaces[i], normspec_count[i], FALSE, FALSE, rigged); + geometryBytes += genDrawInfo(group, pbr_mask | extra_mask, sPbrFaces[i], pbr_count[i], FALSE, FALSE, rigged); // for rigged set, add weights and disable alpha sorting (rigged items use depth buffer) extra_mask |= LLVertexBuffer::MAP_WEIGHT4; |