Skip to content

Commit

Permalink
impl
Browse files Browse the repository at this point in the history
  • Loading branch information
ousttrue committed Mar 16, 2021
1 parent adfc294 commit 3f597d3
Showing 1 changed file with 35 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,13 @@ public static Texture2D Import(Texture2D metallicRoughnessTexture,
{
if (metallicRoughnessTexture != null && occlusionTexture != null)
{
if (metallicRoughnessTexture != occlusionTexture)
if (metallicRoughnessTexture == occlusionTexture)
{
var copyMetallicRoughness = TextureConverter.CopyTexture(metallicRoughnessTexture, glTFTextureTypes.OcclusionMetallicRoughness, null);
var metallicRoughnessPixels = copyMetallicRoughness.GetPixels32();
var copyOcclusion = TextureConverter.CopyTexture(occlusionTexture, glTFTextureTypes.OcclusionMetallicRoughness, null);
var occlusionPixels = copyOcclusion.GetPixels32();
if (metallicRoughnessPixels.Length != occlusionPixels.Length)
{
throw new NotImplementedException();
}
for (int i = 0; i < metallicRoughnessPixels.Length; ++i)
{
metallicRoughnessPixels[i] = ImportPixel(metallicRoughnessPixels[i], metallicFactor, roughnessFactor, occlusionPixels[i]);
metallicRoughnessPixels[i] = ImportPixel(metallicRoughnessPixels[i], metallicFactor, roughnessFactor, metallicRoughnessPixels[i]);
}
copyMetallicRoughness.SetPixels32(metallicRoughnessPixels);
copyMetallicRoughness.Apply();
Expand All @@ -49,9 +43,15 @@ public static Texture2D Import(Texture2D metallicRoughnessTexture,
{
var copyMetallicRoughness = TextureConverter.CopyTexture(metallicRoughnessTexture, glTFTextureTypes.OcclusionMetallicRoughness, null);
var metallicRoughnessPixels = copyMetallicRoughness.GetPixels32();
var copyOcclusion = TextureConverter.CopyTexture(occlusionTexture, glTFTextureTypes.OcclusionMetallicRoughness, null);
var occlusionPixels = copyOcclusion.GetPixels32();
if (metallicRoughnessPixels.Length != occlusionPixels.Length)
{
throw new NotImplementedException();
}
for (int i = 0; i < metallicRoughnessPixels.Length; ++i)
{
metallicRoughnessPixels[i] = ImportPixel(metallicRoughnessPixels[i], metallicFactor, roughnessFactor, metallicRoughnessPixels[i]);
metallicRoughnessPixels[i] = ImportPixel(metallicRoughnessPixels[i], metallicFactor, roughnessFactor, occlusionPixels[i]);
}
copyMetallicRoughness.SetPixels32(metallicRoughnessPixels);
copyMetallicRoughness.Apply();
Expand Down Expand Up @@ -94,18 +94,33 @@ public static Texture2D Export(Texture metallicSmoothTexture, float smoothness,
{
if (metallicSmoothTexture != null && occlusionTexture != null)
{
if (metallicSmoothTexture != occlusionTexture)
{
throw new NotImplementedException();
}
else
if (metallicSmoothTexture == occlusionTexture)
{
var copyTexture = TextureConverter.CopyTexture(metallicSmoothTexture, glTFTextureTypes.OcclusionMetallicRoughness, null);
copyTexture.SetPixels32(copyTexture.GetPixels32().Select(x => ExportPixel(x, smoothness, x)).ToArray());
copyTexture.Apply();
copyTexture.name = metallicSmoothTexture.name;
return copyTexture;
}
else
{
var copyMetallicSmooth = TextureConverter.CopyTexture(metallicSmoothTexture, glTFTextureTypes.OcclusionMetallicRoughness, null);
var metallicSmoothPixels = copyMetallicSmooth.GetPixels32();
var copyOcclusion = TextureConverter.CopyTexture(occlusionTexture, glTFTextureTypes.OcclusionMetallicRoughness, null);
var occlusionPixels = copyOcclusion.GetPixels32();
if (metallicSmoothPixels.Length != occlusionPixels.Length)
{
throw new NotImplementedException();
}
for (int i = 0; i < metallicSmoothPixels.Length; ++i)
{
metallicSmoothPixels[i] = ExportPixel(metallicSmoothPixels[i], smoothness, occlusionPixels[i]);
}
copyMetallicSmooth.SetPixels32(metallicSmoothPixels);
copyMetallicSmooth.Apply();
copyMetallicSmooth.name = metallicSmoothTexture.name;
return copyMetallicSmooth;
}
}
else if (metallicSmoothTexture)
{
Expand All @@ -117,11 +132,15 @@ public static Texture2D Export(Texture metallicSmoothTexture, float smoothness,
}
else if (occlusionTexture)
{
throw new NotImplementedException();
var copyTexture = TextureConverter.CopyTexture(occlusionTexture, glTFTextureTypes.OcclusionMetallicRoughness, null);
copyTexture.SetPixels32(copyTexture.GetPixels32().Select(x => ExportPixel(default, smoothness, x)).ToArray());
copyTexture.Apply();
copyTexture.name = occlusionTexture.name;
return copyTexture;
}
else
{
throw new NotImplementedException();
throw new ArgumentNullException();
}
}

Expand Down

0 comments on commit 3f597d3

Please sign in to comment.