diff options
Diffstat (limited to 'indra/newview')
| -rw-r--r-- | indra/newview/llfetchedgltfmaterial.cpp | 54 | ||||
| -rw-r--r-- | indra/newview/llfetchedgltfmaterial.h | 5 | ||||
| -rw-r--r-- | indra/newview/lltexturectrl.cpp | 36 | 
3 files changed, 87 insertions, 8 deletions
diff --git a/indra/newview/llfetchedgltfmaterial.cpp b/indra/newview/llfetchedgltfmaterial.cpp index fc9d42bfb6..b6d62d1d12 100644 --- a/indra/newview/llfetchedgltfmaterial.cpp +++ b/indra/newview/llfetchedgltfmaterial.cpp @@ -29,6 +29,8 @@  #include "llviewertexturelist.h"  #include "llavatarappearancedefines.h" +#include "llviewerobject.h" +#include "llselectmgr.h"  #include "llshadermgr.h"  #include "pipeline.h" @@ -175,3 +177,55 @@ void LLFetchedGLTFMaterial::materialComplete()      materialCompleteCallbacks.clear();      materialCompleteCallbacks.shrink_to_fit();  } + +LLPointer<LLViewerFetchedTexture> LLFetchedGLTFMaterial::getUITexture() +{ +    if (mFetching) +    { +        return nullptr; +    } + +    auto fetch_texture_for_ui = [](LLPointer<LLViewerFetchedTexture>& img, const LLUUID& id) +    { +        if (id.notNull()) +        { +            if (LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary::isBakedImageId(id)) +            { +                LLViewerObject* obj = LLSelectMgr::getInstance()->getSelection()->getFirstObject(); +                if (obj) +                { +                    LLViewerTexture* viewerTexture = obj->getBakedTextureForMagicId(id); +                    img = viewerTexture ? dynamic_cast<LLViewerFetchedTexture*>(viewerTexture) : NULL; +                } + +            } +            else +            { +                img = LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); +            } +        } +        if (img) +        { +            img->setBoostLevel(LLGLTexture::BOOST_PREVIEW); +            img->forceToSaveRawImage(0); +        } +    }; + +    fetch_texture_for_ui(mBaseColorTexture, mTextureId[LLGLTFMaterial::GLTF_TEXTURE_INFO_BASE_COLOR]); +    fetch_texture_for_ui(mNormalTexture, mTextureId[LLGLTFMaterial::GLTF_TEXTURE_INFO_NORMAL]); +    fetch_texture_for_ui(mMetallicRoughnessTexture, mTextureId[LLGLTFMaterial::GLTF_TEXTURE_INFO_METALLIC_ROUGHNESS]); +    fetch_texture_for_ui(mEmissiveTexture, mTextureId[LLGLTFMaterial::GLTF_TEXTURE_INFO_EMISSIVE]); + +    if ((mBaseColorTexture && (mBaseColorTexture->getRawImageLevel() != 0)) || +        (mNormalTexture && (mNormalTexture->getRawImageLevel() != 0)) || +        (mMetallicRoughnessTexture && (mMetallicRoughnessTexture->getRawImageLevel() != 0)) || +        (mEmissiveTexture && (mEmissiveTexture->getRawImageLevel() != 0))) +    { +        return nullptr; +    } + +    // *HACK: Use one of the PBR texture components as the preview texture for now +    mPreviewTexture = mBaseColorTexture; + +    return mPreviewTexture; +} diff --git a/indra/newview/llfetchedgltfmaterial.h b/indra/newview/llfetchedgltfmaterial.h index 1668657281..eb9639723a 100644 --- a/indra/newview/llfetchedgltfmaterial.h +++ b/indra/newview/llfetchedgltfmaterial.h @@ -50,12 +50,17 @@ public:      bool isFetching() const { return mFetching; } +    LLPointer<LLViewerFetchedTexture> getUITexture(); +      // Textures used for fetching/rendering      LLPointer<LLViewerFetchedTexture> mBaseColorTexture;      LLPointer<LLViewerFetchedTexture> mNormalTexture;      LLPointer<LLViewerFetchedTexture> mMetallicRoughnessTexture;      LLPointer<LLViewerFetchedTexture> mEmissiveTexture; +    // Texture used for previewing the material in the UI +    LLPointer<LLViewerFetchedTexture> mPreviewTexture; +  protected:      // Lifetime management diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index 10667b02d9..50e2f5e1d9 100644 --- a/indra/newview/lltexturectrl.cpp +++ b/indra/newview/lltexturectrl.cpp @@ -719,17 +719,27 @@ void LLFloaterTexturePicker::draw()  		// If the floater is focused, don't apply its alpha to the texture (STORM-677).  		const F32 alpha = getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency(); -		if( mTexturep ) +        LLViewerTexture* texture = nullptr; +        if (mGLTFMaterial) +        { +            texture = mGLTFMaterial->getUITexture(); +        } +        else +        { +            texture = mTexturep.get(); +        } + +		if( texture )  		{ -			if( mTexturep->getComponents() == 4 ) +			if( texture->getComponents() == 4 )  			{  				gl_rect_2d_checkerboard( interior, alpha );  			} -			gl_draw_scaled_image( interior.mLeft, interior.mBottom, interior.getWidth(), interior.getHeight(), mTexturep, UI_VERTEX_COLOR % alpha ); +			gl_draw_scaled_image( interior.mLeft, interior.mBottom, interior.getWidth(), interior.getHeight(), texture, UI_VERTEX_COLOR % alpha );  			// Pump the priority -			mTexturep->addTextureStats( (F32)(interior.getWidth() * interior.getHeight()) ); +			texture->addTextureStats( (F32)(interior.getWidth() * interior.getHeight()) );  		}  		else if (!mFallbackImage.isNull())  		{ @@ -2131,11 +2141,21 @@ void LLTextureCtrl::draw()  		if (texture.isNull())  		{ -			texture = LLViewerTextureManager::getFetchedTexture(mImageAssetID, FTT_DEFAULT, MIPMAP_YES, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); +            if (mInventoryPickType == LLTextureCtrl::PICK_MATERIAL) +            { +                LLPointer<LLFetchedGLTFMaterial> material = gGLTFMaterialList.getMaterial(mImageAssetID); +                if (material) +                { +                    texture = material->getUITexture(); +                } +            } +            else +            { +                texture = LLViewerTextureManager::getFetchedTexture(mImageAssetID, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); +                texture->setBoostLevel(LLGLTexture::BOOST_PREVIEW); +                texture->forceToSaveRawImage(0); +            }  		} -		 -		texture->setBoostLevel(LLGLTexture::BOOST_PREVIEW); -		texture->forceToSaveRawImage(0) ;  		mTexturep = texture;  	}  | 
