mirror of
https://github.com/maxartz15/VertexAnimation.git
synced 2025-04-11 19:55:54 +02:00
GenerateTexture2DArray in ModelBaker
This commit is contained in:
parent
efc5c179e4
commit
e31ddd5631
@ -4,7 +4,7 @@ using UnityEditor;
|
|||||||
|
|
||||||
namespace TAO.VertexAnimation.Editor
|
namespace TAO.VertexAnimation.Editor
|
||||||
{
|
{
|
||||||
[CreateAssetMenu(fileName = "new ModelBaker", menuName = "VA_ModelBaker/ModelBaker", order = 400)]
|
[CreateAssetMenu(fileName = "new ModelBaker", menuName = "TAO/VertexAnimation/ModelBaker", order = 400)]
|
||||||
public class VA_ModelBaker : ScriptableObject
|
public class VA_ModelBaker : ScriptableObject
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
@ -23,6 +23,7 @@ namespace TAO.VertexAnimation.Editor
|
|||||||
|
|
||||||
// Output.
|
// Output.
|
||||||
public GameObject prefab = null;
|
public GameObject prefab = null;
|
||||||
|
public Texture2DArray positionMap = null;
|
||||||
public Material material = null;
|
public Material material = null;
|
||||||
public Mesh[] meshes = null;
|
public Mesh[] meshes = null;
|
||||||
public VA_AnimationBook book = null;
|
public VA_AnimationBook book = null;
|
||||||
@ -89,6 +90,8 @@ namespace TAO.VertexAnimation.Editor
|
|||||||
target.ConbineAndConvertGameObject();
|
target.ConbineAndConvertGameObject();
|
||||||
bakedData = target.Bake(animationClips, fps, textureWidth);
|
bakedData = target.Bake(animationClips, fps, textureWidth);
|
||||||
|
|
||||||
|
positionMap = VA_Texture2DArrayUtils.CreateTextureArray(bakedData.positionMaps.ToArray(), false, true, TextureWrapMode.Repeat, FilterMode.Point, 1, string.Format("{0}-PositionMap", name), true);
|
||||||
|
|
||||||
if (lodSettings.generate)
|
if (lodSettings.generate)
|
||||||
{
|
{
|
||||||
meshes = bakedData.mesh.GenerateLOD(lodSettings.LODCount(), lodSettings.GetQualitySettings());
|
meshes = bakedData.mesh.GenerateLOD(lodSettings.LODCount(), lodSettings.GetQualitySettings());
|
||||||
@ -105,16 +108,16 @@ namespace TAO.VertexAnimation.Editor
|
|||||||
{
|
{
|
||||||
AssetDatabaseUtils.RemoveChildAssets(this, new Object[2] { book, material });
|
AssetDatabaseUtils.RemoveChildAssets(this, new Object[2] { book, material });
|
||||||
|
|
||||||
// TODO: LODs
|
|
||||||
foreach (var m in meshes)
|
foreach (var m in meshes)
|
||||||
{
|
{
|
||||||
AssetDatabase.AddObjectToAsset(m, this);
|
AssetDatabase.AddObjectToAsset(m, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var pm in bakedData.positionMaps)
|
AssetDatabase.AddObjectToAsset(positionMap, this);
|
||||||
{
|
//foreach (var pm in bakedData.positionMaps)
|
||||||
AssetDatabase.AddObjectToAsset(pm, this);
|
//{
|
||||||
}
|
// AssetDatabase.AddObjectToAsset(pm, this);
|
||||||
|
//}
|
||||||
|
|
||||||
AssetDatabase.SaveAssets();
|
AssetDatabase.SaveAssets();
|
||||||
|
|
||||||
@ -176,6 +179,9 @@ namespace TAO.VertexAnimation.Editor
|
|||||||
material.shader = materialShader;
|
material.shader = materialShader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
material.SetTexture("_PositionMap", positionMap);
|
||||||
|
material.SetInt("_MaxFrames", bakedData.maxFrames);
|
||||||
|
|
||||||
// Generate Prefab
|
// Generate Prefab
|
||||||
prefab = AnimationPrefab.Create(path, name, meshes, material, lodSettings.GetTransitionSettings());
|
prefab = AnimationPrefab.Create(path, name, meshes, material, lodSettings.GetTransitionSettings());
|
||||||
}
|
}
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace TAO.VertexAnimation.Editor
|
|
||||||
{
|
|
||||||
[CreateAssetMenu(fileName = "new AssetConverter", menuName = "VA_Animation/AssetConverter", order = 400)]
|
|
||||||
public class VA_AssetConverter : ScriptableObject
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 55b196764521c964c84e8f2edd5c8da5
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -10,6 +10,7 @@ namespace TAO.VertexAnimation
|
|||||||
{
|
{
|
||||||
public Mesh mesh;
|
public Mesh mesh;
|
||||||
public List<Texture2D> positionMaps;
|
public List<Texture2D> positionMaps;
|
||||||
|
public int maxFrames;
|
||||||
|
|
||||||
// Returns main position map.
|
// Returns main position map.
|
||||||
public Texture2D GetPositionMap
|
public Texture2D GetPositionMap
|
||||||
@ -84,6 +85,7 @@ namespace TAO.VertexAnimation
|
|||||||
BakedData bd = Bake(model, ac, animationInfo);
|
BakedData bd = Bake(model, ac, animationInfo);
|
||||||
bakedData.mesh = bd.mesh;
|
bakedData.mesh = bd.mesh;
|
||||||
bakedData.positionMaps.AddRange(bd.positionMaps);
|
bakedData.positionMaps.AddRange(bd.positionMaps);
|
||||||
|
bakedData.maxFrames = maxFrames;
|
||||||
}
|
}
|
||||||
|
|
||||||
return bakedData;
|
return bakedData;
|
||||||
@ -106,7 +108,8 @@ namespace TAO.VertexAnimation
|
|||||||
BakedData bakedData = new BakedData()
|
BakedData bakedData = new BakedData()
|
||||||
{
|
{
|
||||||
mesh = mesh,
|
mesh = mesh,
|
||||||
positionMaps = new List<Texture2D>() { BakePositionMap(model, animationClip, animationInfo) }
|
positionMaps = new List<Texture2D>() { BakePositionMap(model, animationClip, animationInfo) },
|
||||||
|
maxFrames = animationInfo.maxFrames
|
||||||
};
|
};
|
||||||
|
|
||||||
return bakedData;
|
return bakedData;
|
||||||
|
@ -3,7 +3,7 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace TAO.VertexAnimation
|
namespace TAO.VertexAnimation
|
||||||
{
|
{
|
||||||
[CreateAssetMenu(fileName = "new AnimationBook", menuName = "VA_Animation/AnimationBook", order = 400)]
|
[CreateAssetMenu(fileName = "new AnimationBook", menuName = "TAO/VertexAnimation/AnimationBook", order = 400)]
|
||||||
public class VA_AnimationBook : ScriptableObject
|
public class VA_AnimationBook : ScriptableObject
|
||||||
{
|
{
|
||||||
public PlayData playData = null;
|
public PlayData playData = null;
|
||||||
|
@ -3,7 +3,7 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace TAO.VertexAnimation
|
namespace TAO.VertexAnimation
|
||||||
{
|
{
|
||||||
[CreateAssetMenu(fileName = "new AnimationLibrary", menuName = "VA_Animation/AnimationLibrary", order = 400)]
|
[CreateAssetMenu(fileName = "new AnimationLibrary", menuName = "TAO/VertexAnimation/AnimationLibrary", order = 400)]
|
||||||
public class VA_AnimationLibrary : ScriptableObject
|
public class VA_AnimationLibrary : ScriptableObject
|
||||||
{
|
{
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
|
@ -5,7 +5,7 @@ namespace TAO.VertexAnimation
|
|||||||
public static class VA_Texture2DArrayUtils
|
public static class VA_Texture2DArrayUtils
|
||||||
{
|
{
|
||||||
public static Texture2DArray CreateTextureArray(Texture2D[] a_textures, bool a_useMipChain, bool a_isLinear,
|
public static Texture2DArray CreateTextureArray(Texture2D[] a_textures, bool a_useMipChain, bool a_isLinear,
|
||||||
TextureWrapMode a_wrapMode = TextureWrapMode.Repeat, FilterMode a_filterMode = FilterMode.Bilinear, int a_anisoLevel = 1, string a_name = "")
|
TextureWrapMode a_wrapMode = TextureWrapMode.Repeat, FilterMode a_filterMode = FilterMode.Bilinear, int a_anisoLevel = 1, string a_name = "", bool a_makeNoLongerReadable = true)
|
||||||
{
|
{
|
||||||
if(!IsValidForTextureArray(a_textures) || !IsValidCopyTexturePlatform())
|
if(!IsValidForTextureArray(a_textures) || !IsValidCopyTexturePlatform())
|
||||||
{
|
{
|
||||||
@ -27,7 +27,7 @@ namespace TAO.VertexAnimation
|
|||||||
textureArray.anisoLevel = a_anisoLevel;
|
textureArray.anisoLevel = a_anisoLevel;
|
||||||
textureArray.name = a_name;
|
textureArray.name = a_name;
|
||||||
|
|
||||||
textureArray.Apply(false, false);
|
textureArray.Apply(false, a_makeNoLongerReadable);
|
||||||
|
|
||||||
return textureArray;
|
return textureArray;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user