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

86 lines
1.6 KiB
Plaintext
Raw Normal View History

2024-03-29 08:49:03 +01:00
import Bounding;
2023-10-24 15:01:09 +02:00
2023-10-07 19:29:53 +02:00
struct MeshletDescription
{
AABB bounding;
uint32_t vertexCount;
uint32_t primitiveCount;
uint32_t vertexOffset;
uint32_t primitiveOffset;
float3 color;
uint32_t indicesOffset;
2023-10-07 19:29:53 +02:00
};
2023-10-24 15:01:09 +02:00
struct MeshData
{
AABB bounding;
uint32_t numMeshlets;
uint32_t meshletOffset;
uint32_t firstIndex;
uint32_t numIndices;
2023-10-24 15:01:09 +02:00
};
2024-10-01 16:56:04 +02:00
static const uint32_t MAX_VERTICES = 256;
static const uint32_t MAX_PRIMITIVES = 256;
2024-06-04 21:34:14 +02:00
static const uint32_t MAX_MESHLETS_PER_INSTANCE = 2048;
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
};
2024-09-27 17:42:50 +02:00
struct DrawCallOffsets
2024-05-12 19:36:32 +02:00
{
2024-07-10 21:07:10 +02:00
uint instanceOffset;
2024-06-18 19:19:05 +02:00
uint textureOffset;
uint samplerOffset;
uint floatOffset;
2024-09-27 17:42:50 +02:00
};
#ifdef RAY_TRACING
layout(shaderRecordEXT)
#else
layout(push_constant)
#endif
ConstantBuffer<DrawCallOffsets> pOffsets;
2024-05-12 19:36:32 +02:00
2023-10-24 15:01:09 +02:00
struct Scene
{
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
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
{
2024-05-31 14:21:32 +02:00
uint culledMeshlets[MAX_MESHLETS_PER_INSTANCE];
uint instanceId;
uint meshletOffset;
uint cullingOffset;
2024-05-12 19:36:32 +02:00
};