Files
Seele/res/shaders/lib/Scene.slang
T

95 lines
1.8 KiB
Plaintext
Raw Normal View History

2024-03-29 08:49:03 +01:00
import Bounding;
2023-10-24 15:01:09 +02:00
2025-04-15 00:33:49 +02:00
struct PoolRange
{
uint32_t offset;
uint32_t size;
};
2023-10-07 19:29:53 +02:00
struct MeshletDescription
{
AABB bounding;
2025-04-15 00:33:49 +02:00
// range into vertexIndices array
PoolRange vertexIndices;
// range into primitiveIndices array
PoolRange primitiveIndices;
uint32_t indicesOffset;
2025-05-13 10:29:05 +02:00
uint32_t lod;
uint32_t pad0;
uint32_t pad1;
2023-10-07 19:29:53 +02:00
};
2023-10-24 15:01:09 +02:00
struct MeshData
{
AABB bounding;
2025-04-15 00:33:49 +02:00
PoolRange meshletRange;
// offset into the global index buffer
PoolRange indicesRange;
2023-10-24 15:01:09 +02:00
};
2025-06-20 13:06:57 +02:00
static const uint32_t MAX_VERTICES = 128;
static const uint32_t MAX_PRIMITIVES = 128;
2023-10-24 15:01:09 +02:00
struct InstanceData
{
float4x4 transformMatrix;
float4x4 inverseTransformMatrix;
2023-10-24 15:01:09 +02:00
};
2024-05-30 16:56:22 +02:00
struct MeshletCullingInfo
{
2024-06-19 10:33:19 +02:00
uint32_t visible;
bool wasVisible()
{
2024-06-19 10:33:19 +02:00
return bool(visible);
}
2024-05-30 16:56:22 +02:00
};
2023-10-24 15:01:09 +02:00
struct Scene
{
2025-05-12 22:48:01 +02:00
StructuredBuffer<float> positions;
StructuredBuffer<uint> indexBuffer;
StructuredBuffer<InstanceData> instances;
StructuredBuffer<MeshData> meshData;
StructuredBuffer<MeshletDescription> meshletInfos;
StructuredBuffer<uint8_t> primitiveIndices;
StructuredBuffer<uint32_t> vertexIndices;
StructuredBuffer<uint32_t> cullingOffsets;
2024-06-07 09:19:47 +02:00
StructuredBuffer<MeshletCullingInfo> cullingInfos;
2023-10-24 15:01:09 +02:00
};
2024-04-23 19:11:06 +02:00
ParameterBlock<Scene> pScene;
2023-10-07 19:29:53 +02:00
2026-04-12 20:49:02 +02:00
struct DrawCallOffsets
{
uint instanceOffset;
uint textureOffset;
uint samplerOffset;
uint floatOffset;
};
#ifdef RAY_TRACING
// Shader record buffers are accessed via a different mechanism and don't use descriptor set bindings
layout(set = 15, shaderRecordEXT)
#else
layout(push_constant)
#endif
ConstantBuffer<DrawCallOffsets> pOffsets;
2024-06-19 10:33:19 +02:00
uint32_t encodePrimitive(uint32_t meshletId)
{
2024-06-19 10:33:19 +02:00
return meshletId;
}
2024-06-19 10:33:19 +02:00
uint decodePrimitive(uint32_t encoded)
{
2024-06-19 10:33:19 +02:00
return encoded;
}
2024-05-12 19:36:32 +02:00
struct MeshPayload
{
2025-03-09 22:42:05 +01:00
uint culledMeshlets[2048];
uint instanceId;
uint meshletOffset;
uint cullingOffset;
2024-05-12 19:36:32 +02:00
};