Skip to content

Commit 97e0eb0

Browse files
ludovic-theobaldEvergreen
authored andcommitted
[VFX][Fix] Ray-tracing shader compilation errors
1 parent 2081d87 commit 97e0eb0

3 files changed

Lines changed: 17 additions & 5 deletions

File tree

Packages/com.unity.render-pipelines.high-definition/Editor/VFXGraph/Shaders/Templates/PlanarPrimitive/DXR/Unlit/EvaluateMaterialData.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ void EvaluateUnlitMaterialData(in AttributeData attributeData, out float4 outCol
99
// Load the VFX attributes that we need for this
1010
${VFXLoadAttributes}
1111
${VFXProcessBlocks}
12+
float2 uv = attributeData.barycentrics;
1213
${VFXGetColorRT}
1314

1415
// Return the color

Packages/com.unity.visualeffectgraph/Editor/Models/Contexts/VFXAbstractParticleOutput.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,8 @@ public virtual bool exposeAlphaThreshold
293293
if (useAlphaClipping)
294294
return true;
295295
//For Motion & Shadow, allow use a alpha clipping and it shares the same value as color clipping for transparent particles
296-
if (!isBlendModeOpaque && (hasMotionVector || hasShadowCasting))
296+
// Ray traced transparent particle should also expose an alpha threshold for effects using visibility pass like RTAO.
297+
if (!isBlendModeOpaque && (hasMotionVector || hasShadowCasting || isRayTraced))
297298
return true;
298299
return false;
299300
}

Packages/com.unity.visualeffectgraph/Editor/ShaderGraph/Templates/VFXConfigRaytracing.template.hlsl

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#include "Packages/com.unity.visualeffectgraph/Shaders/VFXRayTracingCommon.hlsl"
22

3-
void GetVFXInstancingIndices(out int index, out int instanceIndex, out int instanceActiveIndex)
3+
void GetVFXInstancingIndices(out uint index, out uint instanceIndex, out uint instanceActiveIndex)
44
{
55
#ifdef VFX_RT_DECIMATION_FACTOR
66
int rayTracingDecimationFactor = VFX_RT_DECIMATION_FACTOR;
77
#else
88
int rayTracingDecimationFactor = 1;
99
#endif
1010
index = PrimitiveIndex() * rayTracingDecimationFactor;
11-
instanceIndex = asuint(_InstanceIndex);
12-
instanceActiveIndex = asuint(_InstanceActiveIndex);
11+
instanceIndex = asuint(UNITY_ACCESS_INSTANCED_PROP(PerInstance, _InstanceIndex));
12+
instanceActiveIndex = asuint(UNITY_ACCESS_INSTANCED_PROP(PerInstance, _InstanceActiveIndex));
1313
VFXGetInstanceCurrentIndex(index);
1414
}
1515

@@ -63,7 +63,17 @@ void BuildFragInputsFromVFXIntersection(AttributeData attributeData, out FragInp
6363
output.texCoord2 = float4(attributeData.barycentrics,0,0);
6464
output.texCoord3 = float4(attributeData.barycentrics,0,0);
6565

66-
output.color = float4(attributes.color, attributes.alpha);
66+
#if VFX_USE_COLOR_CURRENT
67+
float3 color = attributes.color;
68+
#else
69+
float3 color = float3(1,1,1);
70+
#endif
71+
#if VFX_USE_ALPHA_CURRENT
72+
float alpha = attributes.alpha;
73+
#else
74+
float alpha = 1;
75+
#endif
76+
output.color = float4(color, alpha);
6777

6878
// Compute the world space normal
6979
float3 normalWS = normalize(-WorldToPrimitive(attributes, size3)[2].xyz);

0 commit comments

Comments
 (0)