diff options
author | Runitai Linden <davep@lindenlab.com> | 2021-12-09 14:02:05 -0600 |
---|---|---|
committer | Runitai Linden <davep@lindenlab.com> | 2021-12-09 14:02:05 -0600 |
commit | f475644bb1b49f0706bb34c59f4931f83bc11e81 (patch) | |
tree | 97703dda73c4fc995e81283ff9ecde6d620010fd /indra | |
parent | 9689e606f4da78dd5654124b3e90913b4e934b1a (diff) | |
parent | 0a9ade4687dd53e9973ebfdf1ef948f04f5ac8c1 (diff) |
Merge branch 'DRTVWR-546' of ssh://bitbucket.org/lindenlab/viewer into DRTVWR-546
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/lldrawpoolwater.cpp | 5 | ||||
-rw-r--r-- | indra/newview/llfloatermodelpreview.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llmodelpreview.cpp | 54 | ||||
-rw-r--r-- | indra/newview/llmodelpreview.h | 11 | ||||
-rw-r--r-- | indra/newview/llvieweroctree.cpp | 6 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_model_preview.xml | 16 |
6 files changed, 50 insertions, 44 deletions
diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index 590385472b..62706feae3 100644 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -679,9 +679,8 @@ void LLDrawPoolWater::renderWater() { face->renderIndexed(); - // If not occlusion culling, record non-void water being drawn - // (If occlusion is enabled, these are set within LLOcclusionCullingGroup::checkOcclusion() ) - if (!edge && !LLPipeline::sUseOcclusion) + // Note non-void water being drawn, updates required + if (!edge) // SL-16461 remove !LLPipeline::sUseOcclusion check { sNeedsReflectionUpdate = TRUE; sNeedsDistortionUpdate = TRUE; diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index aec4e4b8d9..ad9b4c84b4 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -727,7 +727,6 @@ void LLFloaterModelPreview::onLODParamCommit(S32 lod, bool enforce_tri_limit) switch (mode) { case LLModelPreview::MESH_OPTIMIZER_AUTO: - case LLModelPreview::MESH_OPTIMIZER: case LLModelPreview::MESH_OPTIMIZER_SLOPPY: case LLModelPreview::MESH_OPTIMIZER_COMBINE: mModelPreview->onLODMeshOptimizerParamCommit(lod, enforce_tri_limit, mode); @@ -1736,7 +1735,6 @@ void LLFloaterModelPreview::onLoDSourceCommit(S32 lod) LLComboBox* lod_source_combo = getChild<LLComboBox>("lod_source_" + lod_name[lod]); S32 index = lod_source_combo->getCurrentIndex(); if (index == LLModelPreview::MESH_OPTIMIZER_AUTO - || index == LLModelPreview::MESH_OPTIMIZER || index == LLModelPreview::MESH_OPTIMIZER_SLOPPY || index == LLModelPreview::MESH_OPTIMIZER_COMBINE) { //rebuild LoD to update triangle counts diff --git a/indra/newview/llmodelpreview.cpp b/indra/newview/llmodelpreview.cpp index 907b5ec418..1da9e6c651 100644 --- a/indra/newview/llmodelpreview.cpp +++ b/indra/newview/llmodelpreview.cpp @@ -1380,6 +1380,7 @@ F32 LLModelPreview::genMeshOptimizerPerModel(LLModel *base_model, LLModel *targe S32 buf_positions_copied = 0; S32 buf_indices_copied = 0; indices_idx_shift = 0; + S32 valid_faces = 0; // Crude method to copy indices back into face for (U32 face_idx = 0; face_idx < base_model->getNumVolumeFaces(); ++face_idx) @@ -1478,6 +1479,8 @@ F32 LLModelPreview::genMeshOptimizerPerModel(LLModel *base_model, LLModel *targe U32 tex_size = (buf_positions_copied * sizeof(LLVector2) + 0xF)&~0xF; LLVector4a::memcpyNonAliased16((F32*)new_face.mTexCoords, (F32*)buffer_tex_coords, tex_size); + + valid_faces++; } indices_idx_shift += face.mNumVertices; @@ -1490,7 +1493,7 @@ F32 LLModelPreview::genMeshOptimizerPerModel(LLModel *base_model, LLModel *targe ll_aligned_free_16(buffer_indices); ll_aligned_free_32(combined_indices); - if (new_indices < 3) + if (new_indices < 3 || valid_faces == 0) { // Model should have at least one visible triangle @@ -1734,7 +1737,7 @@ void LLModelPreview::genMeshOptimizerLODs(S32 which_lod, S32 meshopt_mode, U32 d // but combine all submodels with origin model as well if (model_meshopt_mode == MESH_OPTIMIZER_COMBINE) { - // Run meshoptimizer for each model/object, up to 8 faces in one model + // Run meshoptimizer for each model/object, up to 8 faces in one model. // Ideally this should run not per model, // but combine all submodels with origin model as well @@ -1748,15 +1751,6 @@ void LLModelPreview::genMeshOptimizerLODs(S32 which_lod, S32 meshopt_mode, U32 d } } } - - if (model_meshopt_mode == MESH_OPTIMIZER) - { - // Run meshoptimizer for each face - for (U32 face_idx = 0; face_idx < base->getNumVolumeFaces(); ++face_idx) - { - genMeshOptimizerPerFace(base, target_model, face_idx, indices_decimator, lod_error_threshold, false); - } - } if (model_meshopt_mode == MESH_OPTIMIZER_SLOPPY) { @@ -1765,10 +1759,15 @@ void LLModelPreview::genMeshOptimizerLODs(S32 which_lod, S32 meshopt_mode, U32 d { genMeshOptimizerPerFace(base, target_model, face_idx, indices_decimator, lod_error_threshold, true); } + + LL_INFOS() << "Model " << target_model->getName() + << " lod " << which_lod + << " simplified using per face method." << LL_ENDL; } if (model_meshopt_mode == MESH_OPTIMIZER_AUTO) { + // Switches between 'combine' method and 'per model sloppy' based on combine's result. F32 allowed_ratio_drift = 2.f; F32 res_ratio = genMeshOptimizerPerModel(base, target_model, indices_decimator, lod_error_threshold, false); @@ -1779,25 +1778,44 @@ void LLModelPreview::genMeshOptimizerLODs(S32 which_lod, S32 meshopt_mode, U32 d { genMeshOptimizerPerFace(base, target_model, face_idx, indices_decimator, lod_error_threshold, false); } - LL_INFOS() << "Model " << target_model->getName() - << " lod " << which_lod - << " per model method overflow, defaulting to per face." << LL_ENDL; } else if (res_ratio * allowed_ratio_drift < indices_decimator) { // Try sloppy variant if normal one failed to simplify model enough. res_ratio = genMeshOptimizerPerModel(base, target_model, indices_decimator, lod_error_threshold, true); - LL_INFOS() << "Model " << target_model->getName() - << " lod " << which_lod - << " sloppily simplified using per model method." << LL_ENDL; + + // Sloppy has a tendecy to error into lower side, so a request for 100 + // triangles turns into ~70, so check for significant difference from target decimation + F32 sloppy_ratio_drift = 1.4f; + if (lod_mode == LIMIT_TRIANGLES + && (res_ratio > indices_decimator * sloppy_ratio_drift || res_ratio < 0)) + { + // Apply a correction to compensate. + + // (indices_decimator / res_ratio) by itself is likely to overshoot to a differend + // side due to overal lack of precision, and we don't need an ideal result, which + // likely does not exist, just a better one, so a partial correction is enough. + F32 sloppy_decimator = indices_decimator * (indices_decimator / res_ratio + 1) / 2; + res_ratio = genMeshOptimizerPerModel(base, target_model, sloppy_decimator, lod_error_threshold, true); + } if (res_ratio < 0) { // Sloppy variant failed to generate triangles. // Can happen with models that are too simple as is. - // Fallback to normal method. + // Fallback to normal method or use lower decimator. genMeshOptimizerPerModel(base, target_model, indices_decimator, lod_error_threshold, false); + + LL_INFOS() << "Model " << target_model->getName() + << " lod " << which_lod + << " simplified using per model method." << LL_ENDL; + } + else + { + LL_INFOS() << "Model " << target_model->getName() + << " lod " << which_lod + << " sloppily simplified using per model method." << LL_ENDL; } } else diff --git a/indra/newview/llmodelpreview.h b/indra/newview/llmodelpreview.h index 7d4507ccf2..48d6d362eb 100644 --- a/indra/newview/llmodelpreview.h +++ b/indra/newview/llmodelpreview.h @@ -125,9 +125,8 @@ public: { LOD_FROM_FILE = 0, MESH_OPTIMIZER_AUTO, // automatically selects method based on model or face - MESH_OPTIMIZER_COMBINE, - MESH_OPTIMIZER, - MESH_OPTIMIZER_SLOPPY, + MESH_OPTIMIZER_COMBINE, // combines faces into a single model, simplifies, then splits back into faces + MESH_OPTIMIZER_SLOPPY, // uses sloppy method, works per face USE_LOD_ABOVE, } eLoDMode; @@ -226,8 +225,12 @@ private: // Count amount of original models, excluding sub-models static U32 countRootModels(LLModelLoader::model_list models); - // functions for meshoptimizer, return reached simplification ratio + // Merges faces into single mesh, simplifies using mesh optimizer, + // then splits back into faces. + // Returns reached simplification ratio. -1 in case of a failure. F32 genMeshOptimizerPerModel(LLModel *base_model, LLModel *target_model, F32 indices_ratio, F32 error_threshold, bool sloppy); + // Simplifies specified face using mesh optimizer. + // Returns reached simplification ratio. -1 in case of a failure. F32 genMeshOptimizerPerFace(LLModel *base_model, LLModel *target_model, U32 face_idx, F32 indices_ratio, F32 error_threshold, bool sloppy); protected: diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index b7d0e06116..8d6f4d2729 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -1140,6 +1140,10 @@ void LLOcclusionCullingGroup::checkOcclusion() #if LL_TRACK_PENDING_OCCLUSION_QUERIES sPendingQueries.erase(mOcclusionQuery[LLViewerCamera::sCurCameraID]); #endif + +#if 0 // (12/2021) occasional false-negative occlusion tests produce water reflection errors, SL-16461 + // If/when water occlusion queries become 100% reliable, re-enable this optimization + if (LLPipeline::RENDER_TYPE_WATER == mSpatialPartition->mDrawableType) { // Note any unoccluded water, for deciding on reflection/distortion passes @@ -1150,7 +1154,7 @@ void LLOcclusionCullingGroup::checkOcclusion() LLDrawPoolWater::sNeedsDistortionUpdate = TRUE; } } - +#endif if (query_result > 0) { clearOcclusionState(LLOcclusionCullingGroup::OCCLUDED, LLOcclusionCullingGroup::STATE_MODE_DIFF); diff --git a/indra/newview/skins/default/xui/en/floater_model_preview.xml b/indra/newview/skins/default/xui/en/floater_model_preview.xml index d08bc92e5d..f10cc61826 100644 --- a/indra/newview/skins/default/xui/en/floater_model_preview.xml +++ b/indra/newview/skins/default/xui/en/floater_model_preview.xml @@ -195,10 +195,6 @@ label="Generate Precise" value="MeshOptCombine" /> <item - name="MeshOpt" - label="Generate per face" - value="MeshOpt" /> - <item name="MeshOptSloppy" label="Generate Sloppy" value="MeshOptSloppy" /> @@ -336,10 +332,6 @@ label="Generate Precise" value="MeshOptCombine" /> <item - name="MeshOpt" - label="Generate per face" - value="MeshOpt" /> - <item name="MeshOptSloppy" label="Generate Sloppy" value="MeshOptSloppy" /> @@ -481,10 +473,6 @@ label="Generate Precise" value="MeshOptCombine" /> <item - name="MeshOpt" - label="Generate per face" - value="MeshOpt" /> - <item name="MeshOptSloppy" label="Generate Sloppy" value="MeshOptSloppy" /> @@ -626,10 +614,6 @@ label="Generate Precise" value="MeshOptCombine" /> <item - name="MeshOpt" - label="Generate per face" - value="MeshOpt" /> - <item name="MeshOptSloppy" label="Generate Sloppy" value="MeshOptSloppy" /> |