Custom HLSL Block(dx12,unity 2023.2.0a20)

i not able to use RaytracingAccelerationStructure inside Custom HLSL Block.it give an error

error in ‘[New VFX] [Simple Loop] Update Particles’: unrecognized identifier ‘RaytracingAccelerationStructure’ at kernel CSMain at node.hlsl(3) (on d3d11)

here my source file for HLSL block

#include "UnityRayQuery.cginc"

//globe property
//shader.SetGlobalRayTracingAccelerationStructure

RaytracingAccelerationStructure g_AccelStruct;
float Distance(in float3 a, in float3 b)
{
    return distance(a, b);
}

vfx graph

RaytracingAccelerationStructure is a SM 6.3 object so it can’t compile anywhere.

1 Like

So can I force it to be compile using SM 6.5 DXC compiler and thx for doc.
@INedelcu

So it been a year now, if there any update on this?
@INedelcu

Hi @vx4

Specifying newer shader model using pragma target is not supported (e.g. #pragma target 6.5) because the shader models make sense only for DirectX and there’s no 1:1 mapping to other graphics APIs. The only way to force using SM 6.5 is to use a feature that was introduced in that model and is supported by Unity. For example #pragma require inlineraytracing will set the target to 6.5 in DXC. In your example you’ll have to setup a RayTracingAccelerationStructure and bind it to shaders using Shader.SetGlobalRayTracingAccelerationStructure or CommandBuffer.SetGlobalRayTracingAccelerationStructure.

1 Like

where i should add #pragma require inlineraytracing , can paste in \PackageCache\com.unity.render-pipelines.universal@2626908b593c\Runtime\VFXGraph\Shaders\VFXDefines.hlsl in order to work?

I asked around. Here’s the conclusion: the pragmas can be defined inside an include but the include must be specified using include_with_pragmas instead of classic include to process the pragmas in that include. Currently there’s no way to specify an include with pragmas from inside a VFX graph.

When generating shader code based on a VFX graph, VFXDefines.hlsl is included in the generated code using include_with_pragmas which means that you can add a pragma directly in VFXDefines.hlsl and you have to make a copy of the package.

1 Like

thx, i will try it