https://github.com/shader-slang/slang
Raw File
Tip revision: 67486ee516ddc33806003727682cbfc68ab1f726 authored by jsmall-nvidia on 28 May 2021, 21:15:12 UTC
Glslang refactor bugfix (#1863)
Tip revision: 67486ee
closesthit.slang
// closesthit.slang
//TEST:CROSS_COMPILE: -profile glsl_460+GL_NV_ray_tracing -stage closesthit -entry main -target spirv-assembly

struct ReflectionRay
{
    float4 color;
};

StructuredBuffer<float4> colors;

layout(shaderRecordNV)
cbuffer ShaderRecord
{
	uint shaderRecordID;
}

void main(
	BuiltInTriangleIntersectionAttributes 	attributes,
	in out ReflectionRay 					ioPayload)
{
	uint materialID = InstanceIndex()
		+ InstanceID()
		+ PrimitiveIndex()
		+ HitKind()
		+ shaderRecordID;

	float4 color = colors[materialID];

	color *= RayTCurrent() - RayTMin();

	ioPayload.color = color;
}
back to top