protected override sealed VFXExpression[] BuildExpression(VFXExpression[] inputExpression) { var mesh = inputExpression[0].valueType == VFXValueType.Mesh ? inputExpression[0] : new VFXExpressionMeshFromSkinnedMeshRenderer(inputExpression[0]); var meshVertexCount = new VFXExpressionMeshVertexCount(mesh); return(new VFXExpression[] { meshVertexCount }); }
public static IEnumerable <VFXExpression> SampleVertexAttribute(VFXExpression source, VFXExpression vertexIndex, VFXOperatorUtility.SequentialAddressingMode mode, IEnumerable <VertexAttribute> vertexAttributes) { bool skinnedMesh = source.valueType == UnityEngine.VFX.VFXValueType.SkinnedMeshRenderer; var mesh = !skinnedMesh ? source : new VFXExpressionMeshFromSkinnedMeshRenderer(source); var meshVertexCount = new VFXExpressionMeshVertexCount(mesh); vertexIndex = VFXOperatorUtility.ApplyAddressingMode(vertexIndex, meshVertexCount, mode); return(SampleVertexAttribute(source, vertexIndex, vertexAttributes)); }
protected override sealed VFXExpression[] BuildExpression(VFXExpression[] inputExpression) { var mesh = inputExpression[0]; var meshVertexStride = new VFXExpressionMeshVertexStride(mesh); var meshVertexCount = new VFXExpressionMeshVertexCount(mesh); var vertexIndex = VFXOperatorUtility.ApplyAddressingMode(inputExpression[1], meshVertexCount, mode); var outputExpressions = new List <VFXExpression>(); foreach (var vertexAttribute in GetOutputVertexAttributes()) { var meshChannelOffset = new VFXExpressionMeshChannelOffset(mesh, VFXValue.Constant <uint>((uint)GetActualVertexAttribute(vertexAttribute))); var outputType = GetOutputType(vertexAttribute); VFXExpression sampled = null; if (vertexAttribute == VertexAttributeFlag.Color) { sampled = new VFXExpressionSampleMeshColor(mesh, vertexIndex, meshChannelOffset, meshVertexStride); } else if (outputType == typeof(float)) { sampled = new VFXExpressionSampleMeshFloat(mesh, vertexIndex, meshChannelOffset, meshVertexStride); } else if (outputType == typeof(Vector2)) { sampled = new VFXExpressionSampleMeshFloat2(mesh, vertexIndex, meshChannelOffset, meshVertexStride); } else if (outputType == typeof(Vector3)) { sampled = new VFXExpressionSampleMeshFloat3(mesh, vertexIndex, meshChannelOffset, meshVertexStride); } else { sampled = new VFXExpressionSampleMeshFloat4(mesh, vertexIndex, meshChannelOffset, meshVertexStride); } outputExpressions.Add(sampled); } return(outputExpressions.ToArray()); }
protected override sealed VFXExpression[] BuildExpression(VFXExpression[] inputExpression) { var meshVertexCount = new VFXExpressionMeshVertexCount(inputExpression[0]); return(new VFXExpression[] { meshVertexCount }); }