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 004e46140ff..0249ba066a9 100644 Binary files a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ShadergraphSampleScene/LightingData.asset and b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ShadergraphSampleScene/LightingData.asset differ 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 f2dff04cd3a..00000000000 Binary files a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ShadergraphSampleScene/ReflectionProbe-0.exr and /dev/null differ diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ShadergraphSampleScene/ReflectionProbe-0.exr.meta b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ShadergraphSampleScene/ReflectionProbe-0.exr.meta deleted file mode 100644 index 9153c703218..00000000000 --- a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ShadergraphSampleScene/ReflectionProbe-0.exr.meta +++ /dev/null @@ -1,96 +0,0 @@ -fileFormatVersion: 2 -guid: d83b1e98929f2f14ba10bfa35194d133 -TextureImporter: - internalIDToNameTable: [] - externalObjects: {} - serializedVersion: 11 - mipmaps: - mipMapMode: 0 - enableMipMap: 1 - sRGBTexture: 1 - linearTexture: 0 - fadeOut: 0 - borderMipMap: 0 - mipMapsPreserveCoverage: 0 - alphaTestReferenceValue: 0.5 - mipMapFadeDistanceStart: 1 - mipMapFadeDistanceEnd: 3 - bumpmap: - convertToNormalMap: 0 - externalNormalMap: 0 - heightScale: 0.25 - normalMapFilter: 0 - isReadable: 0 - streamingMipmaps: 0 - streamingMipmapsPriority: 0 - vTOnly: 0 - grayScaleToAlpha: 0 - generateCubemap: 6 - cubemapConvolution: 1 - seamlessCubemap: 1 - textureFormat: 1 - maxTextureSize: 2048 - textureSettings: - serializedVersion: 2 - filterMode: 2 - aniso: 0 - mipBias: 0 - wrapU: 1 - wrapV: 1 - wrapW: 1 - nPOTScale: 1 - lightmap: 0 - compressionQuality: 50 - spriteMode: 0 - spriteExtrude: 1 - spriteMeshType: 1 - alignment: 0 - spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 100 - spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spriteGenerateFallbackPhysicsShape: 1 - alphaUsage: 1 - alphaIsTransparency: 0 - spriteTessellationDetail: -1 - textureType: 0 - textureShape: 2 - singleChannelComponent: 0 - flipbookRows: 1 - flipbookColumns: 1 - maxTextureSizeSet: 0 - compressionQualitySet: 0 - textureFormatSet: 0 - ignorePngGamma: 0 - applyGammaDecoding: 0 - platformSettings: - - serializedVersion: 3 - buildTarget: DefaultTexturePlatform - maxTextureSize: 2048 - resizeAlgorithm: 0 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 100 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - androidETC2FallbackOverride: 0 - forceMaximumCompressionQuality_BC6H_BC7: 0 - spriteSheet: - serializedVersion: 2 - sprites: [] - outline: [] - physicsShape: [] - bones: [] - spriteID: - internalID: 0 - vertices: [] - indices: - edges: [] - weights: [] - secondaryTextures: [] - spritePackingTag: - pSDRemoveMatte: 0 - pSDShowRemoveMatteOption: 0 - userData: - assetBundleName: - assetBundleVariant: diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/TestCaseFilters.asset.meta b/TestProjects/VisualEffectGraph_HDRP/Assets/TestCaseFilters.asset.meta new file mode 100644 index 00000000000..2bb61f38fa9 --- /dev/null +++ b/TestProjects/VisualEffectGraph_HDRP/Assets/TestCaseFilters.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 55e06b1642a60204bb6c749d26e176e7 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.visualeffectgraph/CHANGELOG.md b/com.unity.visualeffectgraph/CHANGELOG.md index d99dab96953..c1f64a2d2a8 100644 --- a/com.unity.visualeffectgraph/CHANGELOG.md +++ b/com.unity.visualeffectgraph/CHANGELOG.md @@ -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 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 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/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]); } } 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/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 diff --git a/com.unity.visualeffectgraph/Shaders/VFXParticleCommon.template b/com.unity.visualeffectgraph/Shaders/VFXParticleCommon.template index d4147bf1c7e..b3641526573 100644 --- a/com.unity.visualeffectgraph/Shaders/VFXParticleCommon.template +++ b/com.unity.visualeffectgraph/Shaders/VFXParticleCommon.template @@ -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; @@ -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)}}