0

I have a problem with updating some value in a Payload. I generate the payload inside the rgen shader like

struct HitPayload
{
    vec3 hitValue;
    uint32_t depth;
    vec3 worldPos;
    uint32_t instanceCustomIndexEXT;
    uint32_t primitiveID;
    float thereIsNearObj;
    float refractionIndex;
    float _pad0;
};
layout(location = 0) rayPayloadEXT HitPayload prd;

Inside the other shader rchit(closest) and rahit(any) i access the payload with

struct HitPayload
{
    vec3 hitValue;
    uint32_t depth;
    vec3 worldPos;
    uint32_t instanceCustomIndexEXT;
    uint32_t primitiveID;
    float thereIsNearObj;
    float refractionIndex;
    float _pad0;
};
layout(location = 0) rayPayloadInEXT HitPayload prd;

The shader compile and the program run. The problem is that i can update only the hitValue and depth value. Other value never change. I update value in the shaders like this

    prd.hitValue = vec3(1.0,1.0,0.0); //works
    prd.thereIsNearObj = 1.0; //not working

I checked:

  • Alignament
  • remove ignoreIntersectionEXT (block payload update)
  • Implicit cast from int -> uint32_t
  • Hi, recently I have detected that my anyhit shader cannot write to buffers, so I changed the logic to forward data to the ray payload. But then I noticed that ignoreIntersectionEXT actually prevent payload to be updated. Any idea on how to bypass this behavior? Where did you find the "block payload update" rule? Here is my original post: https://stackoverflow.com/questions/75008549/vulkan-ray-tracing-any-hit-shader-doesnt-write-to-buffer Thanks so much. – Marco Di Benedetto Jan 05 '23 at 21:49

1 Answers1

0

i think a good sleep is my best friends (joking). The problem is that Vulkan doesn't support extension type in the payload. I replace all the uint32_t with int and now it works fine. I haven't found a valid source for my solution, but it works.