Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

How to ignore transparent faces in anyhit shader?

Discussion in 'HDRP Ray Tracing' started by guodongrong, Apr 21, 2020.

  1. guodongrong

    guodongrong

    Joined:
    Dec 4, 2019
    Posts:
    13
    I see RTX tutorials all said we can use anyhit shader to ignore transparent faces. But how can I know if a hit face is transparent or not?

    I searched online and find two examples:

    1. On Page 29 of this book (https://link.springer.com/content/pdf/10.1007/978-1-4842-4427-2_3.pdf), it used "a custom-written isTransparent() function to query the material system (based on primitive ID and hit point) to perform alpha testing". However, it does not provide how that "isTransparent()" function is implemented.

    2. The second example is from NVIDIA's GettingStartedWithRTXRayTracing. For example, in anyhit shader here (https://github.com/NVIDIAGameWorks/...ffer/Data/Tutorial04/rayTracedGBuffer.rt.hlsl), it calls a function "alphaTestFails", which is implemented here: https://github.com/NVIDIAGameWorks/...TracedGBuffer/Data/Tutorial04/alphaTest.hlsli.
    However, that function calls Falcor helper functions there. I do not find an easy way to setup Unity to use Falcor.

    Can anyone provide me an ready-to-use anyhit shader to ignore the transparent faces? Or can anyone teach me how to use Falcor with Unity, so that I can reuse the sample codes from item 2 above?

    Thanks a lot!