Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion com.unity.visualeffectgraph/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Fixed
- Removed shader warnings due to SAMPLE_DEPTH_TEXTURE redefinition [Case 1331262](https://issuetracker.unity3d.com/product/unity/issues/guid/1331262/)
- Fix Soft Particle depth computation when using an orthographic camera [Case 1309961](https://issuetracker.unity3d.com/product/unity/issues/guid/1309961)

- Compilation error undeclared identifier 'Infinity' [Case 1328592](https://issuetracker.unity3d.com/product/unity/issues/guid/1328592/)
- Extract position from a transform is wrong on GPU [Case 1353533](https://issuetracker.unity3d.com/product/unity/issues/guid/1353533/)

## [10.6.0] - 2021-04-29
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion com.unity.visualeffectgraph/Documentation~/ComponentAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ The `eventNameOrId` parameter can be one of the following types:

The optional `eventAttribute` parameter attaches an **Event Attribute Payload** to the Event. They payload provides data that the Graph processes with the Event.

**Note**: When you send an Event, the Visual Effect component processes it in its next Update(), which happens during the next frame.
**Note**: When you send an [Event](https://docs.unity3d.com/ScriptReference/VFX.VisualEffect.SendEvent.html) (or use the [`.Simulate`](https://docs.unity3d.com/ScriptReference/VFX.VisualEffect.Simulate.html)method) the Visual Effect component processes all pushed commands in its next `VisualEffect.Update` which happens after the [`LateUpdate`](https://docs.unity3d.com/Manual/ExecutionOrder.html).

### Event Attributes

Expand Down
20 changes: 15 additions & 5 deletions com.unity.visualeffectgraph/Editor/Compiler/VFXShaderWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,30 +61,40 @@ public static string GetValueString(VFXValueType type, object value)
value = value.ToString().ToLower();
break;
case VFXValueType.Float:
value = ((float)value).ToString("G9", CultureInfo.InvariantCulture);
value = FormatFloat((float)value);
break;
case VFXValueType.Float2:
value = $"({((Vector2)value).x.ToString("G9", CultureInfo.InvariantCulture)}, {((Vector2)value).y.ToString("G9", CultureInfo.InvariantCulture)})";
value = $"({FormatFloat(((Vector2)value).x)}, {FormatFloat(((Vector2)value).y)})";
break;
case VFXValueType.Float3:
value = $"({((Vector3)value).x.ToString("G9", CultureInfo.InvariantCulture)}, {((Vector3)value).y.ToString("G9", CultureInfo.InvariantCulture)}, {((Vector3)value).z.ToString("G9", CultureInfo.InvariantCulture)})";
value = $"({FormatFloat(((Vector3)value).x)}, {FormatFloat(((Vector3)value).y)}, {FormatFloat(((Vector3)value).z)})";
break;
case VFXValueType.Float4:
value = $"({((Vector4)value).x.ToString("G9", CultureInfo.InvariantCulture)}, {((Vector4)value).y.ToString("G9", CultureInfo.InvariantCulture)}, {((Vector4)value).z.ToString("G9", CultureInfo.InvariantCulture)}, {((Vector4)value).w.ToString("G9", CultureInfo.InvariantCulture)})";
value = $"({FormatFloat(((Vector4)value).x)}, {FormatFloat(((Vector4)value).y)}, {FormatFloat(((Vector4)value).z)}, {FormatFloat(((Vector4)value).w)})";
break;
case VFXValueType.Matrix4x4:
{
var matrix = ((Matrix4x4)value).transpose;
value = "(";
for (int i = 0; i < 16; ++i)
value += string.Format(CultureInfo.InvariantCulture, i == 15 ? "{0}" : "{0},", matrix[i].ToString("G9", CultureInfo.InvariantCulture));
value += string.Format(CultureInfo.InvariantCulture, i == 15 ? "{0}" : "{0},", FormatFloat(matrix[i]));
value += ")";
}
break;
}
return string.Format(CultureInfo.InvariantCulture, format, VFXExpression.TypeToCode(type), value);
}

private static string FormatFloat(float f)
{
if (float.IsInfinity(f))
return f > 0.0f ? "VFX_INFINITY" : "-VFX_INFINITY";
else if (float.IsNaN(f))
return "VFX_NAN";
else
return f.ToString("G9", CultureInfo.InvariantCulture);
}

public static string GetMultilineWithPrefix(string str, string linePrefix)
{
if (linePrefix.Length == 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ sealed protected override VFXExpression Evaluate(VFXExpression[] constParents)

public override string GetCodeString(string[] parents)
{
return string.Format("{0}[3].xyz", parents[0]);
return string.Format("{0}._14_24_34", parents[0]);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,9 @@ public override IEnumerable<VFXNamedExpression> parameters
if (SampleMode == CurveSampleMode.BySpeed)
{
var speedRangeComponents = VFXOperatorUtility.ExtractComponents(speedRange).ToArray();
// speedRange.y = 1 / (sign(speedRange.y - speedRange.y) * max(epsilon, abs(speedRange.y - speedRange.y))
// speedRange.y = 1 / (speedRange.y - speedRange.x)
var speedRangeDelta = speedRangeComponents[1] - speedRangeComponents[0];
var denom = new VFXExpressionSign(speedRangeDelta) * new VFXExpressionMax(VFXOperatorUtility.EpsilonExpression[VFXValueType.Float], new VFXExpressionAbs(speedRangeDelta));
speedRangeComponents[1] = VFXOperatorUtility.OneExpression[VFXValueType.Float] / denom;
speedRangeComponents[1] = VFXOperatorUtility.OneExpression[VFXValueType.Float] / speedRangeDelta;
yield return new VFXNamedExpression(new VFXExpressionCombine(speedRangeComponents), "SpeedRange");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ VFX_VARYING_PS_INPUTS vert(uint id : SV_VertexID, vs_input i)
${VFXProcessBlocks}

if (!attributes.alive)
{
o.pos.x = VFX_NAN;
return o;
}

float3 vPos = attributes.position;
o.VFX_VARYING_POSCS = TransformPositionVFXToClip(vPos);
Expand Down
2 changes: 2 additions & 0 deletions com.unity.visualeffectgraph/Shaders/VFXCommon.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#define VFX_FLT_MIN 1.175494351e-38
#define VFX_EPSILON 1e-5
#define VFX_INFINITY (1.0f/0.0f)
#define VFX_NAN asfloat(~0u)

#pragma warning(disable : 3557) // disable warning for auto unrolling of single iteration loop

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ if (index >= asuint(nbMax) - deadCount)
#if USE_GEOMETRY_SHADER
return; // cull
#else
{
o.pos.x = VFX_NAN;
return o; // cull
}
#endif

Attributes attributes = (Attributes)0;
Expand All @@ -88,7 +91,10 @@ ${VFXLoadAttributes}
${VFXLoadAttributes:{alive}}
#if !HAS_STRIPS
if (!attributes.alive)
{
o.pos.x = VFX_NAN;
return o;
}
#endif

${VFXLoadAttributes:{(?!(alive))(\b\w)}}
Expand Down