From 35728334d366c5bc2c5010a01b332a043f3a38ae Mon Sep 17 00:00:00 2001 From: kenamis Date: Sun, 21 Jun 2020 15:54:25 -0700 Subject: [PATCH 1/2] reduce the initial renderTexture target based on downsample instead of reducing after rendering --- .../UMA/Scripts/TextureProcessPROCoroutine.cs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/UMAProject/Assets/UMA/Core/StandardAssets/UMA/Scripts/TextureProcessPROCoroutine.cs b/UMAProject/Assets/UMA/Core/StandardAssets/UMA/Scripts/TextureProcessPROCoroutine.cs index e198d68e9..e2a590ce9 100644 --- a/UMAProject/Assets/UMA/Core/StandardAssets/UMA/Scripts/TextureProcessPROCoroutine.cs +++ b/UMAProject/Assets/UMA/Core/StandardAssets/UMA/Scripts/TextureProcessPROCoroutine.cs @@ -105,7 +105,10 @@ protected override IEnumerator workerMethod() continue; } - destinationTexture = new RenderTexture(Mathf.FloorToInt(atlas.cropResolution.x * umaData.atlasResolutionScale), Mathf.FloorToInt(atlas.cropResolution.y * umaData.atlasResolutionScale), 0, slotData.asset.material.channels[textureType].textureFormat, RenderTextureReadWrite.Linear); + //this should be restricted to >= 1 but 0 was allowed before and projects may have the umaMaterial value serialized to 0. + float downSample = (slotData.asset.material.channels[textureType].DownSample == 0) ? 1f : (1f / slotData.asset.material.channels[textureType].DownSample); + + destinationTexture = new RenderTexture(Mathf.FloorToInt(atlas.cropResolution.x * umaData.atlasResolutionScale * downSample), Mathf.FloorToInt(atlas.cropResolution.y * umaData.atlasResolutionScale * downSample), 0, slotData.asset.material.channels[textureType].textureFormat, RenderTextureReadWrite.Linear); destinationTexture.filterMode = FilterMode.Point; destinationTexture.useMipMap = umaGenerator.convertMipMaps && !umaGenerator.convertRenderTexture; //Draw all the Rects here @@ -128,17 +131,6 @@ protected override IEnumerator workerMethod() //PostProcess textureMerge.PostProcess(destinationTexture, slotData.asset.material.channels[textureType].channelType); - int DownSample = slotData.asset.material.channels[textureType].DownSample; - if (DownSample != 0) - { - int newW = width >> DownSample; - int newH = height >> DownSample; - - RenderTexture rt = ResizeRenderTexture(destinationTexture, newW, newH, FilterMode.Bilinear); - destinationTexture.Release(); - destinationTexture = rt; - } - if (umaGenerator.convertRenderTexture || slotData.asset.material.channels[textureType].ConvertRenderTexture) { #region Convert Render Textures From b689c45a1560f66bffa905938dd1795bc52c57d2 Mon Sep 17 00:00:00 2001 From: kenamis Date: Sun, 21 Jun 2020 16:01:26 -0700 Subject: [PATCH 2/2] uncap the range on the DownSample variable --- .../Assets/UMA/Core/StandardAssets/UMA/Scripts/UMAMaterial.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UMAProject/Assets/UMA/Core/StandardAssets/UMA/Scripts/UMAMaterial.cs b/UMAProject/Assets/UMA/Core/StandardAssets/UMA/Scripts/UMAMaterial.cs index ad0f02b5a..e802249c2 100644 --- a/UMAProject/Assets/UMA/Core/StandardAssets/UMA/Scripts/UMAMaterial.cs +++ b/UMAProject/Assets/UMA/Core/StandardAssets/UMA/Scripts/UMAMaterial.cs @@ -76,7 +76,7 @@ public struct MaterialChannel public string materialPropertyName; public string sourceTextureName; public CompressionSettings Compression; - [Range(0,4)] + [Range(1,128)] public int DownSample; public bool ConvertRenderTexture; public bool NonShaderTexture;