| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- // Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
- // All rights reserved.
- // Code licensed under the BSD License.
- // http://www.anki3d.org/LICENSE
- #pragma anki library RtShadows
- #pragma anki ray_type 0
- #pragma anki mutator ANKI_TECHNIQUE 4
- #pragma anki mutator ALPHA_TEXTURE 0 1
- #include <AnKi/Shaders/Common.glsl>
- #include <AnKi/Shaders/Include/ModelTypes.h>
- layout(shaderRecordEXT, scalar) buffer b_model
- {
- ModelGpuDescriptor u_modelDescriptor;
- };
- layout(set = 0, binding = 5) uniform sampler u_sampler;
- ANKI_BINDLESS_SET(1);
- layout(location = 0) rayPayloadInEXT F32 g_payload;
- #pragma anki start ahit
- hitAttributeEXT vec2 g_attribs;
- #if ALPHA_TEXTURE == 1 && ANKI_SUPPORTS_64BIT
- ANKI_DEFINE_LOAD_STORE(U16Vec3, 2)
- ANKI_DEFINE_LOAD_STORE(MainVertex, ANKI_ALIGNOF(MainVertex))
- #endif
- void main()
- {
- #if ALPHA_TEXTURE == 1 && ANKI_SUPPORTS_64BIT
- const ModelGpuDescriptor model = u_modelDescriptor;
- const MeshGpuDescriptor mesh = model.m_mesh;
- const U32 offset = U32(gl_PrimitiveID) * ANKI_SIZEOF(U16Vec3);
- U16Vec3 indices16;
- load(mesh.m_indexBufferPtr + U64(offset), indices16);
- const UVec3 indices = UVec3(indices16);
- const U64 vertBufferPtr = mesh.m_vertexBufferPtrs[VERTEX_ATTRIBUTE_BUFFER_ID_NORMAL_TANGENT_UV0];
- MainVertex vert0, vert1, vert2;
- load(vertBufferPtr + U64(indices[0] * ANKI_SIZEOF(MainVertex)), vert0);
- load(vertBufferPtr + U64(indices[1] * ANKI_SIZEOF(MainVertex)), vert1);
- load(vertBufferPtr + U64(indices[2] * ANKI_SIZEOF(MainVertex)), vert2);
- const Vec3 barycentrics = Vec3(1.0f - g_attribs.x - g_attribs.y, g_attribs.x, g_attribs.y);
- const Vec2 uv = vert0.m_uv0 * barycentrics.x + vert1.m_uv0 * barycentrics.y + vert2.m_uv0 * barycentrics.z;
- const U32 texIdx = U32(model.m_material.m_bindlessTextureIndices[TEXTURE_CHANNEL_ID_DIFFUSE]);
- const F32 alpha = textureLod(u_bindlessTextures2dF32[nonuniformEXT(texIdx)], u_sampler, uv, 3.0).a;
- g_payload += alpha;
- if(g_payload >= 1.0)
- {
- terminateRayEXT;
- }
- #else
- terminateRayEXT;
- #endif
- }
- #pragma anki end
- #pragma anki start chit
- void main()
- {
- }
- #pragma anki end
|