| … | … | @@ -39,6 +39,27 @@ vec4 rt_frag_coord = vec4(0.0); |
| 39 | 39 | float alpha_antialiasing_edge = 0.0; |
| 40 | 40 | vec2 alpha_texture_coordinate = vec2(0.0); |
| 41 | 41 | |
| 42 | // Screen-space derivatives do not exist in ray tracing: a hit shader has no 2x2 |
| 43 | // pixel quad, so dFdx/dFdy/fwidth have no closest-hit overload and glslang |
| 44 | // rejects any shader calling them -- failing the whole hit group, which |
| 45 | // build_tlas then skips, leaving the geometry invisible but still collidable. |
| 46 | // |
| 47 | // These are macros rather than functions because redefining a built-in with an |
| 48 | // existing signature is not legal GLSL, and macros stay type-generic. |
| 49 | // |
| 50 | // LIMITATION: the derivative is zero, so textureGrad/textureQueryLod select |
| 51 | // LOD 0 and screen-footprint mip selection is lost under RT (expect aliasing on |
| 52 | // minified detail). Doing this properly needs ray differentials or ray cones, |
| 53 | // which require the hit triangle's attribute gradients and so cannot be |
| 54 | // expressed as a macro over an arbitrary expression. |
| 55 | #define dFdx(m_v) ((m_v) * 0.0) |
| 56 | #define dFdy(m_v) ((m_v) * 0.0) |
| 57 | #define dFdxCoarse(m_v) ((m_v) * 0.0) |
| 58 | #define dFdyCoarse(m_v) ((m_v) * 0.0) |
| 59 | #define dFdxFine(m_v) ((m_v) * 0.0) |
| 60 | #define dFdyFine(m_v) ((m_v) * 0.0) |
| 61 | #define fwidth(m_v) ((m_v) * 0.0) |
| 62 | |
| 42 | 63 | // Screen/depth textures are unavailable in RT -- alias to bindless slot 0 |
| 43 | 64 | // so shaders that reference them still compile (reads return dummy values). |
| 44 | 65 | #define depth_buffer bindless_textures[0] |