From d0e7744dba283b9a865535ad91470ca6f4544979 Mon Sep 17 00:00:00 2001 From: Reina_Sakiria Date: Wed, 10 Apr 2024 15:49:26 +0900 Subject: [PATCH 1/2] fix: Apply TextureST --- Editor/Decal/RealTimePreviewManager.cs | 13 +++------- Runtime/IDomain.cs | 2 ++ .../AtlasShaderSupportUtils.cs | 2 +- Runtime/TextureAtlas/AtlasTexture.cs | 12 +++++++-- .../ShaderAsset/TextureSTApply.shader | 10 +++---- .../TransTextureCore/Utils/TextureUtility.cs | 26 +++++++++++-------- 6 files changed, 36 insertions(+), 29 deletions(-) diff --git a/Editor/Decal/RealTimePreviewManager.cs b/Editor/Decal/RealTimePreviewManager.cs index f15c38d2..bca07d1a 100644 --- a/Editor/Decal/RealTimePreviewManager.cs +++ b/Editor/Decal/RealTimePreviewManager.cs @@ -111,7 +111,7 @@ private void RegtPreviewRenderTexture(Material material, string propertyName, Bl var souseTexture = material.GetTexture(propertyName) as Texture2D; var newTarget = RenderTexture.GetTemporary(blendTexture.RenderTexture.descriptor); - CopyFilWrap(newTarget, blendTexture.RenderTexture); + newTarget.CopyFilWrap(blendTexture.RenderTexture); editableMat.SetTexture(propertyName, newTarget); @@ -194,7 +194,7 @@ public void RegtAbstractDecal(AbstractDecal abstractDecal) { continue; } } - CopyFilWrap(Rt, tex); + Rt.CopyFilWrap(tex); var blendTex = new BlendRenderTextureClass(Rt, abstractDecal.BlendTypeKey); blends.Add(blendTex); @@ -213,14 +213,7 @@ public void RegtAbstractDecal(AbstractDecal abstractDecal) ListPool.Release(TargetMats); } - internal static void CopyFilWrap(Texture t, Texture s) - { - t.filterMode = s.filterMode; - t.wrapMode = s.wrapMode; - t.wrapModeU = s.wrapModeU; - t.wrapModeV = s.wrapModeV; - t.wrapModeW = s.wrapModeW; - } + public bool IsRealTimePreview(AbstractDecal abstractDecal) => RealTimePreviews.ContainsKey(abstractDecal); public void UnRegtAbstractDecal(AbstractDecal abstractDecal) diff --git a/Runtime/IDomain.cs b/Runtime/IDomain.cs index 95917fee..267fa7b5 100644 --- a/Runtime/IDomain.cs +++ b/Runtime/IDomain.cs @@ -66,12 +66,14 @@ public static RenderTexture GetOriginTempRt(this IOriginTexture origin, Texture2 { var originSize = origin.GetOriginalTextureSize(texture2D); var tempRt = RenderTexture.GetTemporary(originSize, originSize, 0); + tempRt.CopyFilWrap(texture2D); origin.WriteOriginalTexture(texture2D, tempRt); return tempRt; } public static RenderTexture GetOriginTempRt(this IOriginTexture origin, Texture2D texture2D, int size) { var tempRt = RenderTexture.GetTemporary(size, size, 0); + tempRt.CopyFilWrap(texture2D); tempRt.Clear(); origin.WriteOriginalTexture(texture2D, tempRt); return tempRt; diff --git a/Runtime/TextureAtlas/AtlasShaderSupport/AtlasShaderSupportUtils.cs b/Runtime/TextureAtlas/AtlasShaderSupport/AtlasShaderSupportUtils.cs index 835ae003..d475f1eb 100644 --- a/Runtime/TextureAtlas/AtlasShaderSupport/AtlasShaderSupportUtils.cs +++ b/Runtime/TextureAtlas/AtlasShaderSupport/AtlasShaderSupportUtils.cs @@ -25,7 +25,7 @@ public static void Initialize() { s_defaultSupporter = ScriptableObject.CreateInstance(); s_defaultSupporter.SupportedShaderComparer = new AnythingShader(); - s_defaultSupporter.AtlasTargetDefines = new() { new() { TexturePropertyName = "_MainTex", AtlasDefineConstraints = new Anything() } }; + s_defaultSupporter.AtlasTargetDefines = new() { new() { TexturePropertyName = "_MainTex", AtlasDefineConstraints = new Anything(), BakePropertyNames = new() } }; } atlasShaderSupportList.Add(s_defaultSupporter); diff --git a/Runtime/TextureAtlas/AtlasTexture.cs b/Runtime/TextureAtlas/AtlasTexture.cs index 2fae655e..813bafc8 100644 --- a/Runtime/TextureAtlas/AtlasTexture.cs +++ b/Runtime/TextureAtlas/AtlasTexture.cs @@ -355,7 +355,7 @@ Dictionary ZipDictAndOffset(IEnumerable i.Value.Texture2D != null) == false) { continue; } var atlasTex = kv.First(i => i.Value.Texture2D != null).Value; - if (atlasTex.TextureScale == Vector2.zero && atlasTex.TextureTranslation == Vector2.zero) + if (atlasTex.TextureScale == Vector2.one && atlasTex.TextureTranslation == Vector2.zero) { dict[kv.Key] = texManage.GetOriginTempRt(atlasTex.Texture2D); } @@ -416,9 +416,17 @@ Dictionary ZipDictAndOffset(IEnumerable Date: Wed, 10 Apr 2024 15:50:57 +0900 Subject: [PATCH 2/2] chore: update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f29edc2..6cb706ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - GameObject から TexTransTool のほとんどのコンポーネントが追加できるようになりました (#411) - AtlasTexture に強制的に優先度のサイズに変更する ForcePrioritySize が追加されました (#431) - AtlasTexture 複数のマテリアルが衝突しないテクスチャを持つ場合に、同一のアイランドが割り当てられるようになりました (#431) +- AtlasTexture が Scale Transition(Tiling) を使用しているマテリアルのテクスチャを逆補正する機能が追加されました (#431 #435) ### Changed