//SPDX-License-Identifier: MIT //SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts® #version 460 #extension GL_EXT_ray_tracing : enable #extension GL_EXT_shader_image_load_formatted : enable #extension GL_EXT_shader_explicit_arithmetic_types_int16 : enable #extension GL_EXT_descriptor_heap : enable #extension GL_EXT_nonuniform_qualifier : enable // Specialization constants: the albedo's slot in the resource heap and its // sampler's slot in the sampler heap, as the host allocated them (image and // sampler slots index their heaps directly; only buffer slots are offset by // bufferStartElement). The descriptor heap has no combined image samplers, // and glslang rejects a descriptor_heap sampler2D (#164), so the texture // and the sampler are separate descriptors, joined where they are sampled. // Sampling uses gl_HitAttributeEXT barycentrics as UVs — proof-of-binding // rather than UV-correct shading. Per-vertex UV interpolation lands when // Mesh on Vulkan exposes the data-region buffer. layout(constant_id = 0) const uint16_t albedoSlot = 0us; layout(constant_id = 1) const uint16_t samplerSlot = 0us; layout(descriptor_heap) uniform texture2D textures[]; layout(descriptor_heap) uniform sampler samplers[]; hitAttributeEXT vec2 hitAttrs; layout(location = 0) rayPayloadInEXT vec3 hitValue; void main() { vec2 bary = vec2(hitAttrs.x, hitAttrs.y); hitValue = texture(sampler2D(textures[albedoSlot], samplers[samplerSlot]), bary).rgb; }