Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Commit

Permalink
Fixed DXT5 normal decode
Browse files Browse the repository at this point in the history
  • Loading branch information
ousttrue committed Aug 22, 2018
1 parent b6d3730 commit bdfd1b4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Core/Scripts/IO/TextureIO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,17 @@ struct BytesWithPath
//public string Path;
public string Mime;

public BytesWithPath(Texture texture)
public BytesWithPath(Texture texture, bool isNormalMap)
{
//Path = "";
Bytes = TextureItem.CopyTexture(texture).EncodeToPNG();
Bytes = TextureItem.CopyTexture(texture, isNormalMap).EncodeToPNG();
Mime = "image/png";
}
}

public static int ExportTexture(glTF gltf, int bufferIndex, Texture texture, bool isNormalMap)
{
var bytesWithPath = new BytesWithPath(texture); ;
var bytesWithPath = new BytesWithPath(texture, isNormalMap); ;

// add view
var view = gltf.buffers[bufferIndex].Append(bytesWithPath.Bytes, glBufferTarget.NONE);
Expand Down
6 changes: 3 additions & 3 deletions Core/Scripts/IO/TextureItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public Texture2D GetMetallicRoughnessOcclusionConverted()
{
if (m_metallicRoughnessOcclusion == null)
{
var texture = CopyTexture(Texture);
var texture = CopyTexture(Texture, false);
texture.SetPixels32(texture.GetPixels32().Select(ConvertMetallicRoughnessOcclusion).ToArray());
texture.name = this.Texture.name + ".metallicRoughnessOcclusion";
m_metallicRoughnessOcclusion = texture;
Expand Down Expand Up @@ -241,15 +241,15 @@ static Material GetDecodeDxt5()
return s_dxt5decode;
}

public static Texture2D CopyTexture(Texture src)
public static Texture2D CopyTexture(Texture src, bool isNormal)
{
Texture2D dst = null;

var renderTexture = new RenderTexture(src.width, src.height, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB);

using (var scope = new sRGBScope(true))
{
if (IsDxt5(src))
if (isNormal && IsDxt5(src))
{
var mat = GetDecodeDxt5();
Graphics.Blit(src, renderTexture, mat);
Expand Down

0 comments on commit bdfd1b4

Please sign in to comment.