diff options
author | Cosmic Linden <cosmic@lindenlab.com> | 2024-03-20 10:22:29 -0700 |
---|---|---|
committer | Cosmic Linden <cosmic@lindenlab.com> | 2024-03-20 10:58:33 -0700 |
commit | a0649375e1652061610d626c958ee7488fad140d (patch) | |
tree | be61ce62a6c4c4c7550f92ce192f3fe7d151b9d7 /indra/newview | |
parent | e2a3edf6daed276d82767ce070dbbaf1d42dc427 (diff) |
secondlife/viewer-issues#83: Disallow alpha blend/double sided from PBR terrain
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llfloaterregioninfo.cpp | 62 | ||||
-rw-r--r-- | indra/newview/llfloaterregioninfo.h | 1 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/notifications.xml | 40 |
3 files changed, 103 insertions, 0 deletions
diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 706f7cf943..65b4feba11 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -1392,6 +1392,62 @@ BOOL LLPanelRegionTerrainInfo::validateTextureSizes() return TRUE; } +bool LLPanelRegionTerrainInfo::validateMaterials() +{ + if (mMaterialTypeCtrl) + { + const LLTerrainMaterials::Type material_type = material_type_from_ctrl(mMaterialTypeCtrl); + const bool is_texture_selected = material_type == LLTerrainMaterials::Type::TEXTURE; + if (is_texture_selected) { return true; } + } + + for (S32 i = 0; i < LLTerrainMaterials::ASSET_COUNT; ++i) + { + LLTextureCtrl* material_ctrl = mMaterialDetailCtrl[i]; + if (!material_ctrl) { continue; } + + const LLUUID& material_asset_id = material_ctrl->getImageAssetID(); + llassert(material_asset_id.notNull()); + if (material_asset_id.isNull()) { return false; } + const LLFetchedGLTFMaterial* material = gGLTFMaterialList.getMaterial(material_asset_id); + if (!material->isLoaded()) + { + if (material->isFetching()) + { + LLSD args; + args["MATERIAL_NUM"] = i + 1; + LLNotificationsUtil::add("InvalidTerrainMaterialNotLoaded", args); + } + else // Loading failed + { + LLSD args; + args["MATERIAL_NUM"] = i + 1; + LLNotificationsUtil::add("InvalidTerrainMaterialLoadFailed", args); + } + return false; + } + + if (material->mDoubleSided) + { + LLSD args; + args["MATERIAL_NUM"] = i + 1; + LLNotificationsUtil::add("InvalidTerrainMaterialDoubleSided", args); + return false; + } + if (material->mAlphaMode != LLGLTFMaterial::ALPHA_MODE_OPAQUE && material->mAlphaMode != LLGLTFMaterial::ALPHA_MODE_MASK) + { + LLSD args; + args["MATERIAL_NUM"] = i + 1; + const char* alpha_mode = material->getAlphaMode(); + args["MATERIAL_ALPHA_MODE"] = alpha_mode; + LLNotificationsUtil::add("InvalidTerrainMaterialAlphaMode", args); + return false; + } + } + + return true; +} + BOOL LLPanelRegionTerrainInfo::validateTextureHeights() { for (S32 i = 0; i < CORNER_COUNT; ++i) @@ -1668,6 +1724,12 @@ BOOL LLPanelRegionTerrainInfo::sendUpdate() return FALSE; } + // Prevent applying unsupported alpha blend/double-sided materials + if (!validateMaterials()) + { + return FALSE; + } + // Check if terrain Elevation Ranges are correct if (gSavedSettings.getBOOL("RegionCheckTextureHeights") && !validateTextureHeights()) { diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h index 99774e5db3..ac3a8fc717 100644 --- a/indra/newview/llfloaterregioninfo.h +++ b/indra/newview/llfloaterregioninfo.h @@ -254,6 +254,7 @@ public: void setEnvControls(bool available); // Whether environment settings are available for this region BOOL validateTextureSizes(); + bool validateMaterials(); BOOL validateTextureHeights(); //static void onChangeAnything(LLUICtrl* ctrl, void* userData); // callback for any change, to enable commit button diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index c1e6e7b9f0..44807aa6c7 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -4046,6 +4046,46 @@ Replace texture [TEXTURE_NUM] with an RGB [MAX_SIZE]x[MAX_SIZE] or smaller image <notification icon="alertmodal.tga" + name="InvalidTerrainMaterialNotLoaded" + type="alertmodal"> +Couldn't set region materials: +Terrain material [MATERIAL_NUM] is not loaded. + +Wait for the material to load, or replace material [TEXTURE_NUM] with a valid material. + </notification> + + <notification + icon="alertmodal.tga" + name="InvalidTerrainMaterialLoadFailed" + type="alertmodal"> +Couldn't set region materials: +Terrain material [MATERIAL_NUM] failed to load. + +Replace material [TEXTURE_NUM] with a valid material. + </notification> + + <notification + icon="alertmodal.tga" + name="InvalidTerrainMaterialDoubleSided" + type="alertmodal"> +Couldn't set region materials: +Terrain material [MATERIAL_NUM] is double-sided. Double-sided materials are not currently supported for PBR terrain. + +Replace material [MATERIAL_NUM] with a material with doubleSided=false. + </notification> + + <notification + icon="alertmodal.tga" + name="InvalidTerrainMaterialAlphaMode" + type="alertmodal"> +Couldn't set region materials: +Terrain material [MATERIAL_NUM] is using the unsupported alphaMode="[MATERIAL_ALPHA_MODE]". + +Replace material [MATERIAL_NUM] with a material with alphaMode="OPAQUE" or alphaMode="MASK". + </notification> + + <notification + icon="alertmodal.tga" name="RawUploadStarted" type="alertmodal"> Upload started. It may take up to two minutes, depending on your connection speed. |