#include "Common.hlsl" [shader("anyhit")] void ChunkAnyHit(inout RayHits rayPayload, ChunkHitAttributes attrib) { if (rayPayload.hitCount < 0) { // shadow ray rayPayload.hitCount = 0; // TODO: transparent objects should lead to half shadows AcceptHitAndEndSearch(); return; } Texture2D texture = textures[attrib.textureId]; float4 color = texture.SampleLevel(gSampler, attrib.texCoord, 0); if (color.w == 0.f) { IgnoreHit(); return; } SingleHit hit; hit.color = color; hit.normal = attrib.normal; hit.distance = RayTCurrent(); hit.dayLight = attrib.dayLight; hit.dynamicLight = attrib.dynamicLight; applyHit(rayPayload, hit); if (color.w < 1.f) { IgnoreHit(); return; } }