Merge pull request #218 from dwango/fix/propage_texture_properties

問題無いです
This commit is contained in:
hiroj
2019-03-13 17:23:34 +09:00
committed by GitHub
4 changed files with 56 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
using NUnit.Framework;
using UnityEngine;
namespace UniGLTF
{
public class TextureTests
{
[Test]
public void TextureExportTest()
{
// Dummy texture
var tex0 = new Texture2D(128, 128)
{
wrapMode = TextureWrapMode.Clamp,
filterMode = FilterMode.Trilinear,
};
var textureManager = new TextureExportManager(new Texture[] {tex0});
var material = new Material(Shader.Find("Standard"));
material.mainTexture = tex0;
var materialExporter = new MaterialExporter();
materialExporter.ExportMaterial(material, textureManager);
var convTex0 = textureManager.GetExportTexture(0);
var sampler = TextureSamplerUtil.Export(convTex0);
Assert.AreEqual(glWrap.CLAMP_TO_EDGE, sampler.wrapS);
Assert.AreEqual(glWrap.CLAMP_TO_EDGE, sampler.wrapT);
Assert.AreEqual(glFilter.LINEAR_MIPMAP_LINEAR, sampler.minFilter);
Assert.AreEqual(glFilter.LINEAR_MIPMAP_LINEAR, sampler.magFilter);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 195a45a1caf480e41a7af798f30520f0
timeCreated: 1552296844
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -283,6 +283,15 @@ namespace UniGLTF
dst = new Texture2D(src.width, src.height, TextureFormat.ARGB32, false, colorSpace == RenderTextureReadWrite.Linear);
dst.ReadPixels(new Rect(0, 0, src.width, src.height), 0, 0);
dst.name = src.name;
dst.anisoLevel = src.anisoLevel;
dst.filterMode = src.filterMode;
dst.mipMapBias = src.mipMapBias;
dst.wrapMode = src.wrapMode;
#if UNITY_2017_1_OR_NEWER
dst.wrapModeU = src.wrapModeU;
dst.wrapModeV = src.wrapModeV;
dst.wrapModeW = src.wrapModeW;
#endif
dst.Apply();
RenderTexture.active = null;

View File

@@ -225,6 +225,7 @@ namespace UniGLTF
case TextureWrapMode.Clamp:
return glWrap.CLAMP_TO_EDGE;
case (TextureWrapMode)(-1):
case TextureWrapMode.Repeat:
return glWrap.REPEAT;