Hi, I'm working on integrating Rayquery, into my game-engine. Vulkan/DX12 work fine on PC, but Metal(on Mac) doesn't:
Here is screenshot on how rendering looks:
And similar spot from XCode-debugger shows:
Ship, cannons, items are there - TLAS look as they should. Note: in game screenshoot above there are no shadows, but it not always the case:
Here only some parts of object do cast shadow.
Fragment shader: https://shader-playground.timjones.io/44de178b7b8a715ea235c7f12cd0aabc
// relevant part
bool isShadow(...)
{
...
uint flags = 4u;
flags |= 128u;
rayQuery.reset(ray(rayOrigin, rayDirection, tMin, rayDistance), topLevelAS, spvMakeIntersectionParams(flags));
for (;;) // spirv-cross not pretty here :(
{
bool _116 = rayQuery.next();
if (_116)
{
continue;
}
else
{
break;
}
}
uint _120 = uint(rayQuery.get_committed_intersection_type());
if (_120 == 0u)
{
return false;
}
return true;
}
----
intersection_params spvMakeIntersectionParams(uint flags)
{
// hacked this part, while debugging - setting up for simple most any-hit
intersection_params ip;
ip.force_opacity(forced_opacity::opaque);
ip.accept_any_intersection(true);
return ip;
}
After verifying TLAS and ray-query loop can conclude, that most likely it's a driver bug here, or generated shader code is wrong (but looks correct to me!).
PS:
one more small thing about Metal-RT:
Metal doc about MTL::AccelerationStructureTriangleGeometryDescriptor::setIndexBufferOffset
says:
"Specify an offset that is a multiple of the index data type size and a multiple of the platform’s buffer offset alignment."
Buffer-offset-alignment (32 bytes in worst case) is very hard to workaround for multi-material meshes . No other api requires so, and there is no good workaround for this.