Staging before meshlet linearization
This commit is contained in:
@@ -12,8 +12,14 @@ struct LightCullingData
|
||||
layout(set=5)
|
||||
ParameterBlock<LightCullingData> pLightCullingData;
|
||||
|
||||
struct FragmentOutput
|
||||
{
|
||||
float4 color : SV_Target0;
|
||||
uint meshletId : SV_Target1;
|
||||
};
|
||||
|
||||
[shader("pixel")]
|
||||
float4 fragmentMain(in FragmentParameter params) : SV_Target
|
||||
FragmentOutput fragmentMain(in FragmentParameter params)
|
||||
{
|
||||
LightingParameter lightingParams = params.getLightingParameter();
|
||||
MaterialParameter materialParams = params.getMaterialParameter();
|
||||
@@ -35,5 +41,8 @@ float4 fragmentMain(in FragmentParameter params) : SV_Target
|
||||
// gamma correction
|
||||
result = result / (result + float3(1.0));
|
||||
result = pow(result, float3(1.0/2.2));
|
||||
return float4(result, 1.0f);
|
||||
FragmentOutput output;
|
||||
output.color = float4(result, 1.0f);
|
||||
output.meshletId = params.meshletId;
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,8 @@ void meshMain(
|
||||
uint v = min(i, m.vertexCount - 1);
|
||||
{
|
||||
uint vertexIndex = pScene.vertexIndices[m.vertexOffset + v];
|
||||
VertexAttributes attr = pVertexData.getAttributes(md.indicesOffset + vertexIndex);
|
||||
VertexAttributes attr = pVertexData.getAttributes(m.indicesOffset + vertexIndex);
|
||||
attr.meshletId = -1;
|
||||
vertices[v] = attr.getParameter(inst.transformMatrix);
|
||||
//vertices[v].vertexColor = m.color;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,12 @@ struct PrimitiveAttributes
|
||||
uint cull: SV_CullPrimitive;
|
||||
};
|
||||
|
||||
struct CulledMeshletList
|
||||
{
|
||||
StructuredBuffer<uint> meshletIndices;
|
||||
};
|
||||
ParameterBlock<CulledMeshletList> pCullingList;
|
||||
|
||||
[numthreads(MESH_GROUP_SIZE, 1, 1)]
|
||||
[outputtopology("triangle")]
|
||||
[shader("mesh")]
|
||||
@@ -18,7 +24,8 @@ void meshMain(
|
||||
out vertices FragmentParameter vertices[MAX_VERTICES],
|
||||
out indices uint3 indices[MAX_PRIMITIVES]
|
||||
){
|
||||
MeshletDescription m = pScene.meshletInfos[groupID];
|
||||
uint meshletIndex = pCullingList.meshletIndices[groupID];
|
||||
MeshletDescription m = pScene.meshletInfos[meshletIndex];
|
||||
SetMeshOutputCounts(m.vertexCount, m.primitiveCount);
|
||||
|
||||
for(uint i = threadID; i < MAX_PRIMITIVES; i += MESH_GROUP_SIZE)
|
||||
@@ -36,7 +43,8 @@ void meshMain(
|
||||
uint v = min(i, m.vertexCount - 1);
|
||||
{
|
||||
uint vertexIndex = pScene.vertexIndices[m.vertexOffset + v];
|
||||
VertexAttributes attr = pVertexData.getAttributes(md.indicesOffset + vertexIndex);
|
||||
VertexAttributes attr = pVertexData.getAttributes(m.indicesOffset + vertexIndex);
|
||||
attr.meshletId = meshletIndex;
|
||||
vertices[v] = attr.getParameter(float4x4(1.0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ struct FragmentParameter
|
||||
float3 biTangent_WS : TANGENT1;
|
||||
float3 position_WS : POSITION2;
|
||||
float3 vertexColor : COLOR0;
|
||||
uint meshletId : POSITION3;
|
||||
float2 texCoords[MAX_TEXCOORDS] : TEXCOORD0;
|
||||
MaterialParameter getMaterialParameter()
|
||||
{
|
||||
@@ -55,6 +56,7 @@ struct VertexAttributes
|
||||
float3 tangent_MS;
|
||||
float3 biTangent_MS;
|
||||
float3 vertexColor;
|
||||
uint meshletId;
|
||||
float2 texCoords[MAX_TEXCOORDS];
|
||||
FragmentParameter getParameter(float4x4 transformMatrix)
|
||||
{
|
||||
@@ -73,6 +75,7 @@ struct VertexAttributes
|
||||
result.position_WS = worldPos.xyz;
|
||||
result.position_CS = clipPos;
|
||||
result.vertexColor = vertexColor;
|
||||
result.meshletId = meshletId;
|
||||
for(uint i = 0; i < MAX_TEXCOORDS; ++i)
|
||||
{
|
||||
result.texCoords[i] = texCoords[i];
|
||||
|
||||
@@ -8,7 +8,7 @@ struct MeshletDescription
|
||||
uint32_t vertexOffset;
|
||||
uint32_t primitiveOffset;
|
||||
float3 color;
|
||||
float pad;
|
||||
uint32_t indicesOffset;
|
||||
};
|
||||
|
||||
struct MeshData
|
||||
@@ -18,8 +18,6 @@ struct MeshData
|
||||
uint32_t meshletOffset;
|
||||
uint32_t firstIndex;
|
||||
uint32_t numIndices;
|
||||
uint32_t indicesOffset;
|
||||
uint32_t pad0[3];
|
||||
};
|
||||
|
||||
static const uint MAX_VERTICES = 256;
|
||||
|
||||
Reference in New Issue
Block a user