Merge pull request #98 from Hecklezz/improvement/pbr_rpm_and_panel_fixes

[FIRE-35298] PBR repeats per meter and general texture panel improvements
master
Beq Janus 2025-04-05 15:20:04 +01:00 committed by GitHub
commit 8669da3e47
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 351 additions and 50 deletions

View File

@ -134,6 +134,36 @@ void FSPanelFace::updateSelectedGLTFMaterials(std::function<void(LLGLTFMaterial*
LLSelectMgr::getInstance()->getSelection()->applyToTEs(&select_func);
}
void FSPanelFace::updateSelectedGLTFMaterialsWithScale(std::function<void(LLGLTFMaterial*, const F32, const F32)> func)
{
struct LLSelectedTEGLTFMaterialFunctor : public LLSelectedTEFunctor
{
LLSelectedTEGLTFMaterialFunctor(std::function<void(LLGLTFMaterial*, const F32, const F32)> func) : mFunc(func) {}
virtual ~LLSelectedTEGLTFMaterialFunctor() {};
bool apply(LLViewerObject* object, S32 face) override
{
LLGLTFMaterial new_override;
const LLTextureEntry* tep = object->getTE(face);
if (tep->getGLTFMaterialOverride())
{
new_override = *tep->getGLTFMaterialOverride();
}
U32 s_axis = VX;
U32 t_axis = VY;
LLPrimitive::getTESTAxes(face, &s_axis, &t_axis);
mFunc(&new_override, object->getScale().mV[s_axis], object->getScale().mV[t_axis]);
LLGLTFMaterialList::queueModify(object, face, &new_override);
return true;
}
std::function<void(LLGLTFMaterial*, const F32, const F32)> mFunc;
} select_func(func);
LLSelectMgr::getInstance()->getSelection()->applyToTEs(&select_func);
}
template<typename T>
void readSelectedGLTFMaterial(std::function<T(const LLGLTFMaterial*)> func, T& value, bool& identical, bool has_tolerance, T tolerance)
{
@ -154,6 +184,36 @@ void readSelectedGLTFMaterial(std::function<T(const LLGLTFMaterial*)> func, T& v
identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&select_func, value, has_tolerance, tolerance);
}
void getSelectedGLTFMaterialMaxRepeats(LLGLTFMaterial::TextureInfo channel, F32& repeats, bool& identical)
{
// The All channel should read base color values
if (channel == LLGLTFMaterial::TextureInfo::GLTF_TEXTURE_INFO_COUNT)
channel = LLGLTFMaterial::TextureInfo::GLTF_TEXTURE_INFO_BASE_COLOR;
struct LLSelectedTEGetGLTFMaterialMaxRepeatsFunctor : public LLSelectedTEGetFunctor<F32>
{
LLSelectedTEGetGLTFMaterialMaxRepeatsFunctor(LLGLTFMaterial::TextureInfo channel) : mChannel(channel) {}
virtual ~LLSelectedTEGetGLTFMaterialMaxRepeatsFunctor() {};
F32 get(LLViewerObject* object, S32 face) override
{
const LLTextureEntry* tep = object->getTE(face);
const LLGLTFMaterial* render_material = tep->getGLTFRenderMaterial();
if (!render_material)
return 0.f;
U32 s_axis = VX;
U32 t_axis = VY;
LLPrimitive::getTESTAxes(face, &s_axis, &t_axis);
F32 repeats_u = render_material->mTextureTransform[mChannel].mScale[VX] / object->getScale().mV[s_axis];
F32 repeats_v = render_material->mTextureTransform[mChannel].mScale[VY] / object->getScale().mV[t_axis];
return llmax(repeats_u, repeats_v);
}
LLGLTFMaterial::TextureInfo mChannel;
} max_repeats_func(channel);
identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&max_repeats_func, repeats);
}
//
// keep LLRenderMaterialFunctor in sync with llmaterialeditor.cpp - Would be nice if we
// had this in its own file so we could include it from both sides ... -Zi
@ -599,6 +659,9 @@ void FSPanelFace::onMatTabChange()
static S32 last_mat = -1;
if( auto curr_mat = getCurrentMaterialType(); curr_mat != last_mat )
{
// Fixes some UI desync
updateUI(true);
LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstNode();
LLViewerObject* objectp = node ? node->getObject() : NULL;
if(objectp)
@ -627,6 +690,32 @@ void FSPanelFace::onMatTabChange()
}
}
void FSPanelFace::onMatChannelTabChange()
{
// Fixes some UI desync
static S32 last_channel = -1;
if (auto curr_channel = getCurrentMatChannel(); curr_channel != last_channel)
{
last_channel = curr_channel;
if (!mSetChannelTab)
updateUI(true);
}
mSetChannelTab = false;
}
void FSPanelFace::onPBRChannelTabChange()
{
// Fixes some UI desync
static S32 last_channel = -1;
if (auto curr_channel = getCurrentPBRChannel(); curr_channel != last_channel)
{
last_channel = curr_channel;
if (!mSetChannelTab)
updateUI(true);
}
mSetChannelTab = false;
}
bool FSPanelFace::postBuild()
{
//
@ -725,6 +814,9 @@ bool FSPanelFace::postBuild()
// hook up callbacks and do setup of all relevant UI elements here
//
mTabsPBRMatMedia->setCommitCallback(boost::bind(&FSPanelFace::onMatTabChange, this));
mTabsMatChannel->setCommitCallback(boost::bind(&FSPanelFace::onMatChannelTabChange, this));
mTabsPBRChannel->setCommitCallback(boost::bind(&FSPanelFace::onPBRChannelTabChange, this));
// common controls and parameters for Blinn-Phong and PBR
mBtnCopyFaces->setCommitCallback(boost::bind(&FSPanelFace::onCopyFaces, this));
mBtnPasteFaces->setCommitCallback(boost::bind(&FSPanelFace::onPasteFaces, this));
@ -885,9 +977,9 @@ bool FSPanelFace::postBuild()
changePrecision(gSavedSettings.getS32("FSBuildToolDecimalPrecision"));
selectMaterialType(MATMEDIA_PBR); // TODO: add tab switching signal
selectMatChannel(LLRender::DIFFUSE_MAP); // TODO: add tab switching signal
selectPBRChannel(LLRender::NUM_TEXTURE_CHANNELS); // TODO: add tab switching signal
selectMaterialType(MATMEDIA_PBR);
selectMatChannel(LLRender::DIFFUSE_MAP);
selectPBRChannel(LLRender::NUM_TEXTURE_CHANNELS);
return true;
}
@ -2005,13 +2097,19 @@ void FSPanelFace::updateUI(bool force_set_values /*false*/)
F32 repeats_norm = 1.f;
F32 repeats_spec = 1.f;
F32 repeats_pbr_basecolor = 1.f;
F32 repeats_pbr_metallic_roughness = 1.f;
F32 repeats_pbr_normal = 1.f;
F32 repeats_pbr_emissive = 1.f;
bool identical_diff_repeats = false;
bool identical_norm_repeats = false;
bool identical_spec_repeats = false;
LLSelectedTE::getMaxDiffuseRepeats(repeats_diff, identical_diff_repeats);
LLSelectedTEMaterial::getMaxNormalRepeats(repeats_norm, identical_norm_repeats);
LLSelectedTEMaterial::getMaxSpecularRepeats(repeats_spec, identical_spec_repeats);
bool identical_pbr_basecolor_repeats = false;
bool identical_pbr_metallic_roughness_repeats = false;
bool identical_pbr_normal_repeats = false;
bool identical_pbr_emissive_repeats = false;
S32 index = mComboTexGen->getCurrentIndex();
bool enabled = editable && (index != 1);
@ -2021,15 +2119,26 @@ void FSPanelFace::updateUI(bool force_set_values /*false*/)
F32 repeats = 1.0f;
LLRender::eTexIndex material_channel = LLRender::DIFFUSE_MAP;
if (material_selection == MATMEDIA_MATERIAL)
if (material_selection != MATMEDIA_PBR)
{
material_channel = getCurrentMatChannel();
LLSelectedTE::getMaxDiffuseRepeats(repeats_diff, identical_diff_repeats);
LLSelectedTEMaterial::getMaxNormalRepeats(repeats_norm, identical_norm_repeats);
LLSelectedTEMaterial::getMaxSpecularRepeats(repeats_spec, identical_spec_repeats);
}
// TODO: check if repeats per meter even apply to PBR materials -Zi
else if (material_selection == MATMEDIA_PBR)
{
enabled = editable;
material_channel = getCurrentPBRChannel();
getSelectedGLTFMaterialMaxRepeats(LLGLTFMaterial::TextureInfo::GLTF_TEXTURE_INFO_BASE_COLOR,
repeats_pbr_basecolor, identical_pbr_basecolor_repeats);
getSelectedGLTFMaterialMaxRepeats(LLGLTFMaterial::TextureInfo::GLTF_TEXTURE_INFO_METALLIC_ROUGHNESS,
repeats_pbr_metallic_roughness, identical_pbr_metallic_roughness_repeats);
getSelectedGLTFMaterialMaxRepeats(LLGLTFMaterial::TextureInfo::GLTF_TEXTURE_INFO_NORMAL,
repeats_pbr_normal, identical_pbr_normal_repeats);
getSelectedGLTFMaterialMaxRepeats(LLGLTFMaterial::TextureInfo::GLTF_TEXTURE_INFO_EMISSIVE,
repeats_pbr_emissive, identical_pbr_emissive_repeats);
}
switch (material_channel)
@ -2069,11 +2178,40 @@ void FSPanelFace::updateUI(bool force_set_values /*false*/)
repeats = repeats_norm;
}
break;
case LLRender::NUM_TEXTURE_CHANNELS:
case LLRender::BASECOLOR_MAP:
{
identical_repeats = identical_pbr_basecolor_repeats;
repeats = repeats_pbr_basecolor;
}
break;
case LLRender::METALLIC_ROUGHNESS_MAP:
{
identical_repeats = identical_pbr_metallic_roughness_repeats;
repeats = repeats_pbr_metallic_roughness;
}
break;
case LLRender::GLTF_NORMAL_MAP:
{
identical_repeats = identical_pbr_normal_repeats;
repeats = repeats_pbr_normal;
}
break;
case LLRender::EMISSIVE_MAP:
{
identical_repeats = identical_pbr_emissive_repeats;
repeats = repeats_pbr_emissive;
}
break;
}
bool repeats_tentative = !identical_repeats;
if (force_set_values)
if (force_set_values || material_selection == MATMEDIA_PBR)
{
//onCommit, previosly edited element updates related ones
mCtrlRpt->forceSetValue(editable ? repeats : 1.0f);
@ -3235,6 +3373,7 @@ void FSPanelFace::onCommitShinyColor()
void FSPanelFace::onCommitAlpha()
{
mCtrlColorTransp->setFocus(true);
sendAlpha();
}
@ -3262,6 +3401,13 @@ void FSPanelFace::onSelectShinyColor()
void FSPanelFace::updateVisibility(LLViewerObject* objectp /* = nullptr */)
{
S32 materials_media = getCurrentMaterialType();
bool show_media = materials_media == MATMEDIA_MEDIA;
bool show_material = materials_media == MATMEDIA_MATERIAL;
// Shared material controls
mCheckSyncMaterials->setVisible(show_material || show_media);
updateAlphaControls();
// TODO: is this still needed? -Zi
updateShinyControls();
@ -3384,6 +3530,7 @@ void FSPanelFace::onCommitFullbright()
void FSPanelFace::onCommitGlow()
{
mCtrlGlow->setFocus(true);
sendGlow();
}
@ -3495,6 +3642,7 @@ void FSPanelFace::onCommitPbr(const LLUICtrl* pbr_ctrl)
}
else if (pbr_ctrl == mAlphaPBR)
{
mAlphaPBR->setFocus(true);
mUnsavedChanges |= MATERIAL_BASE_COLOR_DIRTY;
}
else if (pbr_ctrl == mAlphaModePBR)
@ -3503,14 +3651,17 @@ void FSPanelFace::onCommitPbr(const LLUICtrl* pbr_ctrl)
}
else if (pbr_ctrl == mMaskCutoffPBR)
{
mMaskCutoffPBR->setFocus(true);
mUnsavedChanges |= MATERIAL_ALPHA_CUTOFF_DIRTY;
}
else if (pbr_ctrl == mMetallicFactorPBR)
{
mMetallicFactorPBR->setFocus(true);
mUnsavedChanges |= MATERIAL_METALLIC_ROUGHTNESS_METALNESS_DIRTY;
}
else if (pbr_ctrl == mRoughnessFactorPBR)
{
mRoughnessFactorPBR->setFocus(true);
mUnsavedChanges |= MATERIAL_METALLIC_ROUGHTNESS_ROUGHNESS_DIRTY;
}
}
@ -3823,6 +3974,7 @@ void FSPanelFace::syncOffsetY(FSPanelFace* self, F32 offsetV)
void FSPanelFace::onCommitMaterialBumpyOffsetX()
{
mCtrlBumpyOffsetU->setFocus(true);
if (gSavedSettings.getBOOL("SyncMaterialSettings"))
{
syncOffsetX(this, getCurrentBumpyOffsetU());
@ -3835,6 +3987,7 @@ void FSPanelFace::onCommitMaterialBumpyOffsetX()
void FSPanelFace::onCommitMaterialBumpyOffsetY()
{
mCtrlBumpyOffsetV->setFocus(true);
if (gSavedSettings.getBOOL("SyncMaterialSettings"))
{
syncOffsetY(this, getCurrentBumpyOffsetV());
@ -3847,6 +4000,7 @@ void FSPanelFace::onCommitMaterialBumpyOffsetY()
void FSPanelFace::onCommitMaterialShinyOffsetX()
{
mCtrlShinyOffsetU->setFocus(true);
if (gSavedSettings.getBOOL("SyncMaterialSettings"))
{
syncOffsetX(this, getCurrentShinyOffsetU());
@ -3859,6 +4013,7 @@ void FSPanelFace::onCommitMaterialShinyOffsetX()
void FSPanelFace::onCommitMaterialShinyOffsetY()
{
mCtrlShinyOffsetV->setFocus(true);
if (gSavedSettings.getBOOL("SyncMaterialSettings"))
{
syncOffsetY(this, getCurrentShinyOffsetV());
@ -3887,6 +4042,7 @@ void FSPanelFace::syncRepeatY(FSPanelFace* self, F32 scaleV)
void FSPanelFace::onCommitMaterialBumpyScaleX()
{
mCtrlBumpyScaleU->setFocus(true);
F32 bumpy_scale_u = getCurrentBumpyScaleU();
if (isIdenticalPlanarTexgen())
{
@ -3906,6 +4062,7 @@ void FSPanelFace::onCommitMaterialBumpyScaleX()
void FSPanelFace::onCommitMaterialBumpyScaleY()
{
mCtrlBumpyScaleV->setFocus(true);
F32 bumpy_scale_v = getCurrentBumpyScaleV();
if (isIdenticalPlanarTexgen())
{
@ -3925,6 +4082,7 @@ void FSPanelFace::onCommitMaterialBumpyScaleY()
void FSPanelFace::onCommitMaterialShinyScaleX()
{
mCtrlShinyScaleU->setFocus(true);
F32 shiny_scale_u = getCurrentShinyScaleU();
if (isIdenticalPlanarTexgen())
{
@ -3944,6 +4102,7 @@ void FSPanelFace::onCommitMaterialShinyScaleX()
void FSPanelFace::onCommitMaterialShinyScaleY()
{
mCtrlShinyScaleV->setFocus(true);
F32 shiny_scale_v = getCurrentShinyScaleV();
if (isIdenticalPlanarTexgen())
{
@ -3971,6 +4130,7 @@ void FSPanelFace::syncMaterialRot(FSPanelFace* self, F32 rot, int te)
void FSPanelFace::onCommitMaterialBumpyRot()
{
mCtrlBumpyRot->setFocus(true);
if (gSavedSettings.getBOOL("SyncMaterialSettings"))
{
mCtrlTexRot->forceSetValue(LLSD(getCurrentBumpyRot()));
@ -3995,6 +4155,7 @@ void FSPanelFace::onCommitMaterialBumpyRot()
void FSPanelFace::onCommitMaterialShinyRot()
{
mCtrlShinyRot->setFocus(true);
if (gSavedSettings.getBOOL("SyncMaterialSettings"))
{
mCtrlTexRot->forceSetValue(LLSD(getCurrentShinyRot()));
@ -4019,21 +4180,25 @@ void FSPanelFace::onCommitMaterialShinyRot()
void FSPanelFace::onCommitMaterialGloss()
{
mCtrlGlossiness->setFocus(true);
LLSelectedTEMaterial::setSpecularLightExponent(this, getCurrentGlossiness());
}
void FSPanelFace::onCommitMaterialEnv()
{
mCtrlEnvironment->setFocus(true);
LLSelectedTEMaterial::setEnvironmentIntensity(this, getCurrentEnvIntensity());
}
void FSPanelFace::onCommitMaterialMaskCutoff()
{
mCtrlMaskCutoff->setFocus(true);
LLSelectedTEMaterial::setAlphaMaskCutoff(this, getCurrentAlphaMaskCutoff());
}
void FSPanelFace::onCommitTextureScaleX()
{
mCtrlTexScaleU->setFocus(true);
if (gSavedSettings.getBOOL("SyncMaterialSettings"))
{
F32 bumpy_scale_u = (F32)mCtrlTexScaleU->getValue().asReal();
@ -4052,6 +4217,7 @@ void FSPanelFace::onCommitTextureScaleX()
void FSPanelFace::onCommitTextureScaleY()
{
mCtrlTexScaleV->setFocus(true);
if (gSavedSettings.getBOOL("SyncMaterialSettings"))
{
F32 bumpy_scale_v = (F32)mCtrlTexScaleV->getValue().asReal();
@ -4070,6 +4236,7 @@ void FSPanelFace::onCommitTextureScaleY()
void FSPanelFace::onCommitTextureRot()
{
mCtrlTexRot->setFocus(true);
if (gSavedSettings.getBOOL("SyncMaterialSettings"))
{
syncMaterialRot(this, (F32)mCtrlTexRot->getValue().asReal());
@ -4084,6 +4251,7 @@ void FSPanelFace::onCommitTextureRot()
void FSPanelFace::onCommitTextureOffsetX()
{
mCtrlTexOffsetU->setFocus(true);
if (gSavedSettings.getBOOL("SyncMaterialSettings"))
{
syncOffsetX(this, (F32)mCtrlTexOffsetU->getValue().asReal());
@ -4097,6 +4265,7 @@ void FSPanelFace::onCommitTextureOffsetX()
void FSPanelFace::onCommitTextureOffsetY()
{
mCtrlTexOffsetV->setFocus(true);
if (gSavedSettings.getBOOL("SyncMaterialSettings"))
{
syncOffsetY(this, (F32)mCtrlTexOffsetV->getValue().asReal());
@ -4111,12 +4280,15 @@ void FSPanelFace::onCommitTextureOffsetY()
// Commit the number of repeats per meter
void FSPanelFace::onCommitRepeatsPerMeter()
{
mCtrlRpt->setFocus(true);
S32 materials_media = getCurrentMaterialType();
LLRender::eTexIndex material_channel = LLRender::DIFFUSE_MAP;
// TODO: check if repeats per meter is even used for PBR -Zi
LLGLTFMaterial::TextureInfo material_type = LLGLTFMaterial::GLTF_TEXTURE_INFO_BASE_COLOR;
if (materials_media == MATMEDIA_PBR)
{
material_channel = getCurrentPBRChannel();
material_type = getCurrentPBRType(material_channel);
}
if (materials_media == MATMEDIA_MATERIAL)
@ -4133,23 +4305,21 @@ void FSPanelFace::onCommitRepeatsPerMeter()
bool identical_scale_t = false;
LLSelectedTE::getObjectScaleS(obj_scale_s, identical_scale_s);
LLSelectedTE::getObjectScaleS(obj_scale_t, identical_scale_t);
LLSelectedTE::getObjectScaleT(obj_scale_t, identical_scale_t);
if (gSavedSettings.getBOOL("SyncMaterialSettings"))
if (mCheckSyncMaterials->isAvailable() && gSavedSettings.getBOOL("SyncMaterialSettings"))
{
LLSelectMgr::getInstance()->selectionTexScaleAutofit(repeats_per_meter);
mCtrlBumpyScaleU->setValue(obj_scale_s * repeats_per_meter);
mCtrlBumpyScaleV->setValue(obj_scale_t * repeats_per_meter);
LLSelectedTEMaterial::setNormalRepeatX(this, obj_scale_s * repeats_per_meter);
LLSelectedTEMaterial::setNormalRepeatY(this, obj_scale_t * repeats_per_meter);
LLSelectedTEMaterial::selectionNormalScaleAutofit(this, repeats_per_meter);
mCtrlShinyScaleU->setValue(obj_scale_s * repeats_per_meter);
mCtrlShinyScaleV->setValue(obj_scale_t * repeats_per_meter);
LLSelectedTEMaterial::setSpecularRepeatX(this, obj_scale_s * repeats_per_meter);
LLSelectedTEMaterial::setSpecularRepeatY(this, obj_scale_t * repeats_per_meter);
LLSelectedTEMaterial::selectionSpecularScaleAutofit(this, repeats_per_meter);
}
else
{
@ -4166,8 +4336,7 @@ void FSPanelFace::onCommitRepeatsPerMeter()
mCtrlBumpyScaleU->setValue(obj_scale_s * repeats_per_meter);
mCtrlBumpyScaleV->setValue(obj_scale_t * repeats_per_meter);
LLSelectedTEMaterial::setNormalRepeatX(this, obj_scale_s * repeats_per_meter);
LLSelectedTEMaterial::setNormalRepeatY(this, obj_scale_t * repeats_per_meter);
LLSelectedTEMaterial::selectionNormalScaleAutofit(this, repeats_per_meter);
}
break;
@ -4176,8 +4345,21 @@ void FSPanelFace::onCommitRepeatsPerMeter()
mCtrlShinyScaleU->setValue(obj_scale_s * repeats_per_meter);
mCtrlShinyScaleV->setValue(obj_scale_t * repeats_per_meter);
LLSelectedTEMaterial::setSpecularRepeatX(this, obj_scale_s * repeats_per_meter);
LLSelectedTEMaterial::setSpecularRepeatY(this, obj_scale_t * repeats_per_meter);
LLSelectedTEMaterial::selectionSpecularScaleAutofit(this, repeats_per_meter);
}
break;
case LLRender::BASECOLOR_MAP:
case LLRender::METALLIC_ROUGHNESS_MAP:
case LLRender::GLTF_NORMAL_MAP:
case LLRender::EMISSIVE_MAP:
case LLRender::NUM_TEXTURE_CHANNELS:
{
updateGLTFTextureTransformWithScale(material_type, [&](LLGLTFMaterial::TextureTransform* new_transform, F32 scale_s, F32 scale_t)
{
new_transform->mScale.mV[VX] = scale_s * repeats_per_meter;
new_transform->mScale.mV[VY] = scale_t * repeats_per_meter;
});
}
break;
@ -5143,10 +5325,33 @@ void FSPanelFace::updateGLTFTextureTransform(const LLGLTFMaterial::TextureInfo t
}
}
void FSPanelFace::updateGLTFTextureTransformWithScale(const LLGLTFMaterial::TextureInfo texture_info, std::function<void(LLGLTFMaterial::TextureTransform*, const F32, const F32)> edit)
{
if (texture_info == LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT)
{
updateSelectedGLTFMaterialsWithScale([&](LLGLTFMaterial* new_override, const F32 scale_s, const F32 scale_t)
{
for (U32 i = 0; i < LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT; ++i)
{
LLGLTFMaterial::TextureTransform& new_transform = new_override->mTextureTransform[(LLGLTFMaterial::TextureInfo)i];
edit(&new_transform, scale_s, scale_t);
}
});
}
else
{
updateSelectedGLTFMaterialsWithScale([&](LLGLTFMaterial* new_override, const F32 scale_s, const F32 scale_t)
{
LLGLTFMaterial::TextureTransform& new_transform = new_override->mTextureTransform[texture_info];
edit(&new_transform, scale_s, scale_t);
});
}
}
void FSPanelFace::setMaterialOverridesFromSelection()
{
// TODO: move to .h -Zi
std::map<LLGLTFMaterial::TextureInfo, std::string> spinner_suffixes{
static std::map<LLGLTFMaterial::TextureInfo, std::string> spinner_suffixes{
{ LLGLTFMaterial::TextureInfo::GLTF_TEXTURE_INFO_BASE_COLOR, "_Base" },
{ LLGLTFMaterial::TextureInfo::GLTF_TEXTURE_INFO_NORMAL, "_Normal" },
{ LLGLTFMaterial::TextureInfo::GLTF_TEXTURE_INFO_METALLIC_ROUGHNESS, "_Metallic" },
@ -5249,6 +5454,16 @@ void FSPanelFace::setMaterialOverridesFromSelection()
gltfCtrlTextureRotation->setTentative(!rotation_same);
gltfCtrlTextureOffsetU->setTentative(!offset_u_same);
gltfCtrlTextureOffsetV->setTentative(!offset_v_same);
// Fixes some UI desync
if (getCurrentMaterialType() == MATMEDIA_PBR)
{
F32 repeats = 1.f;
bool identical = false;
getSelectedGLTFMaterialMaxRepeats(getPBRDropChannel(), repeats, identical);
mCtrlRpt->forceSetValue(repeats);
mCtrlRpt->setTentative(!identical);
}
}
void FSPanelFace::Selection::connect()
@ -5328,10 +5543,10 @@ bool FSPanelFace::Selection::compareSelection()
return selection_changed;
}
void FSPanelFace::onCommitGLTFUVSpinner(const LLUICtrl* ctrl, const LLSD& user_data)
void FSPanelFace::onCommitGLTFUVSpinner(LLUICtrl* ctrl, const LLSD& user_data)
{
// TODO: put into .h -Zi
std::map<std::string, LLGLTFMaterial::TextureInfo> types =
static std::map<std::string, LLGLTFMaterial::TextureInfo> types =
{
{ "all", LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT },
{ "base", LLGLTFMaterial::GLTF_TEXTURE_INFO_BASE_COLOR },
@ -5352,6 +5567,7 @@ void FSPanelFace::onCommitGLTFUVSpinner(const LLUICtrl* ctrl, const LLSD& user_d
const std::string& spinner_name = ctrl->getName();
const float value = (F32)ctrl->getValue().asReal();
ctrl->setFocus(true);
if (LLStringUtil::startsWith(spinner_name, "gltfTextureScaleU"))
{
@ -5597,6 +5813,7 @@ void FSPanelFace::LLSelectedTEMaterial::getMaxSpecularRepeats(F32& repeats, bool
LLMaterial* mat = object->getTEref(face).getMaterialParams().get();
U32 s_axis = VX;
U32 t_axis = VY;
LLPrimitive::getTESTAxes(face, &s_axis, &t_axis);
F32 repeats_s = 1.0f;
F32 repeats_t = 1.0f;
if (mat)
@ -5622,6 +5839,7 @@ void FSPanelFace::LLSelectedTEMaterial::getMaxNormalRepeats(F32& repeats, bool&
LLMaterial* mat = object->getTEref(face).getMaterialParams().get();
U32 s_axis = VX;
U32 t_axis = VY;
LLPrimitive::getTESTAxes(face, &s_axis, &t_axis);
F32 repeats_s = 1.0f;
F32 repeats_t = 1.0f;
if (mat)
@ -5669,6 +5887,62 @@ void FSPanelFace::LLSelectedTEMaterial::getCurrentDiffuseAlphaMode(U8& diffuse_a
identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &get_diff_mode, diffuse_alpha_mode);
}
void FSPanelFace::LLSelectedTEMaterial::selectionNormalScaleAutofit(FSPanelFace* panel_face, F32 repeats_per_meter)
{
struct f : public LLSelectedTEFunctor
{
FSPanelFace* mFacePanel;
F32 mRepeatsPerMeter;
f(FSPanelFace* face_panel, const F32& repeats_per_meter) : mFacePanel(face_panel), mRepeatsPerMeter(repeats_per_meter) {}
bool apply(LLViewerObject* object, S32 te)
{
if (object->permModify())
{
// Compute S,T to axis mapping
U32 s_axis, t_axis;
if (!LLPrimitive::getTESTAxes(te, &s_axis, &t_axis))
return true;
F32 new_s = object->getScale().mV[s_axis] * mRepeatsPerMeter;
F32 new_t = object->getScale().mV[t_axis] * mRepeatsPerMeter;
setNormalRepeatX(mFacePanel, new_s, te);
setNormalRepeatY(mFacePanel, new_t, te);
}
return true;
}
} setfunc(panel_face, repeats_per_meter);
LLSelectMgr::getInstance()->getSelection()->applyToTEs(&setfunc);
}
void FSPanelFace::LLSelectedTEMaterial::selectionSpecularScaleAutofit(FSPanelFace* panel_face, F32 repeats_per_meter)
{
struct f : public LLSelectedTEFunctor
{
FSPanelFace* mFacePanel;
F32 mRepeatsPerMeter;
f(FSPanelFace* face_panel, const F32& repeats_per_meter) : mFacePanel(face_panel), mRepeatsPerMeter(repeats_per_meter) {}
bool apply(LLViewerObject* object, S32 te)
{
if (object->permModify())
{
// Compute S,T to axis mapping
U32 s_axis, t_axis;
if (!LLPrimitive::getTESTAxes(te, &s_axis, &t_axis))
return true;
F32 new_s = object->getScale().mV[s_axis] * mRepeatsPerMeter;
F32 new_t = object->getScale().mV[t_axis] * mRepeatsPerMeter;
setSpecularRepeatX(mFacePanel, new_s, te);
setSpecularRepeatY(mFacePanel, new_t, te);
}
return true;
}
} setfunc(panel_face, repeats_per_meter);
LLSelectMgr::getInstance()->getSelection()->applyToTEs(&setfunc);
}
void FSPanelFace::LLSelectedTE::getObjectScaleS(F32& scale_s, bool& identical)
{
struct LLSelectedTEGetObjectScaleS : public LLSelectedTEGetFunctor<F32>
@ -6002,6 +6276,23 @@ LLRender::eTexIndex FSPanelFace::getCurrentPBRChannel() const
return LLRender::NUM_TEXTURE_CHANNELS;
}
LLGLTFMaterial::TextureInfo FSPanelFace::getCurrentPBRType(LLRender::eTexIndex pbr_channel) const
{
switch (pbr_channel)
{
case LLRender::GLTF_NORMAL_MAP:
return LLGLTFMaterial::GLTF_TEXTURE_INFO_NORMAL;
case LLRender::BASECOLOR_MAP:
return LLGLTFMaterial::GLTF_TEXTURE_INFO_BASE_COLOR;
case LLRender::METALLIC_ROUGHNESS_MAP:
return LLGLTFMaterial::GLTF_TEXTURE_INFO_METALLIC_ROUGHNESS;
case LLRender::EMISSIVE_MAP:
return LLGLTFMaterial::GLTF_TEXTURE_INFO_EMISSIVE;
default:
return LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT;
}
}
void FSPanelFace::selectMaterialType(S32 material_type)
{
if (material_type == MATMEDIA_PBR)
@ -6021,6 +6312,7 @@ void FSPanelFace::selectMaterialType(S32 material_type)
void FSPanelFace::selectMatChannel(LLRender::eTexIndex mat_channel)
{
mSetChannelTab = true;
if (mat_channel == LLRender::NORMAL_MAP)
{
mTabsMatChannel->selectTabByName("panel_blinn_phong_normal");
@ -6037,6 +6329,7 @@ void FSPanelFace::selectMatChannel(LLRender::eTexIndex mat_channel)
void FSPanelFace::selectPBRChannel(LLRender::eTexIndex pbr_channel)
{
mSetChannelTab = true;
if (pbr_channel == LLRender::GLTF_NORMAL_MAP)
{
mTabsPBRChannel->selectTabByName("panel_pbr_transforms_normal");

View File

@ -284,7 +284,7 @@ protected:
static void syncMaterialRot(FSPanelFace* self, F32 rot, int te = -1);
// unify all GLTF spinners with no switching around required -Zi
void onCommitGLTFUVSpinner(const LLUICtrl* ctrl, const LLSD& user_data);
void onCommitGLTFUVSpinner(LLUICtrl* ctrl, const LLSD& user_data);
void onClickBtnSelectSameTexture(const LLUICtrl* ctrl, const LLSD& user_data); // Find all faces with same texture
void onShowFindAllButton(LLUICtrl* ctrl, const LLSD& user_data); // Find all faces with same texture
@ -341,6 +341,8 @@ public:
// public to give functors access -Zi
LLTabContainer* mTabsMatChannel;
void onMatTabChange();
void onMatChannelTabChange();
void onPBRChannelTabChange();
private:
bool isAlpha() { return mIsAlpha; }
@ -378,6 +380,7 @@ private:
S32 getCurrentMaterialType() const;
LLRender::eTexIndex getCurrentMatChannel() const;
LLRender::eTexIndex getCurrentPBRChannel() const;
LLGLTFMaterial::TextureInfo getCurrentPBRType(LLRender::eTexIndex pbr_channel) const;
void selectMaterialType(S32 material_type);
void selectMatChannel(LLRender::eTexIndex mat_channel);
@ -396,6 +399,7 @@ private:
// private Tab controls
LLTabContainer* mTabsPBRMatMedia;
LLTabContainer* mTabsPBRChannel;
bool mSetChannelTab = false;
// common controls and parameters for Blinn-Phong and PBR
LLButton* mBtnCopyFaces;
@ -631,7 +635,9 @@ private:
void updateUIGLTF(LLViewerObject* objectp, bool& has_pbr_material, bool& has_faces_without_pbr, bool force_set_values);
void updateSelectedGLTFMaterials(std::function<void(LLGLTFMaterial*)> func);
void updateSelectedGLTFMaterialsWithScale(std::function<void(LLGLTFMaterial*, const F32, const F32)> func);
void updateGLTFTextureTransform(const LLGLTFMaterial::TextureInfo texture_info, std::function<void(LLGLTFMaterial::TextureTransform*)> edit);
void updateGLTFTextureTransformWithScale(const LLGLTFMaterial::TextureInfo texture_info, std::function<void(LLGLTFMaterial::TextureTransform*, const F32, const F32)> edit);
void setMaterialOverridesFromSelection();
@ -722,6 +728,8 @@ public:
static void getMaxSpecularRepeats(F32& repeats, bool& identical);
static void getMaxNormalRepeats(F32& repeats, bool& identical);
static void getCurrentDiffuseAlphaMode(U8& diffuse_alpha_mode, bool& identical, bool diffuse_texture_has_alpha);
static void selectionNormalScaleAutofit(FSPanelFace* panel_face, F32 repeats_per_meter);
static void selectionSpecularScaleAutofit(FSPanelFace* panel_face, F32 repeats_per_meter);
FS_DEF_GET_MAT_STATE(LLUUID,const LLUUID&,getNormalID,LLUUID::null, false, LLUUID::null);
FS_DEF_GET_MAT_STATE(LLUUID,const LLUUID&,getSpecularID,LLUUID::null, false, LLUUID::null);

View File

@ -329,7 +329,7 @@
top_pad="8"
name="tabs_pbr_transforms"
label_pad_left="0"
tab_max_width="100"
tab_max_width="110"
tab_min_width="30"
tab_position="top"
tab_height="20"
@ -353,7 +353,7 @@
top="0"
mouse_opaque="false"
name="pbr_transforms_all_scale"
width="90"
width="110"
height="70"
>
@ -386,7 +386,7 @@
layout="topleft"
left_pad="0"
height="19"
right="-12"
right="-32"
name="gltfTextureScaleU_All"
initial_value="0"
min_val="-10000"
@ -435,7 +435,7 @@
layout="topleft"
left_pad="0"
height="19"
right="-12"
right="-32"
initial_value="0"
min_val="-10000"
max_val="10000"
@ -613,7 +613,7 @@
top="0"
mouse_opaque="false"
name="pbr_transforms_base_color_scale"
width="90"
width="110"
height="70"
>
@ -646,7 +646,7 @@
layout="topleft"
left_pad="0"
height="19"
right="-12"
right="-32"
name="gltfTextureScaleU_Base"
initial_value="0"
min_val="-10000"
@ -695,7 +695,7 @@
layout="topleft"
left_pad="0"
height="19"
right="-12"
right="-32"
name="gltfTextureScaleV_Base"
initial_value="0"
min_val="-10000"
@ -872,7 +872,7 @@
top="0"
mouse_opaque="false"
name="pbr_transforms_normal_scale"
width="90"
width="110"
height="70"
>
@ -905,7 +905,7 @@
layout="topleft"
left_pad="0"
height="19"
right="-12"
right="-32"
name="gltfTextureScaleU_Normal"
initial_value="0"
min_val="-10000"
@ -954,7 +954,7 @@
layout="topleft"
left_pad="0"
height="19"
right="-12"
right="-32"
name="gltfTextureScaleV_Normal"
initial_value="0"
min_val="-10000"
@ -1131,7 +1131,7 @@
top="0"
mouse_opaque="false"
name="pbr_transforms_orm_scale"
width="90"
width="110"
height="70"
>
@ -1164,7 +1164,7 @@
layout="topleft"
left_pad="0"
height="19"
right="-12"
right="-32"
name="gltfTextureScaleU_Metallic"
initial_value="0"
min_val="-10000"
@ -1213,7 +1213,7 @@
layout="topleft"
left_pad="0"
height="19"
right="-12"
right="-32"
name="gltfTextureScaleV_Metallic"
initial_value="0"
min_val="-10000"
@ -1390,7 +1390,7 @@
top="0"
mouse_opaque="false"
name="pbr_transforms_emissive_scale"
width="90"
width="110"
height="70"
>
@ -1423,7 +1423,7 @@
layout="topleft"
left_pad="0"
height="19"
right="-12"
right="-32"
name="gltfTextureScaleU_Emissive"
initial_value="0"
min_val="-10000"
@ -1472,7 +1472,7 @@
layout="topleft"
left_pad="0"
height="19"
right="-12"
right="-32"
name="gltfTextureScaleV_Emissive"
initial_value="0"
min_val="-10000"
@ -2142,7 +2142,7 @@
top_pad="4"
right="-2"
name="tabs_blinn_phong_uvs"
tab_max_width="100"
tab_max_width="110"
tab_min_width="40"
tab_position="top"
tab_height="20"
@ -2162,7 +2162,7 @@
layout="topleft"
left="4"
top="0"
width="90"
width="110"
height="70"
mouse_opaque="false"
name="transforms_diffuse_scale"
@ -2197,7 +2197,7 @@
layout="topleft"
left_pad="0"
height="19"
right="-12"
right="-32"
name="TexScaleU"
initial_value="0"
min_val="-10000"
@ -2242,7 +2242,7 @@
layout="topleft"
left_pad="0"
height="19"
right="-12"
right="-32"
name="TexScaleV"
initial_value="0"
min_val="-10000"
@ -2402,7 +2402,7 @@
layout="topleft"
left="4"
top="0"
width="90"
width="110"
height="70"
mouse_opaque="false"
name="transforms_normal_scale"
@ -2437,7 +2437,7 @@
layout="topleft"
left_pad="0"
height="19"
right="-12"
right="-32"
name="bumpyScaleU"
initial_value="0"
min_val="-10000"
@ -2482,7 +2482,7 @@
layout="topleft"
left_pad="0"
height="19"
right="-12"
right="-32"
name="bumpyScaleV"
initial_value="0"
min_val="-10000"
@ -2642,7 +2642,7 @@
layout="topleft"
left="4"
top="0"
width="90"
width="110"
height="70"
mouse_opaque="false"
name="transforms_specular_scale"
@ -2677,7 +2677,7 @@
layout="topleft"
left_pad="0"
height="19"
right="-12"
right="-32"
name="shinyScaleU"
initial_value="0"
min_val="-10000"
@ -2722,7 +2722,7 @@
layout="topleft"
left_pad="0"
height="19"
right="-12"
right="-32"
name="shinyScaleV"
initial_value="0"
min_val="-10000"