diff options
author | Ptolemy <ptolemy@lindenlab.com> | 2022-09-02 00:00:58 -0700 |
---|---|---|
committer | Ptolemy <ptolemy@lindenlab.com> | 2022-09-02 00:00:58 -0700 |
commit | 44f1aed84cda3158c19573205ce25d69d632b29a (patch) | |
tree | 310497e0a116f6c5d39212d1f30535c512909144 /indra | |
parent | d9d33c15973550efdb428a165aacd3ccdd7cc14f (diff) | |
parent | e15982eb55c03e53f669eb91715cf2aa7d32998c (diff) |
Merge branch 'DRTVWR-559' of bitbucket.org:lindenlab/viewer into DRTVWR-559
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llcommon/llqueuedthread.cpp | 2 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl | 2 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 4 | ||||
-rw-r--r-- | indra/newview/llappviewer.cpp | 1 | ||||
-rw-r--r-- | indra/newview/lldrawpoolsky.cpp | 5 | ||||
-rw-r--r-- | indra/newview/llmaterialeditor.cpp | 15 | ||||
-rw-r--r-- | indra/newview/llpanelface.cpp | 468 | ||||
-rw-r--r-- | indra/newview/llpanelface.h | 14 | ||||
-rw-r--r-- | indra/newview/llreflectionmapmanager.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llselectmgr.cpp | 83 | ||||
-rw-r--r-- | indra/newview/llselectmgr.h | 1 | ||||
-rw-r--r-- | indra/newview/lltexturectrl.cpp | 164 | ||||
-rw-r--r-- | indra/newview/lltexturectrl.h | 23 | ||||
-rw-r--r-- | indra/newview/llviewertexturelist.cpp | 11 | ||||
-rw-r--r-- | indra/newview/llviewertexturelist.h | 2 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_texture_ctrl.xml | 127 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/panel_tools_texture.xml | 48 |
17 files changed, 590 insertions, 382 deletions
diff --git a/indra/llcommon/llqueuedthread.cpp b/indra/llcommon/llqueuedthread.cpp index 155e32ebae..e5060a1076 100644 --- a/indra/llcommon/llqueuedthread.cpp +++ b/indra/llcommon/llqueuedthread.cpp @@ -146,7 +146,7 @@ S32 LLQueuedThread::updateQueue(F32 max_time_ms) // schedule a call to threadedUpdate for every call to updateQueue if (!isQuitting()) { - mRequestQueue.post([=]() + mRequestQueue.postIfOpen([=]() { LL_PROFILE_ZONE_NAMED_CATEGORY_THREAD("qt - update"); mIdleThread = FALSE; diff --git a/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl index 4d91395a1b..4681fa1abd 100644 --- a/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl @@ -79,7 +79,7 @@ void main() vec3 N = normalize(vary_dir); vec3 up = vec3(0.0, 1.0, 0.0); vec3 right = normalize(cross(up, N)); - up = cross(N, right); + up = normalize(cross(N, right)); const float TWO_PI = PI * 2.0; const float HALF_PI = PI * 0.5; diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 85bb9fbbd1..e6017534ca 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -335,7 +335,6 @@ void main() #if PBR_USE_IRRADIANCE_HACK irradiance = max(amblit,irradiance) * ambocc; #endif - specLight = srgb_to_linear(specLight); #if DEBUG_PBR_SPECLIGHT051 specLight = vec3(0,0.5,1.0); irradiance = specLight; @@ -670,6 +669,9 @@ else diffuse.rgb = linear_to_srgb(diffuse.rgb); // SL-14035 sampleReflectionProbes(ambenv, glossenv, legacyenv, pos.xyz, norm.xyz, spec.a, envIntensity); + ambenv.rgb = linear_to_srgb(ambenv.rgb); + glossenv.rgb = linear_to_srgb(glossenv.rgb); + legacyenv.rgb = linear_to_srgb(legacyenv.rgb); amblit = max(ambenv, amblit); color.rgb = amblit*ambocc; diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 6ca35684d9..54f189625e 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -2071,6 +2071,7 @@ bool LLAppViewer::cleanup() if (sTextureFetch) { sTextureFetch->shutdown(); + sTextureFetch->waitOnPending(); delete sTextureFetch; sTextureFetch = NULL; } diff --git a/indra/newview/lldrawpoolsky.cpp b/indra/newview/lldrawpoolsky.cpp index 3a1efec91b..55ebf03adc 100644 --- a/indra/newview/lldrawpoolsky.cpp +++ b/indra/newview/lldrawpoolsky.cpp @@ -51,7 +51,10 @@ LLDrawPoolSky::LLDrawPoolSky() void LLDrawPoolSky::prerender() { mShaderLevel = LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_ENVIRONMENT); - gSky.mVOSkyp->updateGeometry(gSky.mVOSkyp->mDrawable); + if (gSky.mVOSkyp->mDrawable) + { + gSky.mVOSkyp->updateGeometry(gSky.mVOSkyp->mDrawable); + } } void LLDrawPoolSky::render(S32 pass) diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index f05f0344bd..5acf0600b6 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -1059,24 +1059,39 @@ static void pack_textures( LLPointer<LLImageJ2C>& mr_j2c, LLPointer<LLImageJ2C>& emissive_j2c) { + // NOTE : remove log spam and lossless vs lossy comparisons when the logs are no longer useful + if (albedo_img) { albedo_j2c = LLViewerTextureList::convertToUploadFile(albedo_img); + LL_INFOS() << "Albedo: " << albedo_j2c->getDataSize() << LL_ENDL; } if (normal_img) { normal_j2c = LLViewerTextureList::convertToUploadFile(normal_img); + + LLPointer<LLImageJ2C> test; + test = LLViewerTextureList::convertToUploadFile(normal_img, 1024, true); + + S32 lossy_bytes = normal_j2c->getDataSize(); + S32 lossless_bytes = test->getDataSize(); + + LL_INFOS() << llformat("Lossless vs Lossy: (%d/%d) = %.2f", lossless_bytes, lossy_bytes, (F32)lossless_bytes / lossy_bytes) << LL_ENDL; + + normal_j2c = test; } if (mr_img) { mr_j2c = LLViewerTextureList::convertToUploadFile(mr_img); + LL_INFOS() << "Metallic/Roughness: " << mr_j2c->getDataSize() << LL_ENDL; } if (emissive_img) { emissive_j2c = LLViewerTextureList::convertToUploadFile(emissive_img); + LL_INFOS() << "Emissive: " << emissive_j2c->getDataSize() << LL_ENDL; } } diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 865529eb8f..9300b161f4 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -93,13 +93,15 @@ // Must match the commbobox definitions in panel_tools_texture.xml // const S32 MATMEDIA_MATERIAL = 0; // Material -const S32 MATMEDIA_MEDIA = 1; // Media +const S32 MATMEDIA_PBR = 1; // PBR +const S32 MATMEDIA_MEDIA = 2; // Media const S32 MATTYPE_DIFFUSE = 0; // Diffuse material texture const S32 MATTYPE_NORMAL = 1; // Normal map const S32 MATTYPE_SPECULAR = 2; // Specular map const S32 ALPHAMODE_MASK = 2; // Alpha masking mode const S32 BUMPY_TEXTURE = 18; // use supplied normal map const S32 SHINY_TEXTURE = 4; // use supplied specular map +const S32 PBRTYPE_ALBEDO = 0; // PBR ALBEDO BOOST_STATIC_ASSERT(MATTYPE_DIFFUSE == LLRender::DIFFUSE_MAP && MATTYPE_NORMAL == LLRender::NORMAL_MAP && MATTYPE_SPECULAR == LLRender::SPECULAR_MAP); @@ -142,7 +144,6 @@ F32 LLPanelFace::getCurrentShinyScaleU() { return getChild<LLUICtrl>("shinySca F32 LLPanelFace::getCurrentShinyScaleV() { return getChild<LLUICtrl>("shinyScaleV")->getValue().asReal(); } F32 LLPanelFace::getCurrentShinyOffsetU() { return getChild<LLUICtrl>("shinyOffsetU")->getValue().asReal(); } F32 LLPanelFace::getCurrentShinyOffsetV() { return getChild<LLUICtrl>("shinyOffsetV")->getValue().asReal(); } -LLUUID LLPanelFace::getCurrentMaterialID() { return getChild<LLUICtrl>("materialID")->getValue().asUUID(); } // // Methods @@ -174,7 +175,6 @@ BOOL LLPanelFace::postBuild() childSetCommitCallback("glossiness",&LLPanelFace::onCommitMaterialGloss, this); childSetCommitCallback("environment",&LLPanelFace::onCommitMaterialEnv, this); childSetCommitCallback("maskcutoff",&LLPanelFace::onCommitMaterialMaskCutoff, this); - childSetCommitCallback("materialID", &LLPanelFace::onCommitMaterialID, this); childSetAction("button align",&LLPanelFace::onClickAutoFix,this); childSetAction("button align textures", &LLPanelFace::onAlignTexture, this); @@ -197,6 +197,25 @@ BOOL LLPanelFace::postBuild() setMouseOpaque(FALSE); + LLTextureCtrl* pbr_ctrl = getChild<LLTextureCtrl>("pbr_control"); + if (pbr_ctrl) + { + pbr_ctrl->setDefaultImageAssetID(LLUUID(gSavedSettings.getString("DefaultObjectTexture"))); + pbr_ctrl->setCommitCallback(boost::bind(&LLPanelFace::onCommitPbr, this, _2)); + pbr_ctrl->setOnCancelCallback(boost::bind(&LLPanelFace::onCancelPbr, this, _2)); + pbr_ctrl->setOnSelectCallback(boost::bind(&LLPanelFace::onSelectPbr, this, _2)); + pbr_ctrl->setDragCallback(boost::bind(&LLPanelFace::onDragPbr, this, _2)); + pbr_ctrl->setOnTextureSelectedCallback(boost::bind(&LLPanelFace::onPbrSelectionChanged, this, _1)); + pbr_ctrl->setOnCloseCallback(boost::bind(&LLPanelFace::onCloseTexturePicker, this, _2)); + + pbr_ctrl->setFollowsTop(); + pbr_ctrl->setFollowsLeft(); + pbr_ctrl->setImmediateFilterPermMask(PERM_NONE); + pbr_ctrl->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER); + pbr_ctrl->setBakeTextureEnabled(false); + pbr_ctrl->setInventoryPickType(LLTextureCtrl::PICK_MATERIAL); + } + mTextureCtrl = getChild<LLTextureCtrl>("texture control"); if(mTextureCtrl) { @@ -314,6 +333,13 @@ BOOL LLPanelFace::postBuild() radio_mat_type->selectNthItem(MATTYPE_DIFFUSE); } + LLRadioGroup* radio_pbr_type = getChild<LLRadioGroup>("radio_pbr_type"); + if (radio_mat_type) + { + radio_pbr_type->setCommitCallback(LLPanelFace::onCommitPbrType, this); + radio_pbr_type->selectNthItem(PBRTYPE_ALBEDO); + } + mCtrlGlow = getChild<LLSpinCtrl>("glow"); if(mCtrlGlow) { @@ -852,7 +878,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) { LL_WARNS() << "failed getChild for 'combobox matmedia'" << LL_ENDL; } - getChildView("combobox matmedia")->setEnabled(editable); + combobox_matmedia->setEnabled(editable); LLRadioGroup* radio_mat_type = getChild<LLRadioGroup>("radio_material_type"); if(radio_mat_type) @@ -869,14 +895,31 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) } getChildView("radio_material_type")->setEnabled(editable); + getChildView("radio_pbr_type")->setEnabled(editable); getChildView("checkbox_sync_settings")->setEnabled(editable); childSetValue("checkbox_sync_settings", gSavedSettings.getBOOL("SyncMaterialSettings")); updateVisibility(); bool identical = true; // true because it is anded below - bool identical_diffuse = false; - bool identical_norm = false; - bool identical_spec = false; + bool identical_diffuse = false; + bool identical_norm = false; + bool identical_spec = false; + + // pbr material + bool is_pbr_material = false; + LLTextureCtrl* pbr_ctrl = getChild<LLTextureCtrl>("pbr_control"); + if (pbr_ctrl) + { + LLUUID pbr_id; + bool identical_pbr; + LLSelectedTE::getPbrMaterialId(pbr_id, identical_pbr); + identical &= identical_pbr; + + pbr_ctrl->setTentative(identical_pbr ? FALSE : TRUE); + pbr_ctrl->setEnabled(editable); + pbr_ctrl->setImageAssetID(pbr_id); + is_pbr_material = pbr_id.notNull(); + } LLTextureCtrl* texture_ctrl = getChild<LLTextureCtrl>("texture control"); LLTextureCtrl* shinytexture_ctrl = getChild<LLTextureCtrl>("shinytexture control"); @@ -888,7 +931,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) // Color swatch { - getChildView("color label")->setEnabled(editable); + getChildView("color label")->setEnabled(editable && !is_pbr_material); } LLColorSwatchCtrl* mColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch"); @@ -903,17 +946,17 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) mColorSwatch->setOriginal(color); mColorSwatch->set(color, force_set_values || (prev_color != color) || !editable); - mColorSwatch->setValid(editable); - mColorSwatch->setEnabled( editable ); + mColorSwatch->setValid(editable && !is_pbr_material); + mColorSwatch->setEnabled(editable && !is_pbr_material); mColorSwatch->setCanApplyImmediately( editable ); } // Color transparency - getChildView("color trans")->setEnabled(editable); + getChildView("color trans")->setEnabled(editable && !is_pbr_material); F32 transparency = (1.f - color.mV[VALPHA]) * 100.f; getChild<LLUICtrl>("ColorTrans")->setValue(editable ? transparency : 0); - getChildView("ColorTrans")->setEnabled(editable); + getChildView("ColorTrans")->setEnabled(editable && !is_pbr_material); // Specular map LLSelectedTEMaterial::getSpecularID(specmap_id, identical_spec); @@ -958,7 +1001,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) U8 bumpy = 0; // Bumpy - { + { bool identical_bumpy = false; LLSelectedTE::getBumpmap(bumpy,identical_bumpy); @@ -979,7 +1022,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) getChildView("combobox bumpiness")->setEnabled(editable); getChild<LLUICtrl>("combobox bumpiness")->setTentative(!identical_bumpy); getChildView("label bumpiness")->setEnabled(editable); - } + } // Texture { @@ -1333,8 +1376,8 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) LLSelectedTE::getGlow(glow,identical_glow); getChild<LLUICtrl>("glow")->setValue(glow); getChild<LLUICtrl>("glow")->setTentative(!identical_glow); - getChildView("glow")->setEnabled(editable); - getChildView("glow label")->setEnabled(editable); + getChildView("glow")->setEnabled(editable && !is_pbr_material); + getChildView("glow label")->setEnabled(editable && !is_pbr_material); } { @@ -1441,10 +1484,6 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) LLMaterialPtr material; LLSelectedTEMaterial::getCurrent(material, identical); - // enable this UI box if a single face is selected. - BOOL is_single_face = !LLSelectMgr::getInstance()->getSelection()->isMultipleTESelected(); - childSetEnabled("materialID", static_cast<bool>(is_single_face)); // doesn't work - why? - if (material && editable) { LL_DEBUGS("Materials") << material->asLLSD() << LL_ENDL; @@ -1557,8 +1596,6 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) calcp->setVar(LLCalc::TEX_ROTATION, childGetValue("TexRot").asReal()); calcp->setVar(LLCalc::TEX_TRANSPARENCY, childGetValue("ColorTrans").asReal()); calcp->setVar(LLCalc::TEX_GLOW, childGetValue("glow").asReal()); - - getChildView("materialID")->setEnabled(editable); } else { @@ -1566,6 +1603,12 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) clearCtrls(); // Disable non-UICtrls + LLTextureCtrl* pbr_ctrl = getChild<LLTextureCtrl>("pbr_control"); + if (pbr_ctrl) + { + pbr_ctrl->setImageAssetID(LLUUID::null); + pbr_ctrl->setEnabled(FALSE); + } LLTextureCtrl* texture_ctrl = getChild<LLTextureCtrl>("texture control"); if(texture_ctrl) { @@ -1701,10 +1744,12 @@ void LLPanelFace::updateVisibility() U32 materials_media = combo_matmedia->getCurrentIndex(); U32 material_type = radio_mat_type->getSelectedIndex(); bool show_media = (materials_media == MATMEDIA_MEDIA) && combo_matmedia->getEnabled(); - bool show_texture = (show_media || ((material_type == MATTYPE_DIFFUSE) && combo_matmedia->getEnabled())); - bool show_bumpiness = (!show_media) && (material_type == MATTYPE_NORMAL) && combo_matmedia->getEnabled(); - bool show_shininess = (!show_media) && (material_type == MATTYPE_SPECULAR) && combo_matmedia->getEnabled(); - getChildView("radio_material_type")->setVisible(!show_media); + bool show_material = materials_media == MATMEDIA_MATERIAL; + bool show_pbr = materials_media == MATMEDIA_PBR; + bool show_texture = (show_media || (show_material && (material_type == MATTYPE_DIFFUSE) && combo_matmedia->getEnabled())); + bool show_bumpiness = show_material && (material_type == MATTYPE_NORMAL) && combo_matmedia->getEnabled(); + bool show_shininess = show_material && (material_type == MATTYPE_SPECULAR) && combo_matmedia->getEnabled(); + getChildView("radio_material_type")->setVisible(show_texture); // Media controls getChildView("media_info")->setVisible(show_media); @@ -1713,20 +1758,20 @@ void LLPanelFace::updateVisibility() getChildView("button align")->setVisible(show_media); // Diffuse texture controls - getChildView("texture control")->setVisible(show_texture && !show_media); - getChildView("label alphamode")->setVisible(show_texture && !show_media); - getChildView("combobox alphamode")->setVisible(show_texture && !show_media); + getChildView("texture control")->setVisible(show_texture && show_material); + getChildView("label alphamode")->setVisible(show_texture && (show_material || show_pbr)); + getChildView("combobox alphamode")->setVisible(show_texture && (show_material || show_pbr)); getChildView("label maskcutoff")->setVisible(false); getChildView("maskcutoff")->setVisible(false); - if (show_texture && !show_media) + if (show_texture && show_material) { updateAlphaControls(); } - getChildView("TexScaleU")->setVisible(show_texture); - getChildView("TexScaleV")->setVisible(show_texture); - getChildView("TexRot")->setVisible(show_texture); - getChildView("TexOffsetU")->setVisible(show_texture); - getChildView("TexOffsetV")->setVisible(show_texture); + getChildView("TexScaleU")->setVisible(show_texture || show_pbr); + getChildView("TexScaleV")->setVisible(show_texture || show_pbr); + getChildView("TexRot")->setVisible(show_texture || show_pbr); + getChildView("TexOffsetU")->setVisible(show_texture || show_pbr); + getChildView("TexOffsetV")->setVisible(show_texture || show_pbr); // Specular map controls getChildView("shinytexture control")->setVisible(show_shininess); @@ -1762,7 +1807,9 @@ void LLPanelFace::updateVisibility() getChildView("bumpyOffsetU")->setVisible(show_bumpiness); getChildView("bumpyOffsetV")->setVisible(show_bumpiness); - + // PBR controls + getChildView("pbr_control")->setVisible(show_pbr); + getChildView("radio_pbr_type")->setVisible(show_pbr); } // static @@ -1778,6 +1825,16 @@ void LLPanelFace::onCommitMaterialType(LLUICtrl* ctrl, void* userdata) } // static +void LLPanelFace::onCommitPbrType(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*)userdata; + // Force to default states to side-step problems with menu contents + // and generally reflecting old state when switching tabs or objects + // + self->updateUI(); +} + +// static void LLPanelFace::onCommitBump(LLUICtrl* ctrl, void* userdata) { LLPanelFace* self = (LLPanelFace*) userdata; @@ -1843,8 +1900,8 @@ void LLPanelFace::updateShinyControls(bool is_setting_texture, bool mess_with_sh LLRadioGroup* radio_mat_type = getChild<LLRadioGroup>("radio_material_type"); U32 materials_media = combo_matmedia->getCurrentIndex(); U32 material_type = radio_mat_type->getSelectedIndex(); - bool show_media = (materials_media == MATMEDIA_MEDIA) && combo_matmedia->getEnabled(); - bool show_shininess = (!show_media) && (material_type == MATTYPE_SPECULAR) && combo_matmedia->getEnabled(); + bool show_material = (materials_media == MATMEDIA_MATERIAL); + bool show_shininess = show_material && (material_type == MATTYPE_SPECULAR) && combo_matmedia->getEnabled(); U32 shiny_value = comboShiny->getCurrentIndex(); bool show_shinyctrls = (shiny_value == SHINY_TEXTURE) && show_shininess; // Use texture getChildView("label glossiness")->setVisible(show_shinyctrls); @@ -1962,21 +2019,81 @@ void LLPanelFace::onCommitGlow(LLUICtrl* ctrl, void* userdata) } // static +BOOL LLPanelFace::onDragPbr(LLUICtrl*, LLInventoryItem* item) +{ + BOOL accept = TRUE; + for (LLObjectSelection::root_iterator iter = LLSelectMgr::getInstance()->getSelection()->root_begin(); + iter != LLSelectMgr::getInstance()->getSelection()->root_end(); iter++) + { + LLSelectNode* node = *iter; + LLViewerObject* obj = node->getObject(); + if (!LLToolDragAndDrop::isInventoryDropAcceptable(obj, item)) + { + accept = FALSE; + break; + } + } + return accept; +} + +void LLPanelFace::onCommitPbr(const LLSD& data) +{ + LLTextureCtrl* pbr_ctrl = findChild<LLTextureCtrl>("pbr_control"); + if (!pbr_ctrl) return; + if (!pbr_ctrl->getTentative()) + { + // we grab the item id first, because we want to do a + // permissions check in the selection manager. ARGH! + LLUUID id = pbr_ctrl->getImageItemID(); + if (id.isNull()) + { + id = pbr_ctrl->getImageAssetID(); + } + LLSelectMgr::getInstance()->selectionSetGLTFMaterial(id); + } +} + +void LLPanelFace::onCancelPbr(const LLSD& data) +{ + LLSelectMgr::getInstance()->selectionRevertGLTFMaterials(); +} + +void LLPanelFace::onSelectPbr(const LLSD& data) +{ + LLSelectMgr::getInstance()->saveSelectedObjectTextures(); + + LLTextureCtrl* pbr_ctrl = getChild<LLTextureCtrl>("pbr_control"); + if (!pbr_ctrl) return; + if (!pbr_ctrl->getTentative()) + { + // we grab the item id first, because we want to do a + // permissions check in the selection manager. ARGH! + LLUUID id = pbr_ctrl->getImageItemID(); + if (id.isNull()) + { + id = pbr_ctrl->getImageAssetID(); + } + LLSelectMgr::getInstance()->selectionSetGLTFMaterial(id); + LLSelectedTEMaterial::setMaterialID(this, id); + } +} + +// static BOOL LLPanelFace::onDragTexture(LLUICtrl*, LLInventoryItem* item) { - BOOL accept = TRUE; - for (LLObjectSelection::root_iterator iter = LLSelectMgr::getInstance()->getSelection()->root_begin(); - iter != LLSelectMgr::getInstance()->getSelection()->root_end(); iter++) - { - LLSelectNode* node = *iter; - LLViewerObject* obj = node->getObject(); - if(!LLToolDragAndDrop::isInventoryDropAcceptable(obj, item)) - { - accept = FALSE; - break; - } - } - return accept; + BOOL accept = TRUE; + for (LLObjectSelection::root_iterator iter = LLSelectMgr::getInstance()->getSelection()->root_begin(); + iter != LLSelectMgr::getInstance()->getSelection()->root_end(); iter++) + { + LLSelectNode* node = *iter; + LLViewerObject* obj = node->getObject(); + if (!LLToolDragAndDrop::isInventoryDropAcceptable(obj, item)) + { + accept = FALSE; + break; + } + } + return accept; } void LLPanelFace::onCommitTexture( const LLSD& data ) @@ -2354,17 +2471,6 @@ void LLPanelFace::onCommitMaterialMaskCutoff(LLUICtrl* ctrl, void* userdata) LLSelectedTEMaterial::setAlphaMaskCutoff(self,self->getCurrentAlphaMaskCutoff()); } -//static -void LLPanelFace::onCommitMaterialID(LLUICtrl* ctrl, void* userdata) -{ - LLPanelFace* self = static_cast<LLPanelFace*>(userdata); - LLUUID matID = self->getCurrentMaterialID(); - LLSelectedTEMaterial::setMaterialID(self, matID); - - // Temporary demo hack - replace the TE entries with those from the Material's LLSD - applyMaterialUUID(matID, userdata); -} - // static void LLPanelFace::onCommitTextureInfo( LLUICtrl* ctrl, void* userdata ) { @@ -3474,6 +3580,39 @@ void LLPanelFace::onTextureSelectionChanged(LLInventoryItem* itemp) } } +void LLPanelFace::onPbrSelectionChanged(LLInventoryItem* itemp) +{ + LLTextureCtrl* pbr_ctrl = getChild<LLTextureCtrl>("pbr_control"); + if (pbr_ctrl) + { + LLUUID obj_owner_id; + std::string obj_owner_name; + LLSelectMgr::instance().selectGetOwner(obj_owner_id, obj_owner_name); + + LLSaleInfo sale_info; + LLSelectMgr::instance().selectGetSaleInfo(sale_info); + + bool can_copy = itemp->getPermissions().allowCopyBy(gAgentID); // do we have perm to copy this texture? + bool can_transfer = itemp->getPermissions().allowOperationBy(PERM_TRANSFER, gAgentID); // do we have perm to transfer this texture? + bool is_object_owner = gAgentID == obj_owner_id; // does object for which we are going to apply texture belong to the agent? + bool not_for_sale = !sale_info.isForSale(); // is object for which we are going to apply texture not for sale? + + if (can_copy && can_transfer) + { + pbr_ctrl->setCanApply(true, true); + return; + } + + // if texture has (no-transfer) attribute it can be applied only for object which we own and is not for sale + pbr_ctrl->setCanApply(false, can_transfer ? true : is_object_owner && not_for_sale); + + if (gSavedSettings.getBOOL("TextureLivePreview")) + { + LLNotificationsUtil::add("LivePreviewUnavailable"); + } + } +} + bool LLPanelFace::isIdenticalPlanarTexgen() { LLTextureEntry::e_texgen selected_texgen = LLTextureEntry::TEX_GEN_DEFAULT; @@ -3553,6 +3692,18 @@ void LLPanelFace::LLSelectedTE::getTexId(LLUUID& id, bool& identical) identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, id ); } +void LLPanelFace::LLSelectedTE::getPbrMaterialId(LLUUID& id, bool& identical) +{ + struct LLSelectedTEGetmatId : public LLSelectedTEGetFunctor<LLUUID> + { + LLUUID get(LLViewerObject* object, S32 te_index) + { + return object->getRenderMaterialID(te_index); + } + } func; + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&func, id); +} + void LLPanelFace::LLSelectedTEMaterial::getCurrent(LLMaterialPtr& material_ptr, bool& identical_material) { struct MaterialFunctor : public LLSelectedTEGetFunctor<LLMaterialPtr> @@ -3692,196 +3843,3 @@ void LLPanelFace::LLSelectedTE::getMaxDiffuseRepeats(F32& repeats, bool& identic identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &max_diff_repeats_func, repeats ); } - -void LLPanelFace::onSaveMaterial(void* userdata) -{ - // DRTVWR-559, Q&D material picker - save to inventory goes here - LL_DEBUGS("Material") << "saving render material to inventory" << LL_ENDL; - - std::string name = "New Material"; - - LLSD material_data = llsd::map( - "version", "1", - "material", LLSD::emptyMap() - ); - - // gen a new uuid for this asset - LLTransactionID tid; - tid.generate(); // timestamp-based randomization + uniquification - LLAssetID new_asset_id = tid.makeAssetID(gAgent.getSecureSessionID()); - - material_data["material"] = renderMaterialToLLSD(new_asset_id, userdata); - std::stringstream output; - LLSDSerialize::toNotation(material_data, output); - - //S32 expected_upload_cost = 0;// LLAgentBenefitsMgr::current().getTextureUploadCost(); - - std::string res_name = name; - std::string res_desc = "Saved Material"; - //LLFolderType::EType folder_type = LLFolderType::FT_MATERIAL; - //LLInventoryType::EType inv_type = LLInventoryType::IT_MATERIAL; - U32 next_owner_perm = LLPermissions::DEFAULT.getMaskNextOwner(); - - LLUUID parent = gInventory.findCategoryUUIDForType(LLFolderType::FT_MATERIAL); - const U8 subtype = NO_INV_SUBTYPE; // TODO maybe use AT_SETTINGS and LLSettingsType::ST_MATERIAL ? - - create_inventory_item(gAgent.getID(), gAgent.getSessionID(), parent, tid, res_name, res_desc, - LLAssetType::AT_MATERIAL, LLInventoryType::IT_MATERIAL, subtype, next_owner_perm, - new LLBoostFuncInventoryCallback([output=output.str()](LLUUID const & inv_item_id){ - // from reference in LLSettingsVOBase::createInventoryItem()/updateInventoryItem() - LLResourceUploadInfo::ptr_t uploadInfo = - std::make_shared<LLBufferedAssetUploadInfo>( - inv_item_id, - LLAssetType::AT_SETTINGS, // TODO switch to AT_MATERIAL - output, - [](LLUUID item_id, LLUUID new_asset_id, LLUUID new_item_id, LLSD response) { - LL_INFOS("Material") << "inventory item uploaded. item: " << item_id << " asset: " << new_asset_id << " new_item_id: " << new_item_id << " response: " << response << LL_ENDL; - LLSD params = llsd::map("ASSET_ID", new_asset_id); - LLNotificationsUtil::add("MaterialCreated", params); - }); - - const LLViewerRegion* region = gAgent.getRegion(); - if (region) - { - std::string agent_url(region->getCapability("UpdateSettingsAgentInventory")); - if (agent_url.empty()) - { - LL_ERRS() << "missing required agent inventory cap url" << LL_ENDL; - } - LLViewerAssetUpload::EnqueueInventoryUpload(agent_url, uploadInfo); - } - }) - ); - -} - -// Fill an LLSD with data describing the current face's texture settings -// TODO 2022-05 FUBAR there are both colliding and different data in LLPanelFace vs the TE. Also, neither one has the diffuse tex settings. -// -LLSD LLPanelFace::renderMaterialToLLSD(LLUUID uuid, void* userdata) -{ - llassert(userdata != nullptr); - - LLSD sd; - - sd.insert("RenderMaterialUUID", LLSD(uuid)); - - // now pull same data from the selected TE (same but different. W T F?) - LLMaterialPtr mat = nullptr; - bool ident; // ? - LLSelectedTEMaterial::getCurrent(mat, ident); - - if (mat) - { - sd.insert("teMaterialID", LLSD(mat->getMaterialID())); - - sd.insert("teNormalMap", LLSD(mat->getNormalID())); - sd.insert("teNormalOffsetX", LLSD(mat->getNormalOffsetX())); - sd.insert("teNormalOffsetY", LLSD(mat->getNormalOffsetY())); - sd.insert("teNormalRepeatX", LLSD(mat->getNormalRepeatX())); - sd.insert("teNormalRepeatY", LLSD(mat->getNormalRepeatY())); - sd.insert("teNormalRotation", LLSD(mat->getNormalRotation())); - - sd.insert("teSpecularMap", LLSD(mat->getSpecularID())); - LLColor4U color = mat->getSpecularLightColor(); - - sd.insert("teSpecularColorR", LLSD(static_cast<S32>(color.mV[0]))); - sd.insert("teSpecularColorG", LLSD(static_cast<S32>(color.mV[1]))); - sd.insert("teSpecularColorB", LLSD(static_cast<S32>(color.mV[2]))); - sd.insert("teSpecularColorA", LLSD(static_cast<S32>(color.mV[3]))); - sd.insert("teSpecularExponent", LLSD(static_cast<S32>(mat->getSpecularLightExponent()))); - sd.insert("teSpecularOffsetX", LLSD(mat->getSpecularOffsetX())); - sd.insert("teSpecularOffsetY", LLSD(mat->getSpecularOffsetY())); - sd.insert("teSpecularRepeatX", LLSD(mat->getSpecularRepeatX())); - sd.insert("teSpecularRepeatY", LLSD(mat->getSpecularRepeatY())); - sd.insert("teSpecularRotation", LLSD(mat->getSpecularRotation())); - - sd.insert("teAlphaMode", LLSD(static_cast<S32>(mat->getDiffuseAlphaMode()))); - sd.insert("teAlphaCutoff", LLSD(static_cast<S32>(mat->getAlphaMaskCutoff()))); - sd.insert("teEnvIntensity", LLSD(static_cast<S32>(mat->getEnvironmentIntensity()))); - sd.insert("teShaderMask", LLSD(static_cast<S32>(mat->getShaderMask()))); - } - else - { - // pull data from the LLPanelFace - LLPanelFace* instance = static_cast<LLPanelFace*>(userdata); - sd.insert("pfNormalMap", LLSD(instance->getCurrentNormalMap())); - sd.insert("pfSpecularMap", LLSD(instance->getCurrentSpecularMap())); - sd.insert("pfShininess", LLSD(static_cast<S32>(instance->getCurrentShininess()))); - sd.insert("pfBumpiness", LLSD(static_cast<S32>(instance->getCurrentBumpiness()))); - sd.insert("pfAlphaMode", LLSD(static_cast<S32>(instance->getCurrentDiffuseAlphaMode()))); - sd.insert("pfAlphaCutoff", LLSD(static_cast<S32>(instance->getCurrentAlphaMaskCutoff()))); - sd.insert("pfEnvIntensity", LLSD(static_cast<S32>(instance->getCurrentEnvIntensity()))); - sd.insert("pfGlossiness", LLSD(static_cast<S32>(instance->getCurrentGlossiness()))); - sd.insert("pfNormalRotation", LLSD(instance->getCurrentBumpyRot())); - sd.insert("pfNormalScaleU", LLSD(instance->getCurrentBumpyScaleU())); - sd.insert("pfNormalScaleV", LLSD(instance->getCurrentBumpyScaleV())); - sd.insert("pfNormalOffsetU", LLSD(instance->getCurrentBumpyOffsetU())); - sd.insert("pfNormalOffsetV", LLSD(instance->getCurrentBumpyOffsetV())); - sd.insert("pfSpecularRotation", LLSD(instance->getCurrentShinyRot())); - sd.insert("pfSpecularScaleU", LLSD(instance->getCurrentShinyScaleU())); - sd.insert("pfSpecularScaleV", LLSD(instance->getCurrentShinyScaleV())); - sd.insert("pfSpecularOffsetU", LLSD(instance->getCurrentShinyOffsetU())); - sd.insert("pfSpecularOffsetV", LLSD(instance->getCurrentShinyOffsetV())); - sd.insert("pfMaterialID", LLSD(instance->getCurrentMaterialID())); - } - - return sd; -} - -// Take the individual texture settings from the material and apply to current face & TE -void LLPanelFace::applyMaterialUUID(LLUUID uuid, void* userdata) -{ - llassert(userdata != nullptr); - //LLPanelFace* instance = static_cast<LLPanelFace*>(userdata); - - LLFileSystem material_file(uuid, LLAssetType::AT_MATERIAL, LLFileSystem::READ); - S32 bufsize = material_file.getSize(); - llassert(bufsize > 0); - std::vector<U8> buffer(bufsize); - material_file.read(&buffer[0], bufsize); - std::istringstream input(std::string(buffer.begin(), buffer.end())); // TODO - extend LLFileSystem to expose iostream interface - LLSD matSD; - - LLSDSerialize::fromNotation(matSD, input, bufsize); - - LL_INFOS() << "dump matSD: " << matSD << LL_ENDL; - - // strip off the versioning wrapper for now - matSD = matSD["material"]; - - // wrong, oops. llassert(uuid == matSD.get("RenderMaterialUUID").asUUID()); // if not, whoo boy - - LLMaterialPtr mat = nullptr; - bool ident; // ? - LLSelectedTEMaterial::getCurrent(mat, ident); - - mat->setMaterialID(matSD.get("teMaterialID").asUUID()); - - mat->setNormalID(matSD.get("teNormalMap").asUUID()); - mat->setNormalOffsetX(matSD.get("teNormalOffsetX").asReal()); - mat->setNormalOffsetY(matSD.get("teNormalOffsetY").asReal()); - mat->setNormalRepeatX(matSD.get("teNormalRepeatX").asReal()); - mat->setNormalRepeatY(matSD.get("teNormalRepeatY").asReal()); - mat->setNormalRotation(matSD.get("teNormalRotation").asReal()); - - mat->setSpecularID(matSD.get("teSpecularMap").asUUID()); - LLColor4U color; - color.mV[0] = static_cast<U8>(matSD.get("teSecularColorR").asInteger()); - color.mV[1] = static_cast<U8>(matSD.get("teSecularColorG").asInteger()); - color.mV[2] = static_cast<U8>(matSD.get("teSecularColorB").asInteger()); - color.mV[3] = static_cast<U8>(matSD.get("teSecularColorA").asInteger()); - mat->setSpecularLightColor(color); - mat->setSpecularLightExponent(static_cast<U8>(matSD.get("teSpecularExponent").asInteger())); - mat->setSpecularOffsetX(matSD.get("teSpecularOffsetX").asReal()); - mat->setSpecularOffsetY(matSD.get("teSpecularOffsetY").asReal()); - mat->setSpecularRepeatX(matSD.get("teSpecularRepeatX").asReal()); - mat->setSpecularRepeatY(matSD.get("teSpecularRepeatY").asReal()); - mat->setSpecularRotation(matSD.get("teSpecularRotation").asReal()); - - mat->setDiffuseAlphaMode(static_cast<U8>(matSD.get("teAlphaMode").asInteger())); - mat->setAlphaMaskCutoff(static_cast<U8>(matSD.get("teAlphaCutoff").asInteger())); - mat->setEnvironmentIntensity(static_cast<U8>(matSD.get("teEnvIntensity").asInteger())); - //mat->setShaderMask(static_cast<U32>(matSD.get(teShaderMask").asInteger()); -} - diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index 08dc619402..6746d67ce3 100644 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -128,11 +128,15 @@ protected: void sendShiny(U32 shininess); // applies and sends shininess void sendFullbright(); // applies and sends full bright void sendGlow(); - void sendMedia(); void alignTestureLayer(); void updateCopyTexButton(); + void onCommitPbr(const LLSD& data); + void onCancelPbr(const LLSD& data); + void onSelectPbr(const LLSD& data); + static BOOL onDragPbr(LLUICtrl* ctrl, LLInventoryItem* item); + // this function is to return TRUE if the drag should succeed. static BOOL onDragTexture(LLUICtrl* ctrl, LLInventoryItem* item); @@ -200,6 +204,7 @@ protected: static void onCommitMaterialsMedia( LLUICtrl* ctrl, void* userdata); static void onCommitMaterialType( LLUICtrl* ctrl, void* userdata); + static void onCommitPbrType(LLUICtrl* ctrl, void* userdata); static void onCommitBump( LLUICtrl* ctrl, void* userdata); static void onCommitTexGen( LLUICtrl* ctrl, void* userdata); static void onCommitShiny( LLUICtrl* ctrl, void* userdata); @@ -211,10 +216,6 @@ protected: static void onClickAutoFix(void*); static void onAlignTexture(void*); - static void onSaveMaterial(void*); - static LLSD renderMaterialToLLSD(LLUUID uuid, void* userdata); - static void applyMaterialUUID(LLUUID uuid, void*); - public: // needs to be accessible to selection manager void onCopyColor(); // records all selected faces void onPasteColor(); // to specific face @@ -255,7 +256,6 @@ private: F32 getCurrentShinyScaleV(); F32 getCurrentShinyOffsetU(); F32 getCurrentShinyOffsetV(); - LLUUID getCurrentMaterialID(); // Update visibility of controls to match current UI mode // (e.g. materials vs media editing) @@ -424,6 +424,7 @@ private: * all controls of the floater texture picker which allow to apply the texture will be disabled. */ void onTextureSelectionChanged(LLInventoryItem* itemp); + void onPbrSelectionChanged(LLInventoryItem* itemp); LLMenuButton* mMenuClipboardColor; LLMenuButton* mMenuClipboardTexture; @@ -535,6 +536,7 @@ public: static void getFace(class LLFace*& face_to_return, bool& identical_face); static void getImageFormat(LLGLenum& image_format_to_return, bool& identical_face); static void getTexId(LLUUID& id, bool& identical); + static void getPbrMaterialId(LLUUID& id, bool& identical); static void getObjectScaleS(F32& scale_s, bool& identical); static void getObjectScaleT(F32& scale_t, bool& identical); static void getMaxDiffuseRepeats(F32& repeats, bool& identical); diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index d349b7e024..677e920031 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -80,7 +80,7 @@ void LLReflectionMapManager::update() if (!mRenderTarget.isComplete()) { - U32 color_fmt = GL_RGBA; + U32 color_fmt = GL_SRGB8_ALPHA8; const bool use_depth_buffer = true; const bool use_stencil_buffer = true; U32 targetRes = LL_REFLECTION_PROBE_RESOLUTION * 2; // super sample diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index fc5b1c60e2..c4ad48033e 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -1760,6 +1760,89 @@ void LLSelectMgr::selectionSetImage(const LLUUID& imageid) } //----------------------------------------------------------------------------- +// selectionSetGLTFMaterial() +//----------------------------------------------------------------------------- +void LLSelectMgr::selectionSetGLTFMaterial(const LLUUID& mat_id) +{ + // First for (no copy) textures and multiple object selection + LLViewerInventoryItem* item = gInventory.getItem(mat_id); + if (item + && !item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID()) + && (mSelectedObjects->getNumNodes() > 1)) + { + LL_WARNS() << "Attempted to apply no-copy material to multiple objects" + << LL_ENDL; + return; + } + + struct f : public LLSelectedTEFunctor + { + LLViewerInventoryItem* mItem; + LLUUID mMatId; + f(LLViewerInventoryItem* item, const LLUUID& id) : mItem(item), mMatId(id) {} + bool apply(LLViewerObject* objectp, S32 te) + { + if (objectp && !objectp->permModify()) + { + return false; + } + LLUUID asset_id = mMatId; + if (mItem) + { + asset_id = mItem->getAssetUUID(); + } + + if (te != -1) + { + objectp->setRenderMaterialID(te, asset_id); + } + else + { + S32 num_faces = objectp->getNumTEs(); + for (S32 face = 0; face < num_faces; face++) + { + objectp->setRenderMaterialID(face, asset_id); + } + } + + return true; + } + }; + + if (item && !item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID())) + { + getSelection()->applyNoCopyTextureToTEs(item); + } + else + { + f setfunc(item, mat_id); + getSelection()->applyToTEs(&setfunc); + } + + + struct g : public LLSelectedObjectFunctor + { + LLViewerInventoryItem* mItem; + g(LLViewerInventoryItem* item) : mItem(item) {} + virtual bool apply(LLViewerObject* object) + { + if (!mItem) + { + object->sendTEUpdate(); + // 1 particle effect per object + LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BEAM, TRUE); + effectp->setSourceObject(gAgentAvatarp); + effectp->setTargetObject(object); + effectp->setDuration(LL_HUD_DUR_SHORT); + effectp->setColor(LLColor4U(gAgent.getEffectColor())); + } + return true; + } + } sendfunc(item); + getSelection()->applyToObjects(&sendfunc); +} + +//----------------------------------------------------------------------------- // selectionSetColor() //----------------------------------------------------------------------------- void LLSelectMgr::selectionSetColor(const LLColor4 &color) diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h index aec2baa6a7..3b76f87c44 100644 --- a/indra/newview/llselectmgr.h +++ b/indra/newview/llselectmgr.h @@ -605,6 +605,7 @@ public: void selectionSetRestitution(F32 restitution); void selectionSetMaterial(U8 material); void selectionSetImage(const LLUUID& imageid); // could be item or asset id + void selectionSetGLTFMaterial(const LLUUID& mat_id); // could be item or asset id void selectionSetColor(const LLColor4 &color); void selectionSetColorOnly(const LLColor4 &color); // Set only the RGB channels void selectionSetAlphaOnly(const F32 alpha); // Set only the alpha channel diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index a26ac446c6..2dad9cd2dc 100644 --- a/indra/newview/lltexturectrl.cpp +++ b/indra/newview/lltexturectrl.cpp @@ -177,7 +177,8 @@ LLFloaterTexturePicker::LLFloaterTexturePicker( mOnFloaterCloseCallback(NULL), mSetImageAssetIDCallback(NULL), mOnUpdateImageStatsCallback(NULL), - mBakeTextureEnabled(FALSE) + mBakeTextureEnabled(FALSE), + mInventoryPickType(LLTextureCtrl::PICK_TEXTURE) { mCanApplyImmediately = can_apply_immediately; buildFromFile("floater_texture_ctrl.xml"); @@ -410,15 +411,14 @@ BOOL LLFloaterTexturePicker::postBuild() childSetAction("None", LLFloaterTexturePicker::onBtnNone,this); childSetAction("Blank", LLFloaterTexturePicker::onBtnBlank,this); - - childSetCommitCallback("show_folders_check", onShowFolders, this); - getChildView("show_folders_check")->setVisible( FALSE); - mFilterEdit = getChild<LLFilterEditor>("inventory search editor"); mFilterEdit->setCommitCallback(boost::bind(&LLFloaterTexturePicker::onFilterEdit, this, _2)); mInventoryPanel = getChild<LLInventoryPanel>("inventory panel"); + // if can select both materials and textures, set textures_material_combo's layout as visible + childSetVisible("combo_layout", mInventoryPickType == LLTextureCtrl::PICK_TEXTURE_MATERIAL); + mTextureMaterialsCombo = getChild<LLComboBox>("textures_material_combo"); mTextureMaterialsCombo->setCommitCallback(onSelectTextureMaterials, this); @@ -470,8 +470,20 @@ BOOL LLFloaterTexturePicker::postBuild() mLocalScrollCtrl = getChild<LLScrollListCtrl>("l_name_list"); mLocalScrollCtrl->setCommitCallback(onLocalScrollCommit, this); mLocalScrollCtrl->clearRows(); - LLLocalBitmapMgr::getInstance()->feedScrollList(mLocalScrollCtrl); - LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(mLocalScrollCtrl); + + if (mInventoryPickType == LLTextureCtrl::PICK_TEXTURE_MATERIAL) + { + LLLocalBitmapMgr::getInstance()->feedScrollList(mLocalScrollCtrl); + LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(mLocalScrollCtrl); + } + else if (mInventoryPickType == LLTextureCtrl::PICK_TEXTURE) + { + LLLocalBitmapMgr::getInstance()->feedScrollList(mLocalScrollCtrl); + } + else if (mInventoryPickType == LLTextureCtrl::PICK_MATERIAL) + { + LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(mLocalScrollCtrl); + } mNoCopyTextureSelected = FALSE; @@ -505,7 +517,6 @@ void LLFloaterTexturePicker::draw() updateImageStats(); // if we're inactive, gray out "apply immediate" checkbox - getChildView("show_folders_check")->setEnabled(mActive && mCanApplyImmediately && !mNoCopyTextureSelected); getChildView("Select")->setEnabled(mActive && mCanApply); getChildView("Pipette")->setEnabled(mActive); getChild<LLUICtrl>("Pipette")->setValue(LLToolMgr::getInstance()->getCurrentTool() == LLToolPipette::getInstance()); @@ -836,9 +847,6 @@ void LLFloaterTexturePicker::onModeSelect(LLUICtrl* ctrl, void *userdata) self->getChild<LLFilterEditor>("inventory search editor")->setVisible(index == 0 ? TRUE : FALSE); self->getChild<LLInventoryPanel>("inventory panel")->setVisible(index == 0 ? TRUE : FALSE); - /*self->getChild<LLCheckBox>("show_folders_check")->setVisible(mode); - no idea under which conditions the above is even shown, needs testing. */ - self->getChild<LLButton>("l_add_btn")->setVisible(index == 1 ? TRUE : FALSE); self->getChild<LLButton>("l_rem_btn")->setVisible(index == 1 ? TRUE : FALSE); self->getChild<LLButton>("l_upl_btn")->setVisible(index == 1 ? TRUE : FALSE); @@ -909,11 +917,18 @@ void LLFloaterTexturePicker::onBtnAdd(void* userdata) { LLFloaterTexturePicker* self = (LLFloaterTexturePicker*)userdata; - // todo: there will be changes to texture picker to forbid - // selection of materials in some cases, like landmarks, once - // it gets implemented, update code to select FLOAD_* filter - // based on picker's material/texture mode. - LLFilePickerReplyThread::startPicker(boost::bind(&onPickerCallback, _1, self->getHandle()), LLFilePicker::FFLOAD_MATERIAL_TEXTURE, true); + if (self->mInventoryPickType == LLTextureCtrl::PICK_TEXTURE_MATERIAL) + { + LLFilePickerReplyThread::startPicker(boost::bind(&onPickerCallback, _1, self->getHandle()), LLFilePicker::FFLOAD_MATERIAL_TEXTURE, true); + } + else if (self->mInventoryPickType == LLTextureCtrl::PICK_TEXTURE) + { + LLFilePickerReplyThread::startPicker(boost::bind(&onPickerCallback, _1, self->getHandle()), LLFilePicker::FFLOAD_IMAGE, true); + } + else if (self->mInventoryPickType == LLTextureCtrl::PICK_MATERIAL) + { + LLFilePickerReplyThread::startPicker(boost::bind(&onPickerCallback, _1, self->getHandle()), LLFilePicker::FFLOAD_MATERIAL, true); + } } // static @@ -949,8 +964,20 @@ void LLFloaterTexturePicker::onBtnRemove(void* userdata) self->getChild<LLButton>("l_rem_btn")->setEnabled(false); self->getChild<LLButton>("l_upl_btn")->setEnabled(false); self->mLocalScrollCtrl->clearRows(); - LLLocalBitmapMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); - LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); + + if (self->mInventoryPickType == LLTextureCtrl::PICK_TEXTURE_MATERIAL) + { + LLLocalBitmapMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); + LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); + } + else if (self->mInventoryPickType == LLTextureCtrl::PICK_TEXTURE) + { + LLLocalBitmapMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); + } + else if (self->mInventoryPickType == LLTextureCtrl::PICK_MATERIAL) + { + LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); + } } } @@ -1037,22 +1064,6 @@ void LLFloaterTexturePicker::onLocalScrollCommit(LLUICtrl* ctrl, void* userdata) } // static -void LLFloaterTexturePicker::onShowFolders(LLUICtrl* ctrl, void *user_data) -{ - LLCheckBoxCtrl* check_box = (LLCheckBoxCtrl*)ctrl; - LLFloaterTexturePicker* picker = (LLFloaterTexturePicker*)user_data; - - if (check_box->get()) - { - picker->mInventoryPanel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS); - } - else - { - picker->mInventoryPanel->setShowFolderState(LLInventoryFilter::SHOW_NO_FOLDERS); - } -} - -// static void LLFloaterTexturePicker::onApplyImmediateCheck(LLUICtrl* ctrl, void *user_data) { LLFloaterTexturePicker* picker = (LLFloaterTexturePicker*)user_data; @@ -1199,26 +1210,26 @@ void LLFloaterTexturePicker::onSelectTextureMaterials(LLUICtrl* ctrl, void *user LLFloaterTexturePicker* self = (LLFloaterTexturePicker*)userdata; int index = self->mTextureMaterialsCombo->getValue().asInteger(); - // IMPORTANT: make sure these match the entries in floater_texture_ctrl.xml - // for the textures_material_combo combo box - const int textures_and_materials = 0; - const int textures_only = 1; - const int materials_only = 2; - U32 filter_types = 0x0; - if (index == textures_and_materials) + if (self->mInventoryPickType != LLTextureCtrl::PICK_TEXTURE_MATERIAL) + { + // mInventoryPickType overrides combo + index = self->mInventoryPickType; + } + + if (index == LLTextureCtrl::PICK_TEXTURE_MATERIAL) { filter_types |= 0x1 << LLInventoryType::IT_TEXTURE; filter_types |= 0x1 << LLInventoryType::IT_SNAPSHOT; filter_types |= 0x1 << LLInventoryType::IT_MATERIAL; } - else if (index == textures_only) + else if (index == LLTextureCtrl::PICK_TEXTURE) { filter_types |= 0x1 << LLInventoryType::IT_TEXTURE; filter_types |= 0x1 << LLInventoryType::IT_SNAPSHOT; } - else if (index == materials_only) + else if (index == LLTextureCtrl::PICK_MATERIAL) { filter_types |= 0x1 << LLInventoryType::IT_MATERIAL; } @@ -1253,6 +1264,32 @@ void LLFloaterTexturePicker::setBakeTextureEnabled(BOOL enabled) onModeSelect(0, this); } +void LLFloaterTexturePicker::setInventoryPickType(LLTextureCtrl::EPickInventoryType type) +{ + mInventoryPickType = type; + + // if can select both materials and textures, set textures_material_combo's layout as visible + childSetVisible("combo_layout", mInventoryPickType == LLTextureCtrl::PICK_TEXTURE_MATERIAL); + + mLocalScrollCtrl->clearRows(); + if (mInventoryPickType == LLTextureCtrl::PICK_TEXTURE_MATERIAL) + { + LLLocalBitmapMgr::getInstance()->feedScrollList(mLocalScrollCtrl); + LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(mLocalScrollCtrl); + } + else if (mInventoryPickType == LLTextureCtrl::PICK_TEXTURE) + { + LLLocalBitmapMgr::getInstance()->feedScrollList(mLocalScrollCtrl); + } + else if (mInventoryPickType == LLTextureCtrl::PICK_MATERIAL) + { + LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(mLocalScrollCtrl); + } + + // refresh filters + onSelectTextureMaterials(0, this); +} + void LLFloaterTexturePicker::onPickerCallback(const std::vector<std::string>& filenames, LLHandle<LLFloater> handle) { std::vector<std::string>::const_iterator iter = filenames.begin(); @@ -1278,8 +1315,20 @@ void LLFloaterTexturePicker::onPickerCallback(const std::vector<std::string>& fi { LLFloaterTexturePicker* self = (LLFloaterTexturePicker*)handle.get(); self->mLocalScrollCtrl->clearRows(); - LLLocalBitmapMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); - LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); + + if (self->mInventoryPickType == LLTextureCtrl::PICK_TEXTURE_MATERIAL) + { + LLLocalBitmapMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); + LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); + } + else if (self->mInventoryPickType == LLTextureCtrl::PICK_TEXTURE) + { + LLLocalBitmapMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); + } + else if (self->mInventoryPickType == LLTextureCtrl::PICK_MATERIAL) + { + LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); + } } } @@ -1330,6 +1379,8 @@ LLTextureCtrl::LLTextureCtrl(const LLTextureCtrl::Params& p) mValid( TRUE ), mShowLoadingPlaceholder( TRUE ), mOpenTexPreview(false), + mBakeTextureEnabled(true), + mInventoryPickType(PICK_TEXTURE), mImageAssetID(p.image_id), mDefaultImageAssetID(p.default_image_id), mDefaultImageName(p.default_image_name), @@ -1519,14 +1570,10 @@ void LLTextureCtrl::showPicker(BOOL take_focus) if (texture_floaterp) { texture_floaterp->setOnFloaterCommitCallback(boost::bind(&LLTextureCtrl::onFloaterCommit, this, _1, _2)); - } - if (texture_floaterp) - { texture_floaterp->setSetImageAssetIDCallback(boost::bind(&LLTextureCtrl::setImageAssetID, this, _1)); - } - if (texture_floaterp) - { - texture_floaterp->setBakeTextureEnabled(TRUE); + + texture_floaterp->setBakeTextureEnabled(mBakeTextureEnabled); + texture_floaterp->setInventoryPickType(mInventoryPickType); } LLFloater* root_floater = gFloaterView->getParentFloater(this); @@ -1773,8 +1820,9 @@ void LLTextureCtrl::setImageAssetID( const LLUUID& asset_id ) } } -void LLTextureCtrl::setBakeTextureEnabled(BOOL enabled) +void LLTextureCtrl::setBakeTextureEnabled(bool enabled) { + mBakeTextureEnabled = enabled; LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mFloaterHandle.get(); if (floaterp) { @@ -1782,6 +1830,16 @@ void LLTextureCtrl::setBakeTextureEnabled(BOOL enabled) } } +void LLTextureCtrl::setInventoryPickType(EPickInventoryType type) +{ + mInventoryPickType = type; + LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mFloaterHandle.get(); + if (floaterp) + { + floaterp->setInventoryPickType(type); + } +} + BOOL LLTextureCtrl::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, diff --git a/indra/newview/lltexturectrl.h b/indra/newview/lltexturectrl.h index 1bfbb0d1be..9cb86a2e74 100644 --- a/indra/newview/lltexturectrl.h +++ b/indra/newview/lltexturectrl.h @@ -78,6 +78,15 @@ public: TEXTURE_CANCEL } ETexturePickOp; + // Should match the entries in floater_texture_ctrl.xml + // for the textures_material_combo combo box + typedef enum e_pick_inventory_type + { + PICK_TEXTURE_MATERIAL = 0, + PICK_TEXTURE = 1, + PICK_MATERIAL = 2, + } EPickInventoryType; + public: struct Params : public LLInitParam::Block<Params, LLUICtrl::Params> { @@ -212,7 +221,11 @@ public: LLViewerFetchedTexture* getTexture() { return mTexturep; } - void setBakeTextureEnabled(BOOL enabled); + void setBakeTextureEnabled(bool enabled); + bool getBakeTextureEnabled() const { return mBakeTextureEnabled; } + + void setInventoryPickType(EPickInventoryType type); + EPickInventoryType getInventoryPickType() { return mInventoryPickType; }; private: BOOL allowDrop(LLInventoryItem* item); @@ -251,7 +264,8 @@ private: std::string mLoadingPlaceholderString; S32 mLabelWidth; bool mOpenTexPreview; - BOOL mBakeTextureEnabled; + bool mBakeTextureEnabled; + LLTextureCtrl::EPickInventoryType mInventoryPickType; }; ////////////////////////////////////////////////////////////////////////////////////////// @@ -329,9 +343,7 @@ public: //static void onBtnRevert( void* userdata ); static void onBtnBlank(void* userdata); static void onBtnNone(void* userdata); - static void onBtnClear(void* userdata); void onSelectionChange(const std::deque<LLFolderViewItem*> &items, BOOL user_action); - static void onShowFolders(LLUICtrl* ctrl, void* userdata); static void onApplyImmediateCheck(LLUICtrl* ctrl, void* userdata); void onTextureSelect(const LLTextureEntry& te); @@ -349,6 +361,8 @@ public: void setLocalTextureEnabled(BOOL enabled); void setBakeTextureEnabled(BOOL enabled); + void setInventoryPickType(LLTextureCtrl::EPickInventoryType type); + static void onPickerCallback(const std::vector<std::string>& filenames, LLHandle<LLFloater> handle); protected: @@ -391,6 +405,7 @@ private: bool mCanApply; bool mCanPreview; bool mPreviewSettingChanged; + LLTextureCtrl::EPickInventoryType mInventoryPickType; texture_selected_callback mTextureSelectedCallback; diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 9cbbf1c276..511df4bd79 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -1224,15 +1224,18 @@ BOOL LLViewerTextureList::createUploadFile(const std::string& filename, } // note: modifies the argument raw_image!!!! -LLPointer<LLImageJ2C> LLViewerTextureList::convertToUploadFile(LLPointer<LLImageRaw> raw_image, const S32 max_image_dimentions) +LLPointer<LLImageJ2C> LLViewerTextureList::convertToUploadFile(LLPointer<LLImageRaw> raw_image, const S32 max_image_dimentions, bool force_lossless) { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; raw_image->biasedScaleToPowerOfTwo(max_image_dimentions); LLPointer<LLImageJ2C> compressedImage = new LLImageJ2C(); - if (gSavedSettings.getBOOL("LosslessJ2CUpload") && - (raw_image->getWidth() * raw_image->getHeight() <= LL_IMAGE_REZ_LOSSLESS_CUTOFF * LL_IMAGE_REZ_LOSSLESS_CUTOFF)) - compressedImage->setReversible(TRUE); + if (force_lossless || + (gSavedSettings.getBOOL("LosslessJ2CUpload") && + (raw_image->getWidth() * raw_image->getHeight() <= LL_IMAGE_REZ_LOSSLESS_CUTOFF * LL_IMAGE_REZ_LOSSLESS_CUTOFF))) + { + compressedImage->setReversible(TRUE); + } if (gSavedSettings.getBOOL("Jpeg2000AdvancedCompression")) diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h index 7de3d68e42..4116be6528 100644 --- a/indra/newview/llviewertexturelist.h +++ b/indra/newview/llviewertexturelist.h @@ -96,7 +96,7 @@ public: const std::string& out_filename, const U8 codec, const S32 max_image_dimentions = LLViewerFetchedTexture::MAX_IMAGE_SIZE_DEFAULT); - static LLPointer<LLImageJ2C> convertToUploadFile(LLPointer<LLImageRaw> raw_image, const S32 max_image_dimentions = LLViewerFetchedTexture::MAX_IMAGE_SIZE_DEFAULT); + static LLPointer<LLImageJ2C> convertToUploadFile(LLPointer<LLImageRaw> raw_image, const S32 max_image_dimentions = LLViewerFetchedTexture::MAX_IMAGE_SIZE_DEFAULT, bool force_lossless = false); static void processImageNotInDatabase( LLMessageSystem *msg, void **user_data ); static void receiveImageHeader(LLMessageSystem *msg, void **user_data); static void receiveImagePacket(LLMessageSystem *msg, void **user_data); diff --git a/indra/newview/skins/default/xui/en/floater_texture_ctrl.xml b/indra/newview/skins/default/xui/en/floater_texture_ctrl.xml index 18c226ed58..b6a2aaf31b 100644 --- a/indra/newview/skins/default/xui/en/floater_texture_ctrl.xml +++ b/indra/newview/skins/default/xui/en/floater_texture_ctrl.xml @@ -137,60 +137,79 @@ value="Preview Disabled" word_wrap="true" visible="false" - width="87" /> - <combo_box - follows="left|top|right" - height="23" - label="Choose Textures, Materials or LIFE!" - layout="topleft" - left="175" - name="textures_material_combo" - top="20" - width="231"> - <combo_box.item - label="Materials & Textures" - name="Materials_Textures" - value="0" /> - <combo_box.item - label="Textures" - name="Textures" - value="1" /> - <combo_box.item - label="Materials" - name="Materials" - value="2" /> - </combo_box> - <filter_editor - follows="left|top|right" - height="23" - label="Filter Textures" - layout="topleft" - left="175" - name="inventory search editor" - top="48" - width="231" /> - <asset_filtered_inv_panel - allow_multi_select="false" - bg_visible="true" - bg_alpha_color="DkGray2" - border="false" - follows="all" - height="195" - layout="topleft" - left_delta="0" - name="inventory panel" - top_pad="4" - width="231" - filter_asset_types="texture|material"/> - <check_box - height="14" - initial_value="false" - label="Show folders" - layout="topleft" - name="show_folders_check" - top_pad="0" - left_delta="-3" - width="200" /> + width="87" /> + + <layout_stack name="inventory_stack" + width="231" + height="276" + top="20" + left="175" + follows="all" + animate="false" + orientation="vertical"> + <layout_panel name="combo_layout" + border="false" + bevel_style="in" + auto_resize="false" + user_resize="false" + visible="false" + width="231" + height="24"> + <combo_box + follows="left|top|right" + height="23" + label="Choose Textures, Materials or LIFE!" + layout="topleft" + left="0" + name="textures_material_combo" + top="0" + width="231"> + <combo_box.item + label="Materials & Textures" + name="Materials_Textures" + value="0" /> + <combo_box.item + label="Textures" + name="Textures" + value="1" /> + <combo_box.item + label="Materials" + name="Materials" + value="2" /> + </combo_box> + </layout_panel> + <layout_panel name="inventory_layout" + border="false" + bevel_style="in" + auto_resize="true" + user_resize="false" + visible="true" + width="231" + height="252"> + <filter_editor + follows="left|top|right" + height="23" + label="Filter Textures" + layout="topleft" + left="0" + name="inventory search editor" + top="4" + width="231" /> + <asset_filtered_inv_panel + allow_multi_select="false" + bg_visible="true" + bg_alpha_color="DkGray2" + border="false" + follows="all" + height="221" + layout="topleft" + left_delta="0" + name="inventory panel" + top_pad="4" + width="231" + filter_asset_types="texture|material"/> + </layout_panel> + </layout_stack> <!-- middle: local mode --> <button diff --git a/indra/newview/skins/default/xui/en/panel_tools_texture.xml b/indra/newview/skins/default/xui/en/panel_tools_texture.xml index 2af7ccaa7a..922c58fa94 100644 --- a/indra/newview/skins/default/xui/en/panel_tools_texture.xml +++ b/indra/newview/skins/default/xui/en/panel_tools_texture.xml @@ -144,6 +144,10 @@ name="Materials" value="Materials" /> <combo_box.item + label="PBR" + name="PBR" + value="PBR" /> + <combo_box.item label="Media" name="Media" value="Media" /> @@ -179,6 +183,37 @@ top_pad="1" value="2"/> </radio_group> + <radio_group + control_name="ComboMaterialType" + height="50" + layout="topleft" + left_delta="0" + top_delta="0" + width="150" + visible = "false" + name="radio_pbr_type"> + <radio_item + label="Albedo/emissive" + name="Albedo/emissive" + top="0" + layout="topleft" + height="16" + value="0"/> + <radio_item + label="Normal" + layout="topleft" + top_pad="1" + height="16" + name="Normal" + value="1"/> + <radio_item + label="Metallic/roughness" + name="Metallic/roughness" + height="16" + layout="topleft" + top_pad="1" + value="2"/> + </radio_group> <menu_button menu_filename="menu_copy_paste_texture.xml" follows="top|left" @@ -217,6 +252,19 @@ tool_tip="Click to choose a picture" top_pad="5" width="64" /> + <texture_picker + can_apply_immediately="true" + default_image_name="Default" + fallback_image="materials_ui_x_24.png" + follows="left|top" + height="80" + label="PBR " + layout="topleft" + left="10" + name="pbr_control" + tool_tip="Click to choose a pbr material" + top_delta="0" + width="64" /> <text type="string" length="1" |