https://github.com/shader-slang/slang
Raw File
Tip revision: 6f43b2698a99cc4f4bb4e905749fb87f24bf391b authored by jsmall-nvidia on 27 March 2020, 22:35:06 UTC
WaveBroadcastAt/WaveShuffle (#1299)
Tip revision: 6f43b26
anyhit.slang
// closesthit.slang
//TEST:CROSS_COMPILE: -profile sm_6_3 -stage anyhit -entry main -target spirv-assembly

struct SphereHitAttributes
{
    float3 normal;
};


struct ShadowRay
{
    float4 hitDistance;
};

struct Params
{
    Texture2D<float>    alphaMap;
    SamplerState        sampler;
    int                 mode;
}
ParameterBlock<Params> gParams;

void main(
    SphereHitAttributes attributes,
    in out ShadowRay    ioPayload)
{
    if(gParams.mode)
    {
        float val = gParams.alphaMap.SampleLevel(
            gParams.sampler,
            attributes.normal.xy, 0);
        if(val > 0)
        {
            AcceptHitAndEndSearch();
        }
        else
        {
            IgnoreHit();
        }
    }
}
back to top