o3de / o3de-azslc

Amazon Shader Language (AZSL) Compiler
Other
23 stars 14 forks source link

Is it possible to use inline raytracing? #83

Open ohmaya opened 1 year ago

ohmaya commented 1 year ago

https://github.com/o3de/o3de/discussions/14307

siliconvoodoo commented 1 year ago

It should be possible by changing the shader model version in the .shader file set it to type RayTracing.

example here https://github.com/o3de/o3de-atom-sampleviewer/blob/64499f0e2ec324e656ea2f9bfef17c83942c8399/Shaders/RHI/RayTracingClosestHitSolid.shader

It will translate to lib_6_3 profile for DX12 platform: https://github.com/o3de/o3de/blob/e282c39b6910a7f386179beefc77d7edd9e23c38/Gems/Atom/RHI/DX12/Code/Source/RHI.Builders/ShaderPlatformInterface.cpp#L235

With that, normally you should have access to RayQuery and TraceRayInline These are not reserved keywords, but azslc can tolerate them as user symbols even if not recognized. I verified that it does translate to reasonable HLSL.

For the resources, they should go in an SRG, the sample viewer will have an example of the acceleration structure in an SRG I imagine. image