From 58a2b83bbaea853b2f175e127a0f888b560932a9 Mon Sep 17 00:00:00 2001 From: Paul Demeulenaere Date: Fri, 23 Jul 2021 09:43:54 +0200 Subject: [PATCH 1/7] [Doc] Confusing note about frame delay (#265) * Fix really strange documentation entry * Apply doc suggestion From : https://github.cds.internal.unity3d.com/unity/vfx-graphics/pull/265#discussion_r162754 --- com.unity.visualeffectgraph/Documentation~/ComponentAPI.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.visualeffectgraph/Documentation~/ComponentAPI.md b/com.unity.visualeffectgraph/Documentation~/ComponentAPI.md index 2869724550a..5e4d361ae06 100644 --- a/com.unity.visualeffectgraph/Documentation~/ComponentAPI.md +++ b/com.unity.visualeffectgraph/Documentation~/ComponentAPI.md @@ -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 From 185fc472a1456ad4eb8f6847c3fd7823153f800e Mon Sep 17 00:00:00 2001 From: Gabriel de la Cruz Date: Fri, 23 Jul 2021 10:07:17 +0200 Subject: [PATCH 2/7] [VFX] Add shader formatting for Infinity and NaN in floats #259 --- .../Runtime/VFXGraph/Shaders/VFXDefines.hlsl | 3 +++ .../Editor/Compiler/VFXShaderWriter.cs | 20 ++++++++++++++----- .../Attribute/AttributeFromCurve.cs | 5 ++--- .../Shaders/ParticlePoints/Pass.template | 3 +++ .../Shaders/VFXParticleCommon.template | 4 ++++ 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/VFXGraph/Shaders/VFXDefines.hlsl b/com.unity.render-pipelines.high-definition/Runtime/VFXGraph/Shaders/VFXDefines.hlsl index abc181d7cdb..92daad32a8c 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/VFXGraph/Shaders/VFXDefines.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/VFXGraph/Shaders/VFXDefines.hlsl @@ -39,4 +39,7 @@ // this is only necessary for the old VFXTarget pathway // it defines the macro used to access hybrid instanced properties // (new HDRP/URP Target pathway overrides the type so this is never used) +#define VFX_INFINITY (1.0f/0.0f) +#define VFX_NAN asfloat(~0u) + #define UNITY_ACCESS_HYBRID_INSTANCED_PROP(name, type) name diff --git a/com.unity.visualeffectgraph/Editor/Compiler/VFXShaderWriter.cs b/com.unity.visualeffectgraph/Editor/Compiler/VFXShaderWriter.cs index 03bc2f5d49e..d44d70800f7 100644 --- a/com.unity.visualeffectgraph/Editor/Compiler/VFXShaderWriter.cs +++ b/com.unity.visualeffectgraph/Editor/Compiler/VFXShaderWriter.cs @@ -61,23 +61,23 @@ 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; @@ -85,6 +85,16 @@ public static string GetValueString(VFXValueType type, object value) 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) diff --git a/com.unity.visualeffectgraph/Editor/Models/Blocks/Implementations/Attribute/AttributeFromCurve.cs b/com.unity.visualeffectgraph/Editor/Models/Blocks/Implementations/Attribute/AttributeFromCurve.cs index cadc1dfade1..759e25d2b0f 100644 --- a/com.unity.visualeffectgraph/Editor/Models/Blocks/Implementations/Attribute/AttributeFromCurve.cs +++ b/com.unity.visualeffectgraph/Editor/Models/Blocks/Implementations/Attribute/AttributeFromCurve.cs @@ -387,10 +387,9 @@ public override IEnumerable 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"); } } diff --git a/com.unity.visualeffectgraph/Shaders/ParticlePoints/Pass.template b/com.unity.visualeffectgraph/Shaders/ParticlePoints/Pass.template index 5aee5222532..5026b0c80b1 100644 --- a/com.unity.visualeffectgraph/Shaders/ParticlePoints/Pass.template +++ b/com.unity.visualeffectgraph/Shaders/ParticlePoints/Pass.template @@ -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); diff --git a/com.unity.visualeffectgraph/Shaders/VFXParticleCommon.template b/com.unity.visualeffectgraph/Shaders/VFXParticleCommon.template index d4147bf1c7e..b3b61a8089b 100644 --- a/com.unity.visualeffectgraph/Shaders/VFXParticleCommon.template +++ b/com.unity.visualeffectgraph/Shaders/VFXParticleCommon.template @@ -75,6 +75,7 @@ if (index >= asuint(nbMax) - deadCount) #if USE_GEOMETRY_SHADER return; // cull #else + o.pos.x = VFX_NAN; return o; // cull #endif @@ -88,7 +89,10 @@ ${VFXLoadAttributes} ${VFXLoadAttributes:{alive}} #if !HAS_STRIPS if (!attributes.alive) +{ + o.pos.x = VFX_NAN; return o; +} #endif ${VFXLoadAttributes:{(?!(alive))(\b\w)}} From bbdb2a4c7ad991d17a288a9b4b39c6708b469acd Mon Sep 17 00:00:00 2001 From: Paul Demeulenaere Date: Fri, 23 Jul 2021 16:18:49 +0200 Subject: [PATCH 3/7] *Update changelog missing entry --- com.unity.visualeffectgraph/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.visualeffectgraph/CHANGELOG.md b/com.unity.visualeffectgraph/CHANGELOG.md index d99dab96953..a05b6dea9f7 100644 --- a/com.unity.visualeffectgraph/CHANGELOG.md +++ b/com.unity.visualeffectgraph/CHANGELOG.md @@ -8,7 +8,7 @@ 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/) ## [10.6.0] - 2021-04-29 ### Fixed From 4f047dfdd38f02bb3b66ef4d0be2dc408dc3826e Mon Sep 17 00:00:00 2001 From: Paul Demeulenaere Date: Mon, 26 Jul 2021 09:23:57 +0200 Subject: [PATCH 4/7] [Fix] Build PS4 on URP #269 --- .../Runtime/VFXGraph/Shaders/VFXDefines.hlsl | 3 --- com.unity.visualeffectgraph/Shaders/VFXCommon.hlsl | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/VFXGraph/Shaders/VFXDefines.hlsl b/com.unity.render-pipelines.high-definition/Runtime/VFXGraph/Shaders/VFXDefines.hlsl index 92daad32a8c..abc181d7cdb 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/VFXGraph/Shaders/VFXDefines.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/VFXGraph/Shaders/VFXDefines.hlsl @@ -39,7 +39,4 @@ // this is only necessary for the old VFXTarget pathway // it defines the macro used to access hybrid instanced properties // (new HDRP/URP Target pathway overrides the type so this is never used) -#define VFX_INFINITY (1.0f/0.0f) -#define VFX_NAN asfloat(~0u) - #define UNITY_ACCESS_HYBRID_INSTANCED_PROP(name, type) name diff --git a/com.unity.visualeffectgraph/Shaders/VFXCommon.hlsl b/com.unity.visualeffectgraph/Shaders/VFXCommon.hlsl index b011791f562..6f6498c0102 100644 --- a/com.unity.visualeffectgraph/Shaders/VFXCommon.hlsl +++ b/com.unity.visualeffectgraph/Shaders/VFXCommon.hlsl @@ -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 From b27bb80c2542beb36812aa7506bb913466f90f3c Mon Sep 17 00:00:00 2001 From: Paul Demeulenaere Date: Mon, 30 Aug 2021 09:45:39 +0200 Subject: [PATCH 5/7] Fix Extract Position from Transform on GPU returns zero (#274) --- com.unity.visualeffectgraph/CHANGELOG.md | 1 + .../Editor/Expressions/VFXExpressionTransform.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/com.unity.visualeffectgraph/CHANGELOG.md b/com.unity.visualeffectgraph/CHANGELOG.md index a05b6dea9f7..c1f64a2d2a8 100644 --- a/com.unity.visualeffectgraph/CHANGELOG.md +++ b/com.unity.visualeffectgraph/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - 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 diff --git a/com.unity.visualeffectgraph/Editor/Expressions/VFXExpressionTransform.cs b/com.unity.visualeffectgraph/Editor/Expressions/VFXExpressionTransform.cs index 0d016188fe5..f8bbc6e708d 100644 --- a/com.unity.visualeffectgraph/Editor/Expressions/VFXExpressionTransform.cs +++ b/com.unity.visualeffectgraph/Editor/Expressions/VFXExpressionTransform.cs @@ -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]); } } From c4c54730909ce68b94168c50da2fa5d7ffcd43c7 Mon Sep 17 00:00:00 2001 From: jfryer_unity Date: Wed, 8 Sep 2021 16:53:33 +0200 Subject: [PATCH 6/7] Fix merge --- com.unity.visualeffectgraph/Shaders/VFXParticleCommon.template | 2 ++ 1 file changed, 2 insertions(+) diff --git a/com.unity.visualeffectgraph/Shaders/VFXParticleCommon.template b/com.unity.visualeffectgraph/Shaders/VFXParticleCommon.template index b3b61a8089b..b3641526573 100644 --- a/com.unity.visualeffectgraph/Shaders/VFXParticleCommon.template +++ b/com.unity.visualeffectgraph/Shaders/VFXParticleCommon.template @@ -75,8 +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; From 4817ca78168594cc0774040688ab604478a715f7 Mon Sep 17 00:00:00 2001 From: jfryer_unity Date: Wed, 8 Sep 2021 16:54:29 +0200 Subject: [PATCH 7/7] Add missing files --- .../ShadergraphSampleScene/LightingData.asset | Bin 22324 -> 22260 bytes .../ReflectionProbe-0.exr | Bin 4037 -> 0 bytes .../ReflectionProbe-0.exr.meta | 96 ------------------ .../Assets/TestCaseFilters.asset.meta | 8 ++ 4 files changed, 8 insertions(+), 96 deletions(-) delete mode 100644 TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ShadergraphSampleScene/ReflectionProbe-0.exr delete mode 100644 TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ShadergraphSampleScene/ReflectionProbe-0.exr.meta create mode 100644 TestProjects/VisualEffectGraph_HDRP/Assets/TestCaseFilters.asset.meta diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ShadergraphSampleScene/LightingData.asset b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ShadergraphSampleScene/LightingData.asset index 004e46140ff65d5235792b48d08667b37f2f7d20..0249ba066a93c1f9da841f9fea1abd5788960a35 100644 GIT binary patch delta 270 zcmdn8j`7P{#tGs|YZ<^G>o>z4D^ik3@tZW3cE8#O!jq`mpsA9zyL%H zEPvLpfz>fVR7Xs1bywB_b84FGHLfH)bL!fsb@Z*mP7!9Xii)=m_u}WjcilMi>^XJS zW0}m8Kf0T2*6^rdoaDhVd55PQqvd3KZ_CL7UMiClJOo(`85o!*`+Dt1mNjMM1nN@X zyujOrQ{jP7*FJ?_jonUvMXcMW1?!+fM)3`xf&ztlu^HL6FDh4WTWJ01u*DbN~PV delta 346 zcmeyemT}8E#tGs|hZ(>i+yp{ z>M3gs5$*n#p7!g*3%{-BkBjQo%l>1Y+~{GqnZu)oksD+S$nXVc+b7@lQdc!fGX$9q z0$xDO1;i3S40XMso`Ieb!;#77JuN4HaA%q9;33EYRL?wF)@whyQH(~DS9@AAa!!8e zuD&_J+lEu&sZiHG$zF}!&VNO$S4<1o!J%ht;a$IO=XK2{%VpaS?wTAB;-e5K*0oRU qwv)A<)E%p5KMZzo#I^1?X7z1nQS5z-MH|-dn!F&$V{<`h3nKua$!EF% diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ShadergraphSampleScene/ReflectionProbe-0.exr b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ShadergraphSampleScene/ReflectionProbe-0.exr deleted file mode 100644 index f2dff04cd3aa6a46dfa3cab20e2b34e16c8fab3e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4037 zcmXTZH)LdDU|>kjNX*Mi%_#;lax#lc7|elUP7I7d5(Gdr2)kp51Yw9UBQG3$t6LFC7JmQX*v0cB@8TJiyG{UlZ#SQ^B~4Mr{{-C8^dQzkPrF#Kk5W<&NPLUwSl8U}|m zh;oI46DX+y0VvEt*hdh=1F{Vc^Mu)~sf_rv@oDm@<5T;!