diff --git a/Assets/VRM/UniGLTF/Resources/Shaders/NormalMapEncoder.shader b/Assets/VRM/UniGLTF/Resources/Shaders/NormalMapEncoder.shader index 02096bc54..c4d5fc6a5 100644 --- a/Assets/VRM/UniGLTF/Resources/Shaders/NormalMapEncoder.shader +++ b/Assets/VRM/UniGLTF/Resources/Shaders/NormalMapEncoder.shader @@ -42,6 +42,12 @@ fixed4 frag(v2f i) : SV_Target { half4 col = tex2D(_MainTex, i.uv); + +#if defined(UNITY_NO_DXT5nm) + // This is a trick from UnpackNormal in UnityCG.cginc !!!! + return col; +#endif + half4 normal; normal.x = 1.0; normal.y = col.y; diff --git a/Assets/VRM/UniGLTF/Scripts/IO/TextureConverter.cs b/Assets/VRM/UniGLTF/Scripts/IO/TextureConverter.cs index 94d2d95b1..b10e27682 100644 --- a/Assets/VRM/UniGLTF/Scripts/IO/TextureConverter.cs +++ b/Assets/VRM/UniGLTF/Scripts/IO/TextureConverter.cs @@ -111,22 +111,20 @@ namespace UniGLTF return m_encoder; } + // GLTF data to Unity texture + // ConvertToNormalValueFromRawColorWhenCompressionIsRequired public Texture2D GetImportTexture(Texture2D texture) { -#if UNITY_WEBGL && !UNITY_EDITOR - return texture; -#endif var mat = GetEncoder(); var converted = TextureConverter.Convert(texture, glTFTextureTypes.Normal, null, mat); TextureConverter.AppendTextureExtension(converted, m_extension); return converted; } + // Unity texture to GLTF data + // ConvertToRawColorWhenNormalValueIsCompressed public Texture2D GetExportTexture(Texture2D texture) { -#if UNITY_WEBGL && !UNITY_EDITOR - return texture; -#endif var mat = GetDecoder(); var converted = TextureConverter.Convert(texture, glTFTextureTypes.Normal, null, mat); TextureConverter.RemoveTextureExtension(converted, m_extension); @@ -174,4 +172,4 @@ namespace UniGLTF }; } } -} \ No newline at end of file +}