#include "Common.hlsl" StructuredBuffer textureIdBuffer : register(t1, space2); StructuredBuffer indexBuffer : register(t1, space3); StructuredBuffer vertexData : register(t1, space4); StructuredBuffer indexOffsetBuffer : register(t1, space5); [shader("closesthit")] void SimpleBlocksClosestHit(inout RayHits currentPayload, SimpleBlocksAttributes attrib) { if (currentPayload.hitCount == 0) { return; // already inside of shadow ray } RayHits tmpPayload; // shadow rays for (int i = 0; i < currentPayload.hitCount; i++) { tmpPayload.hitCount = -1; // shadow ray RayDesc ray; ray.Origin = WorldRayOrigin() + (currentPayload.hits[i].distance - 0.001) * WorldRayDirection(); ray.Direction = dayLightDirection; ray.TMin = 0.00001; ray.TMax = 1000; TraceRay(TLAS, 0, 0xFF, 0, 0, 0, ray, tmpPayload); float normalFactor = saturate(dot(normalize(currentPayload.hits[i].normal), normalize(dayLightDirection))); float3 color = unpackLight(currentPayload.hits[i].dayLight) * dayLightFactor; if (tmpPayload.hitCount == 0) { color = color / 2; } else { color = dayLightFactor * (0.5 + normalFactor / 2); } currentPayload.hits[i].dayLight = packLight(color); } // TODO: reflection rays }