Updating slang
This commit is contained in:
@@ -32,6 +32,7 @@ groupshared uint uMinDepth;
|
||||
groupshared uint uMaxDepth;
|
||||
|
||||
groupshared Frustum groupFrustum;
|
||||
groupshared float4x4 viewMatrix;
|
||||
|
||||
groupshared uint oLightCount;
|
||||
groupshared uint oLightIndexStartOffset;
|
||||
@@ -72,6 +73,7 @@ void cullLights(ComputeShaderInput in)
|
||||
uint uDepth = asuint(fDepth);
|
||||
if(in.groupIndex == 0)
|
||||
{
|
||||
viewMatrix = pViewParams.viewMatrix;
|
||||
uMinDepth = 0xffffffff;
|
||||
uMaxDepth = 0x0;
|
||||
oLightCount = 0;
|
||||
@@ -98,11 +100,11 @@ void cullLights(ComputeShaderInput in)
|
||||
for ( uint i = in.groupIndex; i < pLightEnv.numPointLights; i += BLOCK_SIZE * BLOCK_SIZE )
|
||||
{
|
||||
PointLight light = pLightEnv.pointLights[i];
|
||||
float3 light_VS = light.getViewPosition();
|
||||
if(light.insideFrustum(groupFrustum, light_VS, nearClipVS, maxDepthVS))
|
||||
float3 light_VS = mul(viewMatrix, float4(light.position_WS.xyz, 1.0f)).xyz;
|
||||
//if(light.insideFrustum(groupFrustum, light_VS, nearClipVS, maxDepthVS))
|
||||
{
|
||||
tAppendLight(i);
|
||||
if(!light.insidePlane(minPlane, light_VS))
|
||||
//if(!light.insidePlane(minPlane, light_VS))
|
||||
{
|
||||
oAppendLight(i);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ void taskMain(
|
||||
{
|
||||
uint m = mesh.meshletOffset + i;
|
||||
MeshletDescription meshlet = pScene.meshletInfos[m];
|
||||
if(meshlet.bounding.insideFrustum(localToView, viewFrustum))
|
||||
//if(meshlet.bounding.insideFrustum(localToView, viewFrustum))
|
||||
{
|
||||
uint index;
|
||||
InterlockedAdd(head, 1, index);
|
||||
@@ -72,41 +72,23 @@ void meshMain(
|
||||
in uint threadID: SV_GroupIndex,
|
||||
in uint groupID: SV_GroupID,
|
||||
in payload MeshPayload meshPayload,
|
||||
out Vertices<FragmentParameter, MAX_VERTICES> vertices,
|
||||
out Indices<uint3, MAX_PRIMITIVES> indices
|
||||
OutputVertices<FragmentParameter, MAX_VERTICES> vertices,
|
||||
OutputIndices<uint3, MAX_PRIMITIVES> indices
|
||||
){
|
||||
InstanceData inst = pScene.instances[meshPayload.instanceId[groupID]];
|
||||
MeshData md = pScene.meshData[meshPayload.instanceId[groupID]];
|
||||
MeshletDescription m = pScene.meshletInfos[meshPayload.meshletId[groupID]];
|
||||
SetMeshOutputCounts(m.vertexCount, m.primitiveCount);
|
||||
|
||||
uint p = min(threadID, m.primitiveCount - 1);
|
||||
for(uint i = threadID; i < MAX_PRIMITIVES; i += MESH_GROUP_SIZE)
|
||||
{
|
||||
uint local_idx0 = pScene.primitiveIndices[m.primitiveOffset + (p * 3) + 0];
|
||||
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);
|
||||
}
|
||||
p = min(threadID + 32, m.primitiveCount - 1);
|
||||
{
|
||||
uint local_idx0 = pScene.primitiveIndices[m.primitiveOffset + (p * 3) + 0];
|
||||
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);
|
||||
}
|
||||
p = min(threadID + 64, m.primitiveCount - 1);
|
||||
{
|
||||
uint local_idx0 = pScene.primitiveIndices[m.primitiveOffset + (p * 3) + 0];
|
||||
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);
|
||||
}
|
||||
p = min(threadID + 96, m.primitiveCount - 1);
|
||||
{
|
||||
uint local_idx0 = pScene.primitiveIndices[m.primitiveOffset + (p * 3) + 0];
|
||||
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);
|
||||
uint p = min(i, m.primitiveCount - 1);
|
||||
{
|
||||
uint local_idx0 = pScene.primitiveIndices[m.primitiveOffset + (p * 3) + 0];
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
GroupMemoryBarrierWithGroupSync();
|
||||
|
||||
@@ -32,11 +32,6 @@ struct PointLight : ILightEnv
|
||||
float illuminance = max(1 - d / colorRange.w, 0);
|
||||
return illuminance * brdf.evaluate(params.tbn, params.viewDir_TS, -normalize(lightDir_TS), colorRange.xyz);
|
||||
}
|
||||
float3 getViewPosition()
|
||||
{
|
||||
float4 position_VS = mul(pViewParams.viewMatrix, position_WS);
|
||||
return position_VS.xyz / position_VS.w;
|
||||
}
|
||||
|
||||
bool insidePlane(Plane plane, float3 position_VS)
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@ import Bounding;
|
||||
|
||||
struct MeshletDescription
|
||||
{
|
||||
AABB bounding;
|
||||
BoundingSphere bounding;
|
||||
uint32_t vertexCount;
|
||||
uint32_t primitiveCount;
|
||||
uint32_t vertexOffset;
|
||||
@@ -13,7 +13,7 @@ struct MeshletDescription
|
||||
|
||||
struct MeshData
|
||||
{
|
||||
AABB bounding;
|
||||
BoundingSphere bounding;
|
||||
uint32_t numMeshlets;
|
||||
uint32_t meshletOffset;
|
||||
uint32_t firstIndex;
|
||||
|
||||
Reference in New Issue
Block a user