123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496 |
- using System;
- using System.Linq;
- using System.Runtime.CompilerServices;
- using UnityEngine;
- using UnityEngine.VFX;
- namespace UnityEditor.VFX
- {
- class VFXExpressionVertexBufferFromMesh : VFXExpression
- {
- public VFXExpressionVertexBufferFromMesh() : this(VFXValue<Mesh>.Default, VFXValue<uint>.Default)
- {
- }
- public VFXExpressionVertexBufferFromMesh(VFXExpression mesh, VFXExpression channelFormatAndDimensionAndStream) : base(Flags.InvalidOnGPU, new VFXExpression[] { mesh, channelFormatAndDimensionAndStream })
- {
- }
- sealed public override VFXExpressionOperation operation { get { return VFXExpressionOperation.VertexBufferFromMesh; } }
- }
- class VFXExpressionVertexBufferFromSkinnedMeshRenderer : VFXExpression
- {
- public VFXExpressionVertexBufferFromSkinnedMeshRenderer() : this(VFXValue<SkinnedMeshRenderer>.Default, VFXValue<uint>.Default)
- {
- }
- public VFXExpressionVertexBufferFromSkinnedMeshRenderer(VFXExpression mesh, VFXExpression channelFormatAndDimensionAndStream) : base(Flags.InvalidOnGPU, new VFXExpression[] { mesh, channelFormatAndDimensionAndStream })
- {
- }
- sealed public override VFXExpressionOperation operation { get { return VFXExpressionOperation.VertexBufferFromSkinnedMeshRenderer; } }
- }
- class VFXExpressionIndexBufferFromMesh : VFXExpression
- {
- public VFXExpressionIndexBufferFromMesh() : this(VFXValue<Mesh>.Default)
- {
- }
- public VFXExpressionIndexBufferFromMesh(VFXExpression mesh) : base(Flags.InvalidOnGPU, new VFXExpression[] { mesh })
- {
- }
- sealed public override VFXExpressionOperation operation { get { return VFXExpressionOperation.IndexBufferFromMesh; } }
- }
- class VFXExpressionMeshFromSkinnedMeshRenderer : VFXExpression
- {
- public VFXExpressionMeshFromSkinnedMeshRenderer() : this(VFXValue<SkinnedMeshRenderer>.Default)
- {
- }
- public VFXExpressionMeshFromSkinnedMeshRenderer(VFXExpression skinnedMesh) : base(Flags.InvalidOnGPU, new VFXExpression[] { skinnedMesh })
- {
- if (skinnedMesh.valueType != VFXValueType.SkinnedMeshRenderer)
- throw new InvalidOperationException("Unexpected input type in VFXExpressionMeshFromSkinnedMeshRenderer : " + skinnedMesh.valueType);
- }
- public sealed override VFXExpressionOperation operation { get { return VFXExpressionOperation.MeshFromSkinnedMeshRenderer; } }
- protected sealed override VFXExpression Evaluate(VFXExpression[] constParents)
- {
- var skinnedMeshReduce = constParents[0];
- var skinnedMesh = skinnedMeshReduce.Get<SkinnedMeshRenderer>();
- Mesh result = skinnedMesh != null ? skinnedMesh.sharedMesh : null;
- return VFXValue.Constant(result);
- }
- }
- class VFXExpressionMeshIndexCount : VFXExpression
- {
- public VFXExpressionMeshIndexCount() : this(VFXValue<Mesh>.Default)
- {
- }
- public VFXExpressionMeshIndexCount(VFXExpression mesh) : base(Flags.InvalidOnGPU, new VFXExpression[1] { mesh })
- {
- }
- sealed public override VFXExpressionOperation operation { get { return VFXExpressionOperation.MeshIndexCount; } }
- protected sealed override VFXExpression Evaluate(VFXExpression[] constParents)
- {
- var meshReduce = constParents[0];
- var mesh = meshReduce.Get<Mesh>();
- return VFXValue.Constant(VFXExpressionMesh.GetIndexCount(mesh));
- }
- }
- class VFXExpressionMeshIndexFormat : VFXExpression
- {
- public VFXExpressionMeshIndexFormat() : this(VFXValue<Mesh>.Default)
- {
- }
- public VFXExpressionMeshIndexFormat(VFXExpression mesh) : base(Flags.InvalidOnGPU, new VFXExpression[1] { mesh })
- {
- }
- sealed public override VFXExpressionOperation operation { get { return VFXExpressionOperation.MeshIndexFormat; } }
- protected sealed override VFXExpression Evaluate(VFXExpression[] constParents)
- {
- var meshReduce = constParents[0];
- var mesh = meshReduce.Get<Mesh>();
- return VFXValue.Constant(VFXExpressionMesh.GetIndexFormat(mesh));
- }
- }
- class VFXExpressionSampleIndex : VFXExpression
- {
- public VFXExpressionSampleIndex() : this(VFXValue<Mesh>.Default, VFXValue<uint>.Default, VFXValue<uint>.Default)
- {
- }
- public VFXExpressionSampleIndex(VFXExpression mesh, VFXExpression index, VFXExpression indexFormat) : base(Flags.None, new VFXExpression[] { mesh, index, indexFormat })
- {
- }
- protected sealed override VFXExpression Evaluate(VFXExpression[] constParents)
- {
- var meshReduce = constParents[0];
- var vertexOffsetReduce = constParents[1];
- var channelFormatAndDimensionReduce = constParents[2];
- var mesh = meshReduce.Get<Mesh>();
- var index = vertexOffsetReduce.Get<uint>();
- var indexFormat = channelFormatAndDimensionReduce.Get<uint>();
- return VFXValue.Constant(VFXExpressionMesh.GetIndex(mesh, index, indexFormat));
- }
- sealed public override VFXExpressionOperation operation { get { return VFXExpressionOperation.SampleMeshIndex; } }
- public sealed override string GetCodeString(string[] parents)
- {
- return string.Format("SampleMeshIndex({0}, {1}, {2})", parents[0], parents[1], parents[2]);
- }
- }
- abstract class VFXExpressionSampleBaseFloat : VFXExpression
- {
- public VFXExpressionSampleBaseFloat(Flags flags, VFXExpression source, VFXExpression vertexOffset, VFXExpression channelFormatAndDimension) : base(flags, new VFXExpression[] { source, vertexOffset, channelFormatAndDimension })
- {
- }
- public sealed override string GetCodeString(string[] parents)
- {
- return string.Format("SampleMeshFloat({0}, {1}, {2})", parents[0], parents[1], parents[2]);
- }
- }
- class VFXExpressionSampleSkinnedMeshRendererFloat : VFXExpressionSampleBaseFloat
- {
- public VFXExpressionSampleSkinnedMeshRendererFloat() : this(VFXValue<SkinnedMeshRenderer>.Default, VFXValue<uint>.Default, VFXValue<uint>.Default)
- {
- }
- public VFXExpressionSampleSkinnedMeshRendererFloat(VFXExpression skinnedMeshRenderer, VFXExpression vertexOffset, VFXExpression channelFormatAndDimension) : base(Flags.InvalidOnCPU, skinnedMeshRenderer, vertexOffset, channelFormatAndDimension)
- {
- }
- sealed public override VFXExpressionOperation operation { get { return VFXExpressionOperation.None; } }
- sealed public override VFXValueType valueType { get { return VFXValueType.Float; } }
- }
- class VFXExpressionSampleMeshFloat : VFXExpressionSampleBaseFloat
- {
- public VFXExpressionSampleMeshFloat() : this(VFXValue<Mesh>.Default, VFXValue<uint>.Default, VFXValue<uint>.Default)
- {
- }
- public VFXExpressionSampleMeshFloat(VFXExpression mesh, VFXExpression vertexOffset, VFXExpression channelFormatAndDimension) : base(Flags.None, mesh, vertexOffset, channelFormatAndDimension)
- {
- }
- sealed public override VFXExpressionOperation operation { get { return VFXExpressionOperation.SampleMeshVertexFloat; } }
- protected sealed override VFXExpression Evaluate(VFXExpression[] constParents)
- {
- var meshReduce = constParents[0];
- var vertexOffsetReduce = constParents[1];
- var channelFormatAndDimensionReduce = constParents[2];
- var mesh = meshReduce.Get<Mesh>();
- var vertexOffset = vertexOffsetReduce.Get<uint>();
- var channelFormatAndDimension = channelFormatAndDimensionReduce.Get<uint>();
- return VFXValue.Constant(VFXExpressionMesh.GetFloat(mesh, vertexOffset, channelFormatAndDimension));
- }
- }
- abstract class VFXExpressionSampleBaseFloat2 : VFXExpression
- {
- public VFXExpressionSampleBaseFloat2(Flags flags, VFXExpression source, VFXExpression vertexOffset, VFXExpression channelFormatAndDimension) : base(flags, new VFXExpression[] { source, vertexOffset, channelFormatAndDimension })
- {
- }
- public sealed override string GetCodeString(string[] parents)
- {
- return string.Format("SampleMeshFloat2({0}, {1}, {2})", parents[0], parents[1], parents[2]);
- }
- }
- class VFXExpressionSampleSkinnedMeshRendererFloat2 : VFXExpressionSampleBaseFloat2
- {
- public VFXExpressionSampleSkinnedMeshRendererFloat2() : this(VFXValue<SkinnedMeshRenderer>.Default, VFXValue<uint>.Default, VFXValue<uint>.Default)
- {
- }
- public VFXExpressionSampleSkinnedMeshRendererFloat2(VFXExpression skinnedMeshRenderer, VFXExpression vertexOffset, VFXExpression channelFormatAndDimension) : base(Flags.InvalidOnCPU, skinnedMeshRenderer, vertexOffset, channelFormatAndDimension)
- {
- }
- sealed public override VFXExpressionOperation operation { get { return VFXExpressionOperation.None; } }
- sealed public override VFXValueType valueType { get { return VFXValueType.Float2; } }
- }
- class VFXExpressionSampleMeshFloat2 : VFXExpressionSampleBaseFloat2
- {
- public VFXExpressionSampleMeshFloat2() : this(VFXValue<Mesh>.Default, VFXValue<uint>.Default, VFXValue<uint>.Default)
- {
- }
- public VFXExpressionSampleMeshFloat2(VFXExpression mesh, VFXExpression vertexOffset, VFXExpression channelFormatAndDimension) : base(Flags.None, mesh, vertexOffset, channelFormatAndDimension)
- {
- }
- sealed public override VFXExpressionOperation operation { get { return VFXExpressionOperation.SampleMeshVertexFloat2; } }
- protected sealed override VFXExpression Evaluate(VFXExpression[] constParents)
- {
- var meshReduce = constParents[0];
- var vertexOffsetReduce = constParents[1];
- var channelFormatAndDimensionReduce = constParents[2];
- var mesh = meshReduce.Get<Mesh>();
- var vertexOffset = vertexOffsetReduce.Get<uint>();
- var channelFormatAndDimension = channelFormatAndDimensionReduce.Get<uint>();
- return VFXValue.Constant(VFXExpressionMesh.GetFloat2(mesh, vertexOffset, channelFormatAndDimension));
- }
- }
- abstract class VFXExpressionSampleBaseFloat3 : VFXExpression
- {
- public VFXExpressionSampleBaseFloat3(Flags flags, VFXExpression source, VFXExpression vertexOffset, VFXExpression channelFormatAndDimension) : base(flags, new VFXExpression[] { source, vertexOffset, channelFormatAndDimension })
- {
- }
- public sealed override string GetCodeString(string[] parents)
- {
- return string.Format("SampleMeshFloat3({0}, {1}, {2})", parents[0], parents[1], parents[2]);
- }
- }
- class VFXExpressionSampleSkinnedMeshRendererFloat3 : VFXExpressionSampleBaseFloat3
- {
- public VFXExpressionSampleSkinnedMeshRendererFloat3() : this(VFXValue<SkinnedMeshRenderer>.Default, VFXValue<uint>.Default, VFXValue<uint>.Default)
- {
- }
- public VFXExpressionSampleSkinnedMeshRendererFloat3(VFXExpression skinnedMeshRenderer, VFXExpression vertexOffset, VFXExpression channelFormatAndDimension) : base(Flags.InvalidOnCPU, skinnedMeshRenderer, vertexOffset, channelFormatAndDimension)
- {
- }
- sealed public override VFXExpressionOperation operation { get { return VFXExpressionOperation.None; } }
- sealed public override VFXValueType valueType { get { return VFXValueType.Float3; } }
- }
- class VFXExpressionSampleMeshFloat3 : VFXExpressionSampleBaseFloat3
- {
- public VFXExpressionSampleMeshFloat3() : this(VFXValue<Mesh>.Default, VFXValue<uint>.Default, VFXValue<uint>.Default)
- {
- }
- public VFXExpressionSampleMeshFloat3(VFXExpression mesh, VFXExpression vertexOffset, VFXExpression channelFormatAndDimension) : base(Flags.None, mesh, vertexOffset, channelFormatAndDimension)
- {
- }
- sealed public override VFXExpressionOperation operation { get { return VFXExpressionOperation.SampleMeshVertexFloat3; } }
- protected sealed override VFXExpression Evaluate(VFXExpression[] constParents)
- {
- var meshReduce = constParents[0];
- var vertexOffsetReduce = constParents[1];
- var channelFormatAndDimensionReduce = constParents[2];
- var mesh = meshReduce.Get<Mesh>();
- var vertexOffset = vertexOffsetReduce.Get<uint>();
- var channelFormatAndDimension = channelFormatAndDimensionReduce.Get<uint>();
- return VFXValue.Constant(VFXExpressionMesh.GetFloat3(mesh, vertexOffset, channelFormatAndDimension));
- }
- }
- abstract class VFXExpressionSampleBaseFloat4 : VFXExpression
- {
- public VFXExpressionSampleBaseFloat4(Flags flags, VFXExpression source, VFXExpression vertexOffset, VFXExpression channelFormatAndDimension) : base(flags, new VFXExpression[] { source, vertexOffset, channelFormatAndDimension })
- {
- }
- public sealed override string GetCodeString(string[] parents)
- {
- return string.Format("SampleMeshFloat4({0}, {1}, {2})", parents[0], parents[1], parents[2]);
- }
- }
- class VFXExpressionSampleSkinnedMeshRendererFloat4 : VFXExpressionSampleBaseFloat4
- {
- public VFXExpressionSampleSkinnedMeshRendererFloat4() : this(VFXValue<SkinnedMeshRenderer>.Default, VFXValue<uint>.Default, VFXValue<uint>.Default)
- {
- }
- public VFXExpressionSampleSkinnedMeshRendererFloat4(VFXExpression skinnedMeshRenderer, VFXExpression vertexOffset, VFXExpression channelFormatAndDimension) : base(Flags.InvalidOnCPU, skinnedMeshRenderer, vertexOffset, channelFormatAndDimension)
- {
- }
- sealed public override VFXExpressionOperation operation { get { return VFXExpressionOperation.None; } }
- sealed public override VFXValueType valueType { get { return VFXValueType.Float4; } }
- }
- class VFXExpressionSampleMeshFloat4 : VFXExpressionSampleBaseFloat4
- {
- public VFXExpressionSampleMeshFloat4() : this(VFXValue<Mesh>.Default, VFXValue<uint>.Default, VFXValue<uint>.Default)
- {
- }
- public VFXExpressionSampleMeshFloat4(VFXExpression mesh, VFXExpression vertexOffset, VFXExpression channelFormatAndDimension) : base(Flags.None, mesh, vertexOffset, channelFormatAndDimension)
- {
- }
- sealed public override VFXExpressionOperation operation { get { return VFXExpressionOperation.SampleMeshVertexFloat4; } }
- protected sealed override VFXExpression Evaluate(VFXExpression[] constParents)
- {
- var meshReduce = constParents[0];
- var vertexOffsetReduce = constParents[1];
- var channelFormatAndDimensionReduce = constParents[2];
- var mesh = meshReduce.Get<Mesh>();
- var vertexOffset = vertexOffsetReduce.Get<uint>();
- var channelFormatAndDimension = channelFormatAndDimensionReduce.Get<uint>();
- return VFXValue.Constant(VFXExpressionMesh.GetFloat4(mesh, vertexOffset, channelFormatAndDimension));
- }
- }
- abstract class VFXExpressionSampleBaseColor : VFXExpression
- {
- public VFXExpressionSampleBaseColor(Flags flags, VFXExpression source, VFXExpression vertexOffset, VFXExpression channelFormatAndDimension) : base(flags, new VFXExpression[] { source, vertexOffset, channelFormatAndDimension })
- {
- }
- public sealed override string GetCodeString(string[] parents)
- {
- return string.Format("SampleMeshColor({0}, {1}, {2})", parents[0], parents[1], parents[2]);
- }
- }
- class VFXExpressionSampleSkinnedMeshRendererColor : VFXExpressionSampleBaseColor
- {
- public VFXExpressionSampleSkinnedMeshRendererColor() : this(VFXValue<SkinnedMeshRenderer>.Default, VFXValue<uint>.Default, VFXValue<uint>.Default)
- {
- }
- public VFXExpressionSampleSkinnedMeshRendererColor(VFXExpression skinnedMeshRenderer, VFXExpression vertexOffset, VFXExpression channelFormatAndDimension) : base(Flags.InvalidOnCPU, skinnedMeshRenderer, vertexOffset, channelFormatAndDimension)
- {
- }
- sealed public override VFXExpressionOperation operation { get { return VFXExpressionOperation.None; } }
- sealed public override VFXValueType valueType { get { return VFXValueType.Float4; } }
- }
- class VFXExpressionSampleMeshColor : VFXExpressionSampleBaseColor
- {
- public VFXExpressionSampleMeshColor() : this(VFXValue<Mesh>.Default, VFXValue<uint>.Default, VFXValue<uint>.Default)
- {
- }
- public VFXExpressionSampleMeshColor(VFXExpression mesh, VFXExpression vertexOffset, VFXExpression channelFormatAndDimension) : base(Flags.None, mesh, vertexOffset, channelFormatAndDimension)
- {
- }
- sealed public override VFXExpressionOperation operation { get { return VFXExpressionOperation.SampleMeshVertexColor; } }
- protected sealed override VFXExpression Evaluate(VFXExpression[] constParents)
- {
- var meshReduce = constParents[0];
- var vertexOffsetReduce = constParents[1];
- var channelFormatAndDimensionReduce = constParents[2];
- var mesh = meshReduce.Get<Mesh>();
- var vertexOffset = vertexOffsetReduce.Get<uint>();
- var channelFormatAndDimension = channelFormatAndDimensionReduce.Get<uint>();
- return VFXValue.Constant(VFXExpressionMesh.GetColor(mesh, vertexOffset, channelFormatAndDimension));
- }
- }
- class VFXExpressionMeshVertexCount : VFXExpression
- {
- public VFXExpressionMeshVertexCount() : this(VFXValue<Mesh>.Default)
- {
- }
- public VFXExpressionMeshVertexCount(VFXExpression mesh) : base(Flags.InvalidOnGPU, new VFXExpression[1] { mesh })
- {
- if (mesh.valueType != VFXValueType.Mesh)
- throw new InvalidOperationException("Unexpected type in VFXExpressionMeshVertexCount : " + mesh.valueType);
- }
- sealed public override VFXExpressionOperation operation { get { return VFXExpressionOperation.MeshVertexCount; } }
- protected sealed override VFXExpression Evaluate(VFXExpression[] constParents)
- {
- var meshReduce = constParents[0];
- var mesh = meshReduce.Get<Mesh>();
- return VFXValue.Constant(VFXExpressionMesh.GetVertexCount(mesh));
- }
- }
- class VFXExpressionMeshChannelOffset : VFXExpression
- {
- public VFXExpressionMeshChannelOffset() : this(VFXValue<Mesh>.Default, VFXValue<uint>.Default)
- {
- }
- public VFXExpressionMeshChannelOffset(VFXExpression mesh, VFXExpression channelIndex) : base(Flags.InvalidOnGPU, new VFXExpression[2] { mesh, channelIndex })
- {
- }
- sealed public override VFXExpressionOperation operation { get { return VFXExpressionOperation.MeshChannelOffset; } }
- protected sealed override VFXExpression Evaluate(VFXExpression[] constParents)
- {
- var meshReduce = constParents[0];
- var channelIndexReduce = constParents[1];
- var mesh = meshReduce.Get<Mesh>();
- var channelIndex = channelIndexReduce.Get<uint>();
- return VFXValue.Constant(VFXExpressionMesh.GetChannelOffset(mesh, channelIndex));
- }
- }
- class VFXExpressionMeshChannelInfos : VFXExpression
- {
- public VFXExpressionMeshChannelInfos() : this(VFXValue<Mesh>.Default, VFXValue<uint>.Default)
- {
- }
- public VFXExpressionMeshChannelInfos(VFXExpression mesh, VFXExpression channelIndex) : base(Flags.InvalidOnGPU, new VFXExpression[2] { mesh, channelIndex })
- {
- }
- sealed public override VFXExpressionOperation operation { get { return VFXExpressionOperation.MeshChannelInfos; } }
- protected sealed override VFXExpression Evaluate(VFXExpression[] constParents)
- {
- var meshReduce = constParents[0];
- var channelIndexReduce = constParents[1];
- var mesh = meshReduce.Get<Mesh>();
- var channelIndex = channelIndexReduce.Get<uint>();
- return VFXValue.Constant(VFXExpressionMesh.GetChannelInfos(mesh, channelIndex));
- }
- }
- class VFXExpressionMeshVertexStride : VFXExpression
- {
- public VFXExpressionMeshVertexStride() : this(VFXValue<Mesh>.Default, VFXValue<uint>.Default)
- {
- }
- public VFXExpressionMeshVertexStride(VFXExpression mesh, VFXExpression channelIndex) : base(Flags.InvalidOnGPU, new VFXExpression[] { mesh, channelIndex })
- {
- }
- sealed public override VFXExpressionOperation operation { get { return VFXExpressionOperation.MeshVertexStride; } }
- protected sealed override VFXExpression Evaluate(VFXExpression[] constParents)
- {
- var meshReduce = constParents[0];
- var channelIndexReduce = constParents[1];
- var mesh = meshReduce.Get<Mesh>();
- var channelIndex = channelIndexReduce.Get<uint>();
- return VFXValue.Constant(VFXExpressionMesh.GetVertexStride(mesh, channelIndex));
- }
- }
- }
|