Fixed for Entities 1.0

This commit is contained in:
Maximilian Winter 2022-12-04 04:18:35 +01:00
parent 4499f67f31
commit 6fde2095aa
17 changed files with 1059 additions and 331 deletions

View File

@ -14,25 +14,25 @@ namespace TAO.VertexAnimation.Editor
parent = PrefabUtility.LoadPrefabContents(path); parent = PrefabUtility.LoadPrefabContents(path);
// Check setup. // Check setup.
if (!parent.TryGetComponent(out LODGroup _)) //if (!parent.TryGetComponent(out LODGroup _))
{ //{
parent.AddComponent<LODGroup>(); // parent.AddComponent<LODGroup>();
} //}
if (!parent.TryGetComponent(out VA_AnimatorComponentAuthoring _)) //if (!parent.TryGetComponent(out VA_AnimatorComponentAuthoring _))
{ //{
parent.AddComponent<VA_AnimatorComponentAuthoring>(); // parent.AddComponent<VA_AnimatorComponentAuthoring>();
} //}
if (!parent.TryGetComponent(out Unity.Entities.ConvertToEntity _)) //if (!parent.TryGetComponent(out Unity.Entities.ConvertToEntity _))
{ //{
parent.AddComponent<Unity.Entities.ConvertToEntity>(); // parent.AddComponent<Unity.Entities.ConvertToEntity>();
} //}
} }
else else
{ {
// Create parent. // Create parent.
parent = new GameObject(name, typeof(LODGroup), typeof(VA_AnimatorComponentAuthoring), typeof(Unity.Entities.ConvertToEntity)); parent = new GameObject(name);
} }
// Create all LODs. // Create all LODs.
@ -66,16 +66,16 @@ namespace TAO.VertexAnimation.Editor
} }
child.transform.SetParent(parent.transform); child.transform.SetParent(parent.transform);
lods[i] = new LOD(lodTransitions[i], new Renderer[1] { mr }); //lods[i] = new LOD(lodTransitions[i], new Renderer[1] { mr });
} }
var lodGroup = parent.GetComponent<LODGroup>(); //var lodGroup = parent.GetComponent<LODGroup>();
lodGroup.SetLODs(lods); //lodGroup.SetLODs(lods);
lodGroup.RecalculateBounds(); //lodGroup.RecalculateBounds();
// Create prefab. // Create prefab.
GameObject prefab = PrefabUtility.SaveAsPrefabAssetAndConnect(parent, path, InteractionMode.AutomatedAction); GameObject prefab = PrefabUtility.SaveAsPrefabAssetAndConnect(parent, path, InteractionMode.AutomatedAction);
GameObject.DestroyImmediate(parent); //GameObject.DestroyImmediate(parent);
return prefab; return prefab;
} }

View File

@ -1,6 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEditor; using UnityEditor;
using UnityEngine.Experimental.Rendering;
namespace TAO.VertexAnimation.Editor namespace TAO.VertexAnimation.Editor
{ {
@ -155,6 +156,9 @@ namespace TAO.VertexAnimation.Editor
// Get info. // Get info.
NamingConventionUtils.PositionMapInfo info = bakedData.GetPositionMap.name.GetTextureInfo(); NamingConventionUtils.PositionMapInfo info = bakedData.GetPositionMap.name.GetTextureInfo();
bakedData.mesh.SetTriangles( bakedData.mesh.triangles, 0 );
meshes = new[] { bakedData.mesh };
// Generate Material // Generate Material
if (!AssetDatabaseUtils.HasChildAsset(this, material)) if (!AssetDatabaseUtils.HasChildAsset(this, material))
{ {

View File

@ -5,9 +5,103 @@
using UnityEngine; using UnityEngine;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEditor;
using UnityEngine.Rendering;
namespace TAO.VertexAnimation namespace TAO.VertexAnimation
{ {
public static class SkinnedMeshCombiner
{
public static GameObject Combine(this SkinnedMeshRenderer target, List<SkinnedMeshRenderer> skinnedMeshRenderers, string name, Vector3 position, Quaternion rotation, Vector3 scale)
{
List<BoneWeight> boneWeights = new List<BoneWeight>();
List<Transform> bones = new List<Transform>();
List<CombineInstance> combineInstances = new List<CombineInstance>();
Material sharedMaterial = skinnedMeshRenderers[0].sharedMaterial;
Bounds newBounds = skinnedMeshRenderers[0].bounds;
int num = 0;
for( int i = 0; i < skinnedMeshRenderers.Count; ++i )
{
SkinnedMeshRenderer skinnedMeshRenderer = skinnedMeshRenderers[i];
BoneWeight[] bws = skinnedMeshRenderer.sharedMesh.boneWeights;
Transform[] bs = skinnedMeshRenderer.bones;
for( int bwIndex = 0; bwIndex < bws.Length; ++bwIndex )
{
BoneWeight boneWeight = bws[bwIndex];
boneWeight.boneIndex0 += num;
boneWeight.boneIndex1 += num;
boneWeight.boneIndex2 += num;
boneWeight.boneIndex3 += num;
boneWeights.Add( boneWeight );
}
num += bs.Length;
for( int boneIndex = 0; boneIndex < bs.Length; ++boneIndex )
{
bones.Add( bs[boneIndex] );
}
CombineInstance combineInstance = new CombineInstance()
{
mesh = skinnedMeshRenderer.sharedMesh,
transform = skinnedMeshRenderer.transform.localToWorldMatrix
};
combineInstances.Add( combineInstance );
if ( i > 0 )
{
newBounds.Encapsulate( skinnedMeshRenderers[i].bounds );
}
//skinnedMeshRenderer.enabled = false;
}
List<Matrix4x4> bindposes = new List<Matrix4x4>();
for( int i = 0; i < bones.Count; ++i )
{
Transform bone = bones[i];
bindposes.Add( bone.worldToLocalMatrix * target.transform.worldToLocalMatrix );
}
SkinnedMeshRenderer combinedSkinnedMeshRenderer = target;
combinedSkinnedMeshRenderer.updateWhenOffscreen = false;
combinedSkinnedMeshRenderer.sharedMesh = new Mesh();
combinedSkinnedMeshRenderer.sharedMesh.indexFormat = IndexFormat.UInt32;
if ( combineInstances.Count == 1 )
{
combinedSkinnedMeshRenderer.sharedMesh = combineInstances[0].mesh;
}
else
{
combinedSkinnedMeshRenderer.sharedMesh.CombineMeshes( combineInstances.ToArray(), true, true );
}
foreach ( CombineInstance combineInstance in combineInstances )
{
combinedSkinnedMeshRenderer.sharedMesh.subMeshCount += combineInstance.mesh.subMeshCount;
}
combinedSkinnedMeshRenderer.sharedMaterials = new Material[combinedSkinnedMeshRenderer.sharedMesh.subMeshCount];
for ( int i = 0; i < combinedSkinnedMeshRenderer.sharedMesh.subMeshCount; i++ )
{
combinedSkinnedMeshRenderer.sharedMaterials[i] = sharedMaterial;
}
//combinedSkinnedMeshRenderer.sharedMaterial = sharedMaterial;
combinedSkinnedMeshRenderer.bones = bones.ToArray();
combinedSkinnedMeshRenderer.sharedMesh.boneWeights = boneWeights.ToArray();
combinedSkinnedMeshRenderer.sharedMesh.bindposes = bindposes.ToArray();
combinedSkinnedMeshRenderer.sharedMesh.RecalculateBounds();
//combinedSkinnedMeshRenderer.localBounds = new Bounds( new Vector3( 0.0f, 1.0f, 0.0f ), new Vector3( 0.5f, 1.0f, 0.5f ) );
//AssetDatabase.CreateAsset( combinedSkinnedMeshRenderer.sharedMesh, $"Assets/CombinedSkinnedMeshRendererPrefabs/{name}(Mesh{System.DateTime.Now:MM_dd_yyyy-H_mm}).asset" );
//AssetDatabase.SaveAssets();
return target.gameObject;
}
}
public static class MeshCombiner public static class MeshCombiner
{ {
private struct MaterialMeshGroup private struct MaterialMeshGroup
@ -262,7 +356,7 @@ namespace TAO.VertexAnimation
// Add target mesh. // Add target mesh.
SkinnedMeshRenderer target = gameObject.AddComponent<SkinnedMeshRenderer>(); SkinnedMeshRenderer target = gameObject.AddComponent<SkinnedMeshRenderer>();
target.Combine(skinnedMeshes, meshes); target.Combine(skinnedMeshes, gameObject.name, gameObject.transform.position, gameObject.transform.rotation, gameObject.transform.localScale);
} }
} }
} }

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: f43224daff50a5042a182c6fb12440a8 guid: e9d4c3f791214a29ac7c1238c9381900
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2

View File

@ -16,13 +16,13 @@ namespace TAO.VertexAnimation
public VA_AnimationData GetData() public VA_AnimationData GetData()
{ {
// TODO: Fix data name, FixedString32 doesn't transfer from editor? // TODO: Fix data name, FixedString32 doesn't transfer from editor?
Data.name = new FixedString64(name); Data.name = new FixedString64Bytes(name);
return Data; return Data;
} }
public FixedString64 GetName() public FixedString64Bytes GetName()
{ {
return new FixedString64(this.name); return new FixedString64Bytes(this.name);
} }
} }
} }

View File

@ -0,0 +1,21 @@
using Unity.Entities;
using Unity.Mathematics;
using UnityEngine;
namespace TAO.VertexAnimation
{
public class VA_AnimationDataComponentAuthoring : MonoBehaviour
{
public float4 Color;
}
public class VA_AnimationDataBaker : Baker < VA_AnimationDataComponentAuthoring >
{
public override void Bake( VA_AnimationDataComponentAuthoring authoring )
{
//Entity parent = GetEntity( authoring.RootParent );
AddComponent( new VaAnimationDataComponent{ Value = authoring.Color} );
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4fed86d3fa104b829db2922ca534f704
timeCreated: 1670034530

View File

@ -1,64 +1,100 @@
using Unity.Entities; using Unity.Entities;
using Unity.Collections; using Unity.Collections;
using UnityEngine;
using Hash128 = Unity.Entities.Hash128;
namespace TAO.VertexAnimation namespace TAO.VertexAnimation
{ {
[UnityEngine.RequireComponent(typeof(ConvertToEntity))] [UnityEngine.DisallowMultipleComponent]
[UnityEngine.DisallowMultipleComponent]
public class VA_AnimationLibraryComponentAuthoring : UnityEngine.MonoBehaviour public class VA_AnimationLibraryComponentAuthoring : UnityEngine.MonoBehaviour
{ {
public VA_AnimationLibrary animationLibrary; public VA_AnimationLibrary AnimationLibrary;
public bool debugMode = false; public bool DebugMode = false;
} }
public class VA_AnimationLibraryConversionSystem : GameObjectConversionSystem internal struct SkinnedMeshEntity : IBufferElementData
{
public Entity Value;
}
public struct VA_AnimationLibraryComponent : IComponentData
{
public BlobAssetReference<VA_AnimationLibraryData> AnimLibAssetRef;
public BlobAssetStore BlobAssetStore;
}
public class VA_AnimationLibraryComponentBaker : Baker < VA_AnimationLibraryComponentAuthoring >
{
public override void Bake( VA_AnimationLibraryComponentAuthoring authoring )
{ {
// Static because of multi scene setup. authoring.AnimationLibrary.Init();
public static BlobAssetReference<VA_AnimationLibraryData> animLibAssetRef; VA_AnimationLibraryComponent animationLibrary = new VA_AnimationLibraryComponent();
using (BlobBuilder blobBuilder = new BlobBuilder(Allocator.Temp))
protected override void OnUpdate()
{ {
Entities.ForEach((VA_AnimationLibraryComponentAuthoring animationLib) => // Construct the root.
ref VA_AnimationLibraryData animationDataBlobAsset = ref blobBuilder.ConstructRoot<VA_AnimationLibraryData>();
// Set all the data.
BlobBuilderArray<VA_AnimationData> animationDataArray = blobBuilder.Allocate(ref animationDataBlobAsset.animations, authoring.AnimationLibrary.animationData.Count);
for (int i = 0; i < animationDataArray.Length; i++)
{ {
animationLib.animationLibrary.Init(); // Copy data.
animationDataArray[i] = authoring.AnimationLibrary.animationData[i];
// Blob builder to build. if (authoring.DebugMode)
using (BlobBuilder blobBuilder = new BlobBuilder(Allocator.Temp))
{ {
// Construct the root. UnityEngine.Debug.Log("VA_AnimationLibrary added " + animationDataArray[i].name.ToString());
ref VA_AnimationLibraryData animationDataBlobAsset = ref blobBuilder.ConstructRoot<VA_AnimationLibraryData>();
// Set all the data.
BlobBuilderArray<VA_AnimationData> animationDataArray = blobBuilder.Allocate(ref animationDataBlobAsset.animations, animationLib.animationLibrary.animationData.Count);
for (int i = 0; i < animationDataArray.Length; i++)
{
// Copy data.
animationDataArray[i] = animationLib.animationLibrary.animationData[i];
if (animationLib.debugMode)
{
UnityEngine.Debug.Log("VA_AnimationLibrary added " + animationDataArray[i].name.ToString());
}
}
// Construct blob asset reference.
//BlobAssetReference<VA_AnimationLibraryData> animLibAssetRef = blobBuilder.CreateBlobAssetReference<VA_AnimationLibraryData>(Allocator.Persistent);
// Static because of multi scene setup.
animLibAssetRef = blobBuilder.CreateBlobAssetReference<VA_AnimationLibraryData>(Allocator.Persistent);
// Add it to the asset store.
BlobAssetStore.TryAdd(new Hash128(VA_AnimationLibraryUtils.AnimationLibraryAssetStoreName), animLibAssetRef);
if (animationLib.debugMode)
{
UnityEngine.Debug.Log("VA_AnimationLibrary has " + animLibAssetRef.Value.animations.Length.ToString() + " animations.");
}
} }
}
// Remove the entity since we don't need it anymore. // Construct blob asset reference.
DstEntityManager.DestroyEntity(GetPrimaryEntity(animationLib)); //BlobAssetReference<VA_AnimationLibraryData> animLibAssetRef = blobBuilder.CreateBlobAssetReference<VA_AnimationLibraryData>(Allocator.Persistent);
}); // Static because of multi scene setup.
animationLibrary.AnimLibAssetRef = blobBuilder.CreateBlobAssetReference<VA_AnimationLibraryData>(Allocator.Persistent);
Hash128 hash128 = new Hash128( VA_AnimationLibraryUtils.AnimationLibraryAssetStoreName );
// Add it to the asset store.
animationLibrary.BlobAssetStore = new BlobAssetStore( 50);
animationLibrary.BlobAssetStore.TryAdd(hash128, ref animationLibrary.AnimLibAssetRef);
if (authoring.DebugMode)
{
UnityEngine.Debug.Log("VA_AnimationLibrary has " + animationLibrary.AnimLibAssetRef.Value.animations.Length.ToString() + " animations.");
}
}
AddComponent( animationLibrary );
BlobAssetReference<VA_AnimationLibraryData> animLib = animationLibrary.AnimLibAssetRef;
// Add animator to 'parent'.
VA_AnimatorComponent animatorComponent = new VA_AnimatorComponent
{
animationIndex = 0,
animationIndexNext = -1,
animationTime = 0,
animationLibrary = animLib
};
AddComponent(animatorComponent);
var boneEntityArray = AddBuffer<SkinnedMeshEntity>();
MeshRenderer[] skinnedMeshRenderers =
authoring.transform.GetComponentsInChildren < MeshRenderer >();
boneEntityArray.ResizeUninitialized(skinnedMeshRenderers.Length);
for (int boneIndex = 0; boneIndex < skinnedMeshRenderers.Length; ++boneIndex)
{
var boneEntity = GetEntity(skinnedMeshRenderers[boneIndex]);
boneEntityArray[boneIndex] = new SkinnedMeshEntity {Value = boneEntity};
} }
} }
}
//[GenerateAuthoringComponent]
public struct VA_AnimatorComponent : IComponentData
{
public int animationIndex;
public int animationIndexNext;
public float animationTime;
public BlobAssetReference<VA_AnimationLibraryData> animationLibrary;
}
} }

View File

@ -6,7 +6,7 @@ namespace TAO.VertexAnimation
[System.Serializable] [System.Serializable]
public struct VA_AnimationData public struct VA_AnimationData
{ {
public VA_AnimationData(FixedString64 a_name, int a_frames, int a_maxFrames, int a_fps, int a_positionMapIndex, int a_colorMapIndex = -1) public VA_AnimationData(FixedString64Bytes a_name, int a_frames, int a_maxFrames, int a_fps, int a_positionMapIndex, int a_colorMapIndex = -1)
{ {
name = a_name; name = a_name;
frames = a_frames; frames = a_frames;
@ -18,7 +18,7 @@ namespace TAO.VertexAnimation
} }
// The name of the animation. // The name of the animation.
public FixedString64 name; public FixedString64Bytes name;
// The frames in this animation. // The frames in this animation.
public int frames; public int frames;
// The maximum of frames the texture holds. // The maximum of frames the texture holds.
@ -42,7 +42,7 @@ namespace TAO.VertexAnimation
{ {
public const string AnimationLibraryAssetStoreName = "VA_AnimationLibrary"; public const string AnimationLibraryAssetStoreName = "VA_AnimationLibrary";
public static int GetAnimation(ref VA_AnimationLibraryData animationsRef, FixedString64 animationName) public static int GetAnimation(ref VA_AnimationLibraryData animationsRef, FixedString64Bytes animationName)
{ {
for (int i = 0; i < animationsRef.animations.Length; i++) for (int i = 0; i < animationsRef.animations.Length; i++)
{ {

View File

@ -5,54 +5,5 @@ using UnityEngine;
namespace TAO.VertexAnimation namespace TAO.VertexAnimation
{ {
[DisallowMultipleComponent]
public class VA_AnimatorComponentAuthoring : MonoBehaviour
{
}
//[GenerateAuthoringComponent]
public struct VA_AnimatorComponent : IComponentData
{
public int animationIndex;
public int animationIndexNext;
public float animationTime;
public BlobAssetReference<VA_AnimationLibraryData> animationLibrary;
}
[UpdateAfter(typeof(VA_AnimationLibraryConversionSystem))]
public class VA_AnimatorConversionSystem : GameObjectConversionSystem
{
protected override void OnUpdate()
{
//BlobAssetStore.TryGet(new Unity.Entities.Hash128(VA_AnimationLibraryUtils.AnimationLibraryAssetStoreName), out BlobAssetReference<VA_AnimationLibraryData> animLib);
// Static because of multi scene setup.
BlobAssetReference<VA_AnimationLibraryData> animLib = VA_AnimationLibraryConversionSystem.animLibAssetRef;
Entities.ForEach((VA_AnimatorComponentAuthoring animator) =>
{
Entity entity = GetPrimaryEntity(animator);
// Add animator to 'parent'.
VA_AnimatorComponent animatorComponent = new VA_AnimatorComponent
{
animationIndex = 0,
animationIndexNext = -1,
animationTime = 0,
animationLibrary = animLib
};
DstEntityManager.AddComponentData(entity, animatorComponent);
// Add the Material data to the children.
var children = animator.GetComponentsInChildren<MeshRenderer>();
for (int i = 0; i < children.Length; i++)
{
Entity ent = GetPrimaryEntity(children[i]);
VA_AnimationDataComponent animationData = new VA_AnimationDataComponent();
DstEntityManager.AddComponentData(ent, animationData);
}
});
}
}
} }

View File

@ -1,58 +1,52 @@
using Unity.Entities; using System.Collections.Generic;
using Unity.Entities;
using Unity.Transforms; using Unity.Transforms;
using Unity.Mathematics; using Unity.Mathematics;
namespace TAO.VertexAnimation namespace TAO.VertexAnimation
{ {
// System to update all the animations. // System to update all the animations.
public class VA_AnimatorSystem : SystemBase public partial class VA_AnimatorSystem : SystemBase
{ {
protected override void OnUpdate() protected override void OnUpdate()
{ {
var animationData = GetComponentDataFromEntity<VA_AnimationDataComponent>(false); // This is only executed if we have a valid skinning setup
Entities
Entities.ForEach((ref VA_AnimatorComponent ac, in DynamicBuffer<Child> children) => .ForEach((VA_AnimatorComponent animator, in DynamicBuffer<SkinnedMeshEntity> bones) =>
{
for (int i = 0; i < children.Length; i++)
{ {
// Get child.
Entity child = children[i].Value;
// Get the animation lib data. // Get the animation lib data.
ref VA_AnimationLibraryData animationsRef = ref ac.animationLibrary.Value; ref VA_AnimationLibraryData animationsRef = ref animator.animationLibrary.Value;
// Lerp animations. // Lerp animations.
// Set animation for lerp. // Set animation for lerp.
int animationIndexNext = ac.animationIndexNext; int animationIndexNext = animator.animationIndexNext;
if (ac.animationIndexNext < 0) if (animator.animationIndexNext < 0)
{ {
animationIndexNext = ac.animationIndex; animationIndexNext = animator.animationIndex;
//animator.animationIndexNext = animationIndexNext + 1;
} }
// Calculate next frame time for lerp. // Calculate next frame time for lerp.
float animationTimeNext = ac.animationTime + (1.0f / animationsRef.animations[animationIndexNext].maxFrames); float animationTimeNext = animator.animationTime + (1.0f / animationsRef.animations[animationIndexNext].maxFrames);
if (animationTimeNext > animationsRef.animations[animationIndexNext].duration) if (animationTimeNext > animationsRef.animations[animationIndexNext].duration)
{ {
// Set time. Using the difference to smooth out animations when looping. // Set time. Using the difference to smooth out animations when looping.
animationTimeNext -= ac.animationTime; animationTimeNext -= animator.animationTime;
} }
// Set material data. for ( int i = 0; i < bones.Length; i++ )
animationData[child] = new VA_AnimationDataComponent
{ {
Value = new float4 VaAnimationDataComponent vaAnimationDataComponent = new VaAnimationDataComponent();
vaAnimationDataComponent.Value = new float4
{ {
x = ac.animationTime, x = animator.animationTime,
y = VA_AnimationLibraryUtils.GetAnimationMapIndex(ref animationsRef, ac.animationIndex), y = VA_AnimationLibraryUtils.GetAnimationMapIndex( ref animationsRef, animator.animationIndex ),
z = animationTimeNext, z = animationTimeNext,
w = VA_AnimationLibraryUtils.GetAnimationMapIndex(ref animationsRef, animationIndexNext) w = VA_AnimationLibraryUtils.GetAnimationMapIndex( ref animationsRef, animationIndexNext )
} };
}; SystemAPI.SetComponent<VaAnimationDataComponent>( bones[i].Value, vaAnimationDataComponent );
} }
}) }).Run();
.WithNativeDisableContainerSafetyRestriction(animationData)
.WithName("VA_AnimatorSystem")
.ScheduleParallel();
} }
} }
} }

View File

@ -4,10 +4,12 @@ using Unity.Rendering;
namespace TAO.VertexAnimation namespace TAO.VertexAnimation
{ {
[MaterialProperty("_AnimationData", MaterialPropertyFormat.Float4)] [MaterialProperty("_AnimationData")] //, MaterialPropertyFormat.Float4
public struct VA_AnimationDataComponent : IComponentData public struct VaAnimationDataComponent : IComponentData
{ {
// animationTime, animationIndex, colorIndex, nan. // animationTime, animationIndex, colorIndex, nan.
public float4 Value; public float4 Value;
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -2,9 +2,25 @@
#ifndef VERTEXANIMATIONUTILS_INCLUDED #ifndef VERTEXANIMATIONUTILS_INCLUDED
#define VERTEX_ANIMATION_INCLUDED #define VERTEX_ANIMATION_INCLUDED
#include "VectorEncodingDecoding.hlsl"
#include "SampleTexture2DArrayLOD.hlsl" #include "SampleTexture2DArrayLOD.hlsl"
void CALC_VA_UV_float(float2 uv, int maxFrames, float time, out float2 uvPosition)
{
float timeInFrames = frac(time);
timeInFrames = ceil(timeInFrames * maxFrames);
timeInFrames /= maxFrames;
timeInFrames += round(1.0f / maxFrames);
uvPosition.x = uv.x;
#ifdef VA_FLIP_UVS_ON
uvPosition.y = (1.0f - (timeInFrames)) + (1.0f - (1.0f - uv.y));
#else
uvPosition.y = (1.0f - (1.0f - uv.y) - (1.0f - (timeInFrames)));
#endif
}
float2 VA_UV_float(float2 uv, int maxFrames, float time) float2 VA_UV_float(float2 uv, int maxFrames, float time)
{ {
float2 uvPosition; float2 uvPosition;

View File

@ -1,5 +1,5 @@
{ {
"m_SGVersion": 2, "m_SGVersion": 3,
"m_Type": "UnityEditor.ShaderGraph.GraphData", "m_Type": "UnityEditor.ShaderGraph.GraphData",
"m_ObjectId": "144dcb1a2d15470a91360080bc9bd989", "m_ObjectId": "144dcb1a2d15470a91360080bc9bd989",
"m_Properties": [ "m_Properties": [
@ -23,6 +23,12 @@
} }
], ],
"m_Keywords": [], "m_Keywords": [],
"m_Dropdowns": [],
"m_CategoryData": [
{
"m_Id": "7b54f901e6934a3f86974515753934c1"
}
],
"m_Nodes": [ "m_Nodes": [
{ {
"m_Id": "031d019a3f114a639fed0a731159883c" "m_Id": "031d019a3f114a639fed0a731159883c"
@ -183,10 +189,12 @@
"serializedMesh": { "serializedMesh": {
"m_SerializedMesh": "{\"mesh\":{\"instanceID\":0}}", "m_SerializedMesh": "{\"mesh\":{\"instanceID\":0}}",
"m_Guid": "" "m_Guid": ""
} },
"preventRotation": false
}, },
"m_Path": "Sub Graphs", "m_Path": "Sub Graphs",
"m_ConcretePrecision": 0, "m_GraphPrecision": 0,
"m_PreviewMode": 2,
"m_OutputNode": { "m_OutputNode": {
"m_Id": "031d019a3f114a639fed0a731159883c" "m_Id": "031d019a3f114a639fed0a731159883c"
}, },
@ -222,6 +230,8 @@
"synonyms": [], "synonyms": [],
"m_Precision": 0, "m_Precision": 0,
"m_PreviewExpanded": true, "m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": { "m_CustomColors": {
"m_SerializableColors": [] "m_SerializableColors": []
}, },
@ -254,7 +264,8 @@
"m_SlotType": 0, "m_SlotType": 0,
"m_Hidden": false, "m_Hidden": false,
"m_ShaderOutputName": "texSampler", "m_ShaderOutputName": "texSampler",
"m_StageCapability": 3 "m_StageCapability": 3,
"m_BareResource": true
} }
{ {
@ -283,6 +294,8 @@
"synonyms": [], "synonyms": [],
"m_Precision": 0, "m_Precision": 0,
"m_PreviewExpanded": true, "m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": { "m_CustomColors": {
"m_SerializableColors": [] "m_SerializableColors": []
}, },
@ -317,6 +330,8 @@
"synonyms": [], "synonyms": [],
"m_Precision": 0, "m_Precision": 0,
"m_PreviewExpanded": true, "m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": { "m_CustomColors": {
"m_SerializableColors": [] "m_SerializableColors": []
}, },
@ -334,7 +349,8 @@
"m_SlotType": 1, "m_SlotType": 1,
"m_Hidden": false, "m_Hidden": false,
"m_ShaderOutputName": "Out", "m_ShaderOutputName": "Out",
"m_StageCapability": 3 "m_StageCapability": 3,
"m_BareResource": false
} }
{ {
@ -369,6 +385,33 @@
"m_Labels": [] "m_Labels": []
} }
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.CategoryData",
"m_ObjectId": "7b54f901e6934a3f86974515753934c1",
"m_Name": "",
"m_ChildObjectList": [
{
"m_Id": "c333595616b942739573e272a2bcc553"
},
{
"m_Id": "a09a6ce7e08545d99b5bda70586f4e79"
},
{
"m_Id": "975a04061f8d4786bce18d1574108732"
},
{
"m_Id": "f9b649ed28584dca8a522f3fb582f350"
},
{
"m_Id": "967e0c2bcb6e48c2b85b82c6d4c734a4"
},
{
"m_Id": "cc4eba55004546408c4665cdb22d3111"
}
]
}
{ {
"m_SGVersion": 0, "m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector2MaterialSlot", "m_Type": "UnityEditor.ShaderGraph.Vector2MaterialSlot",
@ -409,21 +452,21 @@
} }
{ {
"m_SGVersion": 0, "m_SGVersion": 1,
"m_Type": "UnityEditor.ShaderGraph.CustomFunctionNode", "m_Type": "UnityEditor.ShaderGraph.CustomFunctionNode",
"m_ObjectId": "83aca69ecbd845e888867dea88a660f1", "m_ObjectId": "83aca69ecbd845e888867dea88a660f1",
"m_Group": { "m_Group": {
"m_Id": "" "m_Id": ""
}, },
"m_Name": "Custom Function", "m_Name": "VA_ARRAY (Custom Function)",
"m_DrawState": { "m_DrawState": {
"m_Expanded": true, "m_Expanded": true,
"m_Position": { "m_Position": {
"serializedVersion": "2", "serializedVersion": "2",
"x": -405.0, "x": -402.66668701171877,
"y": -144.0, "y": -148.0,
"width": 237.99998474121095, "width": 237.33331298828126,
"height": 494.0 "height": 399.9999694824219
} }
}, },
"m_Slots": [ "m_Slots": [
@ -455,6 +498,8 @@
"synonyms": [], "synonyms": [],
"m_Precision": 0, "m_Precision": 0,
"m_PreviewExpanded": true, "m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": { "m_CustomColors": {
"m_SerializableColors": [] "m_SerializableColors": []
}, },
@ -496,12 +541,17 @@
"m_GuidSerialized": "26e53708-434a-4d58-b8b2-d8fb8005d644" "m_GuidSerialized": "26e53708-434a-4d58-b8b2-d8fb8005d644"
}, },
"m_Name": "MaxFrames", "m_Name": "MaxFrames",
"m_DefaultRefNameVersion": 0,
"m_RefNameGeneratedByDisplayName": "",
"m_DefaultReferenceName": "Vector1_967e0c2bcb6e48c2b85b82c6d4c734a4", "m_DefaultReferenceName": "Vector1_967e0c2bcb6e48c2b85b82c6d4c734a4",
"m_OverrideReferenceName": "", "m_OverrideReferenceName": "",
"m_GeneratePropertyBlock": true, "m_GeneratePropertyBlock": true,
"m_UseCustomSlotLabel": false,
"m_CustomSlotLabel": "",
"m_DismissedVersion": 0,
"m_Precision": 0, "m_Precision": 0,
"overrideHLSLDeclaration": false, "overrideHLSLDeclaration": true,
"hlslDeclarationOverride": 0, "hlslDeclarationOverride": 2,
"m_Hidden": false, "m_Hidden": false,
"m_Value": 0.0, "m_Value": 0.0,
"m_FloatType": 0, "m_FloatType": 0,
@ -512,23 +562,29 @@
} }
{ {
"m_SGVersion": 0, "m_SGVersion": 1,
"m_Type": "UnityEditor.ShaderGraph.SamplerStateShaderProperty", "m_Type": "UnityEditor.ShaderGraph.SamplerStateShaderProperty",
"m_ObjectId": "975a04061f8d4786bce18d1574108732", "m_ObjectId": "975a04061f8d4786bce18d1574108732",
"m_Guid": { "m_Guid": {
"m_GuidSerialized": "374e9a5f-1ef4-43a2-9ff2-6108a1976ab0" "m_GuidSerialized": "374e9a5f-1ef4-43a2-9ff2-6108a1976ab0"
}, },
"m_Name": "SamplerState", "m_Name": "SamplerState",
"m_DefaultReferenceName": "", "m_DefaultRefNameVersion": 0,
"m_OverrideReferenceName": "SamplerState_Linear_Repeat", "m_RefNameGeneratedByDisplayName": "",
"m_DefaultReferenceName": "SamplerState_975a04061f8d4786bce18d1574108732",
"m_OverrideReferenceName": "",
"m_GeneratePropertyBlock": true, "m_GeneratePropertyBlock": true,
"m_UseCustomSlotLabel": false,
"m_CustomSlotLabel": "",
"m_DismissedVersion": 0,
"m_Precision": 0, "m_Precision": 0,
"overrideHLSLDeclaration": false, "overrideHLSLDeclaration": false,
"hlslDeclarationOverride": 0, "hlslDeclarationOverride": 0,
"m_Hidden": false, "m_Hidden": false,
"m_Value": { "m_Value": {
"m_filter": 0, "m_filter": 0,
"m_wrap": 0 "m_wrap": 0,
"m_anisotropic": 0
} }
} }
@ -540,12 +596,17 @@
"m_GuidSerialized": "96fb959c-8624-4642-9ac6-6b405b5a6dd4" "m_GuidSerialized": "96fb959c-8624-4642-9ac6-6b405b5a6dd4"
}, },
"m_Name": "UV", "m_Name": "UV",
"m_DefaultRefNameVersion": 0,
"m_RefNameGeneratedByDisplayName": "",
"m_DefaultReferenceName": "Vector2_a09a6ce7e08545d99b5bda70586f4e79", "m_DefaultReferenceName": "Vector2_a09a6ce7e08545d99b5bda70586f4e79",
"m_OverrideReferenceName": "", "m_OverrideReferenceName": "",
"m_GeneratePropertyBlock": true, "m_GeneratePropertyBlock": true,
"m_UseCustomSlotLabel": false,
"m_CustomSlotLabel": "",
"m_DismissedVersion": 0,
"m_Precision": 0, "m_Precision": 0,
"overrideHLSLDeclaration": false, "overrideHLSLDeclaration": false,
"hlslDeclarationOverride": 0, "hlslDeclarationOverride": 2,
"m_Hidden": false, "m_Hidden": false,
"m_Value": { "m_Value": {
"x": 0.0, "x": 0.0,
@ -642,6 +703,8 @@
"synonyms": [], "synonyms": [],
"m_Precision": 0, "m_Precision": 0,
"m_PreviewExpanded": true, "m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": { "m_CustomColors": {
"m_SerializableColors": [] "m_SerializableColors": []
}, },
@ -660,6 +723,7 @@
"m_Hidden": false, "m_Hidden": false,
"m_ShaderOutputName": "positionMap", "m_ShaderOutputName": "positionMap",
"m_StageCapability": 3, "m_StageCapability": 3,
"m_BareResource": true,
"m_TextureArray": { "m_TextureArray": {
"m_SerializedTexture": "{\"textureArray\":{\"instanceID\":0}}", "m_SerializedTexture": "{\"textureArray\":{\"instanceID\":0}}",
"m_Guid": "" "m_Guid": ""
@ -718,15 +782,20 @@
"m_GuidSerialized": "484a186e-c3de-457f-80e1-65e0ac649faf" "m_GuidSerialized": "484a186e-c3de-457f-80e1-65e0ac649faf"
}, },
"m_Name": "PositionMap", "m_Name": "PositionMap",
"m_DefaultRefNameVersion": 0,
"m_RefNameGeneratedByDisplayName": "",
"m_DefaultReferenceName": "Texture2DArray_c333595616b942739573e272a2bcc553", "m_DefaultReferenceName": "Texture2DArray_c333595616b942739573e272a2bcc553",
"m_OverrideReferenceName": "", "m_OverrideReferenceName": "",
"m_GeneratePropertyBlock": true, "m_GeneratePropertyBlock": true,
"m_UseCustomSlotLabel": false,
"m_CustomSlotLabel": "",
"m_DismissedVersion": 0,
"m_Precision": 0, "m_Precision": 0,
"overrideHLSLDeclaration": false, "overrideHLSLDeclaration": false,
"hlslDeclarationOverride": 0, "hlslDeclarationOverride": 0,
"m_Hidden": false, "m_Hidden": false,
"m_Value": { "m_Value": {
"m_SerializedTexture": "{\"textureArray\":{\"instanceID\":0}}", "m_SerializedTexture": "{\"textureArray\":{\"fileID\":3909434844059189716,\"guid\":\"7211d85b1ff94194f9be9f44b460b472\",\"type\":2}}",
"m_Guid": "" "m_Guid": ""
}, },
"m_Modifiable": true "m_Modifiable": true
@ -758,6 +827,8 @@
"synonyms": [], "synonyms": [],
"m_Precision": 0, "m_Precision": 0,
"m_PreviewExpanded": true, "m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": { "m_CustomColors": {
"m_SerializableColors": [] "m_SerializableColors": []
}, },
@ -774,12 +845,17 @@
"m_GuidSerialized": "3f779194-c6e4-40be-9134-677bb0c69785" "m_GuidSerialized": "3f779194-c6e4-40be-9134-677bb0c69785"
}, },
"m_Name": "PositionMapIndex", "m_Name": "PositionMapIndex",
"m_DefaultRefNameVersion": 0,
"m_RefNameGeneratedByDisplayName": "",
"m_DefaultReferenceName": "Vector1_cc4eba55004546408c4665cdb22d3111", "m_DefaultReferenceName": "Vector1_cc4eba55004546408c4665cdb22d3111",
"m_OverrideReferenceName": "", "m_OverrideReferenceName": "",
"m_GeneratePropertyBlock": true, "m_GeneratePropertyBlock": true,
"m_UseCustomSlotLabel": false,
"m_CustomSlotLabel": "",
"m_DismissedVersion": 0,
"m_Precision": 0, "m_Precision": 0,
"overrideHLSLDeclaration": true, "overrideHLSLDeclaration": true,
"hlslDeclarationOverride": 3, "hlslDeclarationOverride": 2,
"m_Hidden": false, "m_Hidden": false,
"m_Value": 0.0, "m_Value": 0.0,
"m_FloatType": 0, "m_FloatType": 0,
@ -798,7 +874,8 @@
"m_SlotType": 1, "m_SlotType": 1,
"m_Hidden": false, "m_Hidden": false,
"m_ShaderOutputName": "Out", "m_ShaderOutputName": "Out",
"m_StageCapability": 3 "m_StageCapability": 3,
"m_BareResource": false
} }
{ {
@ -827,6 +904,8 @@
"synonyms": [], "synonyms": [],
"m_Precision": 0, "m_Precision": 0,
"m_PreviewExpanded": true, "m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": { "m_CustomColors": {
"m_SerializableColors": [] "m_SerializableColors": []
}, },
@ -878,6 +957,8 @@
"synonyms": [], "synonyms": [],
"m_Precision": 0, "m_Precision": 0,
"m_PreviewExpanded": true, "m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": { "m_CustomColors": {
"m_SerializableColors": [] "m_SerializableColors": []
}, },
@ -894,12 +975,17 @@
"m_GuidSerialized": "07478aa4-3d18-4430-bf12-24688db601b8" "m_GuidSerialized": "07478aa4-3d18-4430-bf12-24688db601b8"
}, },
"m_Name": "Time", "m_Name": "Time",
"m_DefaultRefNameVersion": 0,
"m_RefNameGeneratedByDisplayName": "",
"m_DefaultReferenceName": "Vector1_f9b649ed28584dca8a522f3fb582f350", "m_DefaultReferenceName": "Vector1_f9b649ed28584dca8a522f3fb582f350",
"m_OverrideReferenceName": "", "m_OverrideReferenceName": "",
"m_GeneratePropertyBlock": true, "m_GeneratePropertyBlock": true,
"m_UseCustomSlotLabel": false,
"m_CustomSlotLabel": "",
"m_DismissedVersion": 0,
"m_Precision": 0, "m_Precision": 0,
"overrideHLSLDeclaration": false, "overrideHLSLDeclaration": true,
"hlslDeclarationOverride": 0, "hlslDeclarationOverride": 2,
"m_Hidden": false, "m_Hidden": false,
"m_Value": 0.0, "m_Value": 0.0,
"m_FloatType": 0, "m_FloatType": 0,

View File

@ -8,7 +8,8 @@
"GUID:7a450cf7ca9694b5a8bfa3fd83ec635a", "GUID:7a450cf7ca9694b5a8bfa3fd83ec635a",
"GUID:a5baed0c9693541a5bd947d336ec7659", "GUID:a5baed0c9693541a5bd947d336ec7659",
"GUID:d8b63aba1907145bea998dd612889d6b", "GUID:d8b63aba1907145bea998dd612889d6b",
"GUID:e0cd26848372d4e5c891c569017e11f1" "GUID:e0cd26848372d4e5c891c569017e11f1",
"GUID:c6266fb6386056f4b9e71740697607ca"
], ],
"includePlatforms": [], "includePlatforms": [],
"excludePlatforms": [], "excludePlatforms": [],

View File

@ -36,9 +36,7 @@
], ],
"dependencies": { "dependencies": {
"com.unity.entities": "0.16.0-preview.21", "com.unity.entities": "0.16.0-preview.21",
"com.unity.render-pipelines.universal": "10.2.2", "com.unity.shadergraph": "10.2.2"
"com.unity.shadergraph": "10.2.2",
"com.unity.rendering.hybrid": "0.10.0-preview.21"
}, },
"hideInEditor": false "hideInEditor": false
} }