| 1234567891011121314151617181920212223242526272829303132 |
- #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<float4> 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;
- }
- }
|