Visibility reset doesnt work anymore for some reason
This commit is contained in:
@@ -4,6 +4,10 @@ import Scene;
|
||||
groupshared MeshPayload p;
|
||||
groupshared uint head;
|
||||
groupshared MeshData mesh;
|
||||
groupshared InstanceData instance;
|
||||
groupshared Frustum viewFrustum;
|
||||
|
||||
ParameterBlock<Texture2D> pDepthAttachment;
|
||||
|
||||
[numthreads(TASK_GROUP_SIZE, 1, 1)]
|
||||
[shader("amplification")]
|
||||
@@ -14,10 +18,23 @@ void taskMain(
|
||||
if (threadID == 0)
|
||||
{
|
||||
head = 0;
|
||||
instance = pScene.instances[pOffsets.instanceOffset + groupID];
|
||||
mesh = pScene.meshData[pOffsets.instanceOffset + groupID];
|
||||
p.instanceId = pOffsets.instanceOffset + groupID;
|
||||
p.meshletOffset = mesh.meshletOffset;
|
||||
p.cullingOffset = pScene.cullingOffsets[p.instanceId];
|
||||
float3 origin = viewToModel(instance.inverseTransformMatrix, float4(0, 0, 0, 1)).xyz;
|
||||
const float offset = 0.0f;
|
||||
float3 corners[4] = {
|
||||
screenToModel(instance.inverseTransformMatrix, float4(offset, offset, -1.0f, 1.0f)).xyz,
|
||||
screenToModel(instance.inverseTransformMatrix, float4(pViewParams.screenDimensions.x - offset, offset, -1.0f, 1.0f)).xyz,
|
||||
screenToModel(instance.inverseTransformMatrix, float4(offset, pViewParams.screenDimensions.y - offset, -1.0f, 1.0f)).xyz,
|
||||
screenToModel(instance.inverseTransformMatrix, float4(pViewParams.screenDimensions - float2(offset, offset), -1.0f, 1.0f)).xyz
|
||||
};
|
||||
viewFrustum.sides[0] = computePlane(origin, corners[2], corners[0]);
|
||||
viewFrustum.sides[1] = computePlane(origin, corners[1], corners[3]);
|
||||
viewFrustum.sides[2] = computePlane(origin, corners[0], corners[1]);
|
||||
viewFrustum.sides[3] = computePlane(origin, corners[3], corners[2]);
|
||||
}
|
||||
GroupMemoryBarrierWithGroupSync();
|
||||
for (uint i = threadID; i < mesh.numMeshlets; i += TASK_GROUP_SIZE)
|
||||
@@ -26,11 +43,17 @@ void taskMain(
|
||||
uint cull = p.cullingOffset + i;
|
||||
MeshletDescription meshlet = pScene.meshletInfos[m];
|
||||
MeshletCullingInfo culling = pScene.cullingInfos[cull];
|
||||
if(false)//if(!culling.anyVisible())
|
||||
// if any triangle was visible last frame, it was drawn by the cached pass already
|
||||
if(!culling.anyVisible())
|
||||
{
|
||||
uint index;
|
||||
InterlockedAdd(head, 1, index);
|
||||
p.culledMeshlets[index] = i;
|
||||
#ifdef VIEW_CULLING
|
||||
if(meshlet.bounding.insideFrustum(viewFrustum))
|
||||
#endif
|
||||
{
|
||||
uint index;
|
||||
InterlockedAdd(head, 1, index);
|
||||
p.culledMeshlets[index] = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
GroupMemoryBarrierWithGroupSync();
|
||||
|
||||
@@ -38,7 +38,7 @@ void meshMain(
|
||||
uint local_idx1 = pScene.primitiveIndices[m.primitiveOffset + (p * 3) + 1];
|
||||
uint local_idx2 = pScene.primitiveIndices[m.primitiveOffset + (p * 3) + 2];
|
||||
indices[p] = uint3(local_idx0, local_idx1, local_idx2);
|
||||
prim[p].cull = cull.triangleCulled(p);
|
||||
prim[p].cull = false;//cull.triangleCulled(p);
|
||||
#ifdef VISIBILITY
|
||||
prim[p].prim = encodePrimitive(p, meshletId);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user