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

95 lines
1.8 KiB
Plaintext

import Bounding;
struct PoolRange
{
uint32_t offset;
uint32_t size;
};
struct MeshletDescription
{
AABB bounding;
// range into vertexIndices array
PoolRange vertexIndices;
// range into primitiveIndices array
PoolRange primitiveIndices;
uint32_t indicesOffset;
uint32_t lod;
uint32_t pad0;
uint32_t pad1;
};
struct MeshData
{
AABB bounding;
PoolRange meshletRange;
// offset into the global index buffer
PoolRange indicesRange;
};
static const uint32_t MAX_VERTICES = 128;
static const uint32_t MAX_PRIMITIVES = 128;
struct InstanceData
{
float4x4 transformMatrix;
float4x4 inverseTransformMatrix;
};
struct MeshletCullingInfo
{
uint32_t visible;
bool wasVisible()
{
return bool(visible);
}
};
struct Scene
{
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;
StructuredBuffer<MeshletCullingInfo> cullingInfos;
};
ParameterBlock<Scene> pScene;
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;
uint32_t encodePrimitive(uint32_t meshletId)
{
return meshletId;
}
uint decodePrimitive(uint32_t encoded)
{
return encoded;
}
struct MeshPayload
{
uint culledMeshlets[2048];
uint instanceId;
uint meshletOffset;
uint cullingOffset;
};