From 4503e332dd8a86edda0bbb9f3a522b32e28f8560 Mon Sep 17 00:00:00 2001 From: Maikeu Locatelli Date: Wed, 13 Mar 2019 16:40:32 -0300 Subject: [PATCH] Fix Textures when Empty --- Assets/Scripts/General/TextureManager.cs | 32 ++++++++++-------------- ProjectSettings/ProjectSettings.asset | 9 ++++--- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/Assets/Scripts/General/TextureManager.cs b/Assets/Scripts/General/TextureManager.cs index dc814065..a21650c6 100644 --- a/Assets/Scripts/General/TextureManager.cs +++ b/Assets/Scripts/General/TextureManager.cs @@ -189,7 +189,7 @@ public void SetFullMaterial() } else { - FullMaterialInstance.SetTexture(HeightMapId, Texture2D.blackTexture); + FullMaterialInstance.SetTexture(HeightMapId, null); } if (DiffuseMap != null) @@ -207,12 +207,10 @@ public void SetFullMaterial() // ReSharper disable once StringLiteralTypo FullMaterialInstance.EnableKeyword("_NORMALMAP"); StartCoroutine(PackNormalAndSet()); - - } else { - FullMaterialInstance.SetTexture(NormalMapId, Texture2D.normalTexture); + FullMaterialInstance.SetTexture(NormalMapId, null); } if (MaskMap) @@ -223,7 +221,7 @@ public void SetFullMaterial() } else { - FullMaterialInstance.SetTexture(MaskMapId, _blackTexture); + FullMaterialInstance.SetTexture(MaskMapId, null); } ProgramManager.Instance.TestObject.GetComponent().material = FullMaterialInstance; @@ -239,7 +237,7 @@ private IEnumerator PackNormalAndSet() PackNormalCompute.SetTexture(kernel, "NormalInput", NormalMap); PackNormalCompute.SetTexture(kernel, "Result", tempRenderTexture); PackNormalCompute.Dispatch(kernel, size.x / 8, size.y / 8, 1); - + yield return null; GetTextureFromRender(tempRenderTexture, out _packedNormal); FullMaterialInstance.SetTexture(NormalMapId, _packedNormal); @@ -247,17 +245,10 @@ private IEnumerator PackNormalAndSet() public Texture2D GetStandardTexture(int width, int height, bool linear = true) { - if (Hdr) - { - return GetStandardHdrTexture(width, height, linear); - } - else - { - return GetStandardLdrTexture(width, height, linear); - } + return Hdr ? GetStandardHdrTexture(width, height, linear) : GetStandardLdrTexture(width, height, linear); } - public static Texture2D GetStandardHdrTexture(int width, int height, bool linear = true) + private static Texture2D GetStandardHdrTexture(int width, int height, bool linear = true) { var texture = new Texture2D(width, height, DefaultHdrTextureFormat, true, linear) { @@ -268,7 +259,7 @@ public static Texture2D GetStandardHdrTexture(int width, int height, bool linear } - public static Texture2D GetStandardLdrTexture(int width, int height, bool linear = true) + private static Texture2D GetStandardLdrTexture(int width, int height, bool linear = true) { var texture = new Texture2D(width, height, DefaultLdrTextureFormat, true, linear) { @@ -298,12 +289,12 @@ public void GetTextureFromRender(RenderTexture input, ProgramEnums.MapType mapTy GetTextureFromRender(input, mapType, out _); } - public void GetTextureFromRender(RenderTexture input, out Texture2D outTexture) + private void GetTextureFromRender(RenderTexture input, out Texture2D outTexture) { GetTextureFromRender(input, ProgramEnums.MapType.None, out outTexture); } - public void GetTextureFromRender(RenderTexture input, ProgramEnums.MapType mapType, out Texture2D outTexture) + private void GetTextureFromRender(RenderTexture input, ProgramEnums.MapType mapType, out Texture2D outTexture) { RenderTexture.active = input; var texture = GetStandardTexture(input.width, input.height); @@ -465,6 +456,7 @@ public void ClearTexture(ProgramEnums.MapType mapType) } } + [UsedImplicitly] public void ClearAllButtonCallback() { ClearAllTextures(); @@ -542,17 +534,19 @@ public void FixSize() FixSizeSize(size.x, size.y); } + [UsedImplicitly] public static void FixSizeMap(Texture mapToUse) { FixSizeSize(mapToUse.width, mapToUse.height); } + [UsedImplicitly] public static void FixSizeMap(RenderTexture mapToUse) { FixSizeSize(mapToUse.width, mapToUse.height); } - public static void FixSizeSize(float width, float height) + private static void FixSizeSize(float width, float height) { var testObjectScale = new Vector3(1, 1, 1); const float area = 1.0f; diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 1c851f59..c6306481 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -113,7 +113,7 @@ PlayerSettings: switchNVNShaderPoolsGranularity: 33554432 switchNVNDefaultPoolsGranularity: 16777216 switchNVNOtherPoolsGranularity: 16777216 - vulkanEnableSetSRGBWrite: 0 + vulkanEnableSetSRGBWrite: 1 m_SupportedAspectRatios: 4:3: 0 5:4: 0 @@ -334,8 +334,11 @@ PlayerSettings: m_APIs: 15000000 m_Automatic: 0 - m_BuildTarget: WindowsStandaloneSupport - m_APIs: 02000000 - m_Automatic: 1 + m_APIs: 020000001500000012000000 + m_Automatic: 0 + - m_BuildTarget: MacStandaloneSupport + m_APIs: 10000000 + m_Automatic: 0 m_BuildTargetVRSettings: [] m_BuildTargetEnableVuforiaSettings: [] openGLRequireES31: 0