static public VFXExpression Sequential3D(VFXExpression origin, VFXExpression axisX, VFXExpression axisY, VFXExpression axisZ, VFXExpression index, VFXExpression countX, VFXExpression countY, VFXExpression countZ) { index = VFXOperatorUtility.Modulo(index, countX * countY * countZ); var z = new VFXExpressionCastUintToFloat(VFXOperatorUtility.Modulo(index, countZ)); var y = new VFXExpressionCastUintToFloat(VFXOperatorUtility.Modulo(index / countZ, countY)); var x = new VFXExpressionCastUintToFloat(index / (countY * countZ)); VFXExpression volumeSize = new VFXExpressionCombine(new VFXExpressionCastUintToFloat(countX), new VFXExpressionCastUintToFloat(countY), new VFXExpressionCastUintToFloat(countZ)); volumeSize = volumeSize - VFXOperatorUtility.OneExpression[VFXValueType.Float3]; var scaleAxisZero = Saturate(volumeSize); //Handle special case for one count => lead to be centered on origin (instead of -axis) volumeSize = new VFXExpressionMax(volumeSize, VFXOperatorUtility.OneExpression[VFXValueType.Float3]); var dt = new VFXExpressionCombine(x, y, z) / volumeSize; dt = dt * VFXOperatorUtility.TwoExpression[VFXValueType.Float3] - VFXOperatorUtility.OneExpression[VFXValueType.Float3]; var r = origin; r += dt.xxx * scaleAxisZero.xxx * axisX; r += dt.yyy * scaleAxisZero.yyy * axisY; r += dt.zzz * scaleAxisZero.zzz * axisZ; return(r); }
public static VFXExpression ApplyToExpressionGraph(VFXPropertyAttribute[] attributes, VFXExpression exp) { if (attributes != null) { foreach (VFXPropertyAttribute attribute in attributes) { switch (attribute.m_Type) { case Type.kRange: exp = VFXOperatorUtility.Clamp(exp, VFXValue.Constant(attribute.m_Min), VFXValue.Constant(attribute.m_Max)); break; case Type.kMin: exp = new VFXExpressionMax(exp, VFXOperatorUtility.CastFloat(VFXValue.Constant(attribute.m_Min), exp.valueType)); break; case Type.kNormalize: exp = VFXOperatorUtility.Normalize(exp); break; case Type.kTooltip: case Type.kAngle: case Type.kColor: case Type.kRegex: case Type.kDelayed: break; default: throw new NotImplementedException(); } } } return(exp); }
static public VFXExpression ApplyAddressingMode(VFXExpression index, VFXExpression count, SequentialAddressingMode mode) { VFXExpression r = null; if (mode == SequentialAddressingMode.Wrap) { r = Modulo(index, count); } else if (mode == SequentialAddressingMode.Clamp) { var countMinusOne = count - OneExpression[VFXValueType.Uint32]; r = new VFXExpressionMin(index, countMinusOne); } else if (mode == SequentialAddressingMode.Mirror) { var two = TwoExpression[VFXValueType.Uint32]; var cycle = count * two - two; cycle = new VFXExpressionMax(cycle, OneExpression[VFXValueType.Uint32]); var modulo = Modulo(index, cycle); //var compare = new VFXExpressionCondition(VFXCondition.Less, new VFXExpressionCastUintToFloat(modulo), new VFXExpressionCastUintToFloat(count)); <= Use this line for 7.x.x/8.x.x/9.x.x backport var compare = new VFXExpressionCondition(VFXValueType.Uint32, VFXCondition.Less, modulo, count); r = new VFXExpressionBranch(compare, modulo, cycle - modulo); } return(r); }
static public VFXExpression SequentialLine(VFXExpression start, VFXExpression end, VFXExpression index, VFXExpression count) { VFXExpression dt = new VFXExpressionCastUintToFloat(VFXOperatorUtility.Modulo(index, count)); var size = new VFXExpressionCastUintToFloat(count) - VFXOperatorUtility.OneExpression[VFXValueType.Float]; size = new VFXExpressionMax(size, VFXOperatorUtility.OneExpression[VFXValueType.Float]); dt = dt / size; dt = new VFXExpressionCombine(dt, dt, dt); return(VFXOperatorUtility.Lerp(start, end, dt)); }
protected override VFXExpression Reduce(VFXExpression[] reducedParents) { VFXExpression inputSaturateExpression = null; if (VFXExpressionMax.CanBeReducedToSaturate(this, reducedParents, out inputSaturateExpression)) { return(new VFXExpressionSaturate(inputSaturateExpression)); } return(base.Reduce(reducedParents)); }
static public VFXExpression Clamp(VFXExpression input, VFXExpression min, VFXExpression max, bool autoCast) { //Max(Min(x, max), min)) if (autoCast) { min = CastFloat(min, input.valueType); max = CastFloat(max, input.valueType); } var maxExp = new VFXExpressionMax(input, min); return(new VFXExpressionMin(maxExp, max)); }
public static VFXExpression ApplyToExpressionGraph(VFXPropertyAttribute[] attributes, VFXExpression exp) { if (attributes != null) { foreach (VFXPropertyAttribute attribute in attributes) { switch (attribute.m_Type) { case Type.kRange: switch (exp.valueType) { case VFXValueType.Int32: exp = VFXOperatorUtility.Clamp(exp, VFXValue.Constant((int)attribute.m_Min), VFXValue.Constant((int)attribute.m_Max), false); break; case VFXValueType.Uint32: exp = VFXOperatorUtility.Clamp(exp, VFXValue.Constant((uint)attribute.m_Min), VFXValue.Constant((uint)attribute.m_Max), false); break; case VFXValueType.Float: case VFXValueType.Float2: case VFXValueType.Float3: case VFXValueType.Float4: exp = VFXOperatorUtility.Clamp(exp, VFXValue.Constant(attribute.m_Min), VFXValue.Constant(attribute.m_Max)); break; default: throw new NotImplementedException(string.Format("Cannot use RangeAttribute on value of type: {0}", exp.valueType)); } break; case Type.kMin: switch (exp.valueType) { case VFXValueType.Int32: exp = new VFXExpressionMax(exp, VFXValue.Constant((int)attribute.m_Min)); break; case VFXValueType.Uint32: exp = new VFXExpressionMax(exp, VFXValue.Constant((uint)attribute.m_Min)); break; case VFXValueType.Float: case VFXValueType.Float2: case VFXValueType.Float3: case VFXValueType.Float4: exp = new VFXExpressionMax(exp, VFXOperatorUtility.CastFloat(VFXValue.Constant(attribute.m_Min), exp.valueType)); break; default: throw new NotImplementedException(string.Format("Cannot use MinAttribute on value of type: {0}", exp.valueType)); } break; case Type.kNormalize: exp = VFXOperatorUtility.Normalize(exp); break; case Type.kTooltip: case Type.kAngle: case Type.kColor: case Type.kRegex: case Type.kDelayed: case Type.kBitField: break; default: throw new NotImplementedException(); } } } return(exp); }
public VFXExpression ApplyToExpressionGraph(VFXExpression exp) { if (m_GraphAttributes == null) { return(exp); } foreach (PropertyAttribute attribute in m_GraphAttributes) { if (attribute is RangeAttribute) { var rangeAttribute = (RangeAttribute)attribute; switch (exp.valueType) { case VFXValueType.Int32: exp = VFXOperatorUtility.Clamp(exp, VFXValue.Constant((int)rangeAttribute.min), VFXValue.Constant((int)rangeAttribute.max), false); break; case VFXValueType.Uint32: exp = VFXOperatorUtility.Clamp(exp, VFXValue.Constant((uint)rangeAttribute.min), VFXValue.Constant((uint)rangeAttribute.max), false); break; case VFXValueType.Float: case VFXValueType.Float2: case VFXValueType.Float3: case VFXValueType.Float4: exp = VFXOperatorUtility.Clamp(exp, VFXValue.Constant(rangeAttribute.min), VFXValue.Constant(rangeAttribute.max)); break; default: throw new NotImplementedException(string.Format("Cannot use RangeAttribute on value of type: {0}", exp.valueType)); } } else if (attribute is MinAttribute) { var minAttribute = (MinAttribute)attribute; switch (exp.valueType) { case VFXValueType.Int32: exp = new VFXExpressionMax(exp, VFXValue.Constant((int)minAttribute.min)); break; case VFXValueType.Uint32: exp = new VFXExpressionMax(exp, VFXValue.Constant((uint)minAttribute.min)); break; case VFXValueType.Float: case VFXValueType.Float2: case VFXValueType.Float3: case VFXValueType.Float4: exp = new VFXExpressionMax(exp, VFXOperatorUtility.CastFloat(VFXValue.Constant(minAttribute.min), exp.valueType)); break; default: throw new NotImplementedException(string.Format("Cannot use MinAttribute on value of type: {0}", exp.valueType)); } } else if (attribute is NormalizeAttribute) { exp = VFXOperatorUtility.Normalize(exp); } else if (attribute is EnumAttribute) { var enumAttribute = (EnumAttribute)attribute; exp = new VFXExpressionMin(exp, VFXValue.Constant((uint)enumAttribute.values.Length - 1)); } else { throw new NotImplementedException("Unrecognized expression attribute: " + attribute); } } return(exp); }