mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-05-18 00:30:42 -05:00
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:
commit
38eea5ff15
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
|||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user