Merge pull request #139 from dwango/feature/fix_shaders_for_any_platforms

Fix normal maps are broken on Android(and also iOS) platforms
This commit is contained in:
yutopp 2019-01-25 15:07:20 +09:00 committed by GitHub
commit 38eea5ff15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 7 deletions

View File

@ -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;

View File

@ -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
};
}
}
}
}