Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/fix/unnecessary-texture-duplicat…
Browse files Browse the repository at this point in the history
…ion' into dev
  • Loading branch information
hybridherbst committed Apr 13, 2024
2 parents 0eb8256 + d1c67e0 commit 3547c64
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Runtime/Scripts/SceneImporter/ImporterTextures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,9 @@ protected virtual async Task ConstructTexture(GLTFTexture texture, int textureIn
{
int sourceId = GetTextureSourceId(texture);
GLTFImage image = _gltfRoot.Images[sourceId];

bool isFirstInstance = _assetCache.ImageCache[sourceId] == null;

await ConstructImage(image, sourceId, markGpuOnly, isLinear, isNormal);

var source = _assetCache.ImageCache[sourceId];
Expand Down Expand Up @@ -452,7 +455,7 @@ protected virtual async Task ConstructTexture(GLTFTexture texture, int textureIn
break;
default:
Debug.Log(LogType.Warning, "Unsupported Sampler.MinFilter: " + sampler.MinFilter+ $" (File: {_gltfFileName})");
desiredFilterMode = FilterMode.Trilinear;
desiredFilterMode = FilterMode.Bilinear;
break;
}

Expand All @@ -477,11 +480,18 @@ TextureWrapMode UnityWrapMode(GLTF.Schema.WrapMode gltfWrapMode)
}
else
{
desiredFilterMode = FilterMode.Trilinear;
desiredFilterMode = FilterMode.Bilinear;
desiredWrapModeS = TextureWrapMode.Repeat;
desiredWrapModeT = TextureWrapMode.Repeat;
}

if (isFirstInstance)
{
source.filterMode = desiredFilterMode;
source.wrapModeU = desiredWrapModeS;
source.wrapModeV = desiredWrapModeT;
}

var matchSamplerState = source.filterMode == desiredFilterMode && source.wrapModeU == desiredWrapModeS && source.wrapModeV == desiredWrapModeT;
if (matchSamplerState || markGpuOnly)
{
Expand Down

0 comments on commit 3547c64

Please sign in to comment.