Regression test for the procedural BLAS path: the same 3x3x3 grid of unit-box AABBs runs through a PROCEDURAL_HIT_GROUP_KHR group whose GLSL intersection shader (reportIntersectionEXT) turns each box into a radius-1 sphere, the any-hit shader punches the spherical-checkerboard cut-out (visible proof non-opaque geometry runs any-hit), and the closest-hit shades per-instance tints — the WebGPU example behavior reproduced natively. Fixed camera in raygen.glsl; the WebGPU/DOM path is unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
30 lines
1.2 KiB
GLSL
30 lines
1.2 KiB
GLSL
#version 460
|
|
#extension GL_EXT_ray_tracing : enable
|
|
|
|
// RTVolume any-hit shader — runs on every candidate sphere hit because
|
|
// the geometry is built non-opaque (BuildProcedural opaque=false) and
|
|
// the instances don't force-opaque. Punches a spherical checkerboard of
|
|
// holes: for half the cells it calls ignoreIntersectionEXT, so the ray
|
|
// passes straight through and the background / spheres behind show
|
|
// through — the visible proof the any-hit path runs. Mirrors
|
|
// anyhit.wgsl on the WebGPU path.
|
|
|
|
hitAttributeEXT vec2 attribs;
|
|
layout(location = 0) rayPayloadInEXT vec3 hitValue;
|
|
|
|
void main() {
|
|
// Object-space hit point on the unit sphere → its normal/direction.
|
|
vec3 posObj = gl_ObjectRayOriginEXT + gl_ObjectRayDirectionEXT * gl_HitTEXT;
|
|
vec3 n = normalize(posObj);
|
|
|
|
const float PI = 3.14159265;
|
|
float longitude = atan(n.z, n.x); // [-PI, PI]
|
|
float latitude = asin(clamp(n.y, -1.0, 1.0)); // [-PI/2, PI/2]
|
|
|
|
int cu = int(floor((longitude + PI) / PI * 6.0));
|
|
int cv = int(floor((latitude + PI * 0.5) / PI * 6.0));
|
|
|
|
if (((cu + cv) & 1) == 0) {
|
|
ignoreIntersectionEXT; // cut-out cell — see through
|
|
}
|
|
}
|