Trying new meshlet gen approach
This commit is contained in:
@@ -31,5 +31,5 @@ float4 fragmentMain(in FragmentParameter params) : SV_Target
|
||||
uint lightIndex = pLightCullingData.lightIndexList[startOffset + i];
|
||||
result += pLightEnv.pointLights[lightIndex].illuminate(lightingParams, brdf);
|
||||
}
|
||||
return float4(result, 1.0f);
|
||||
return float4(params.vertexColor, 1.0f);
|
||||
}
|
||||
|
||||
@@ -101,10 +101,10 @@ void cullLights(ComputeShaderInput in)
|
||||
{
|
||||
PointLight light = pLightEnv.pointLights[i];
|
||||
float3 light_VS = mul(viewMatrix, float4(light.position_WS.xyz, 1.0f)).xyz;
|
||||
//if(light.insideFrustum(groupFrustum, light_VS, nearClipVS, maxDepthVS))
|
||||
if(light.insideFrustum(groupFrustum, light_VS, nearClipVS, maxDepthVS))
|
||||
{
|
||||
tAppendLight(i);
|
||||
//if(!light.insidePlane(minPlane, light_VS))
|
||||
if(!light.insidePlane(minPlane, light_VS))
|
||||
{
|
||||
oAppendLight(i);
|
||||
}
|
||||
|
||||
@@ -29,10 +29,10 @@ void taskMain(
|
||||
localToView = mul(pViewParams.viewMatrix, instance.transformMatrix);
|
||||
float3 origin = float3(0, 0, 0);
|
||||
float3 corners[4] = {
|
||||
screenToView(float4(pViewParams.screenDimensions, -1.0f, 1.0f)).xyz,
|
||||
screenToView(float4(pViewParams.screenDimensions, -1.0f, 1.0f)).xyz,
|
||||
screenToView(float4(pViewParams.screenDimensions, -1.0f, 1.0f)).xyz,
|
||||
screenToView(float4(pViewParams.screenDimensions, -1.0f, 1.0f)).xyz
|
||||
screenToView(float4(100.0f, 100.0f, -1.0f, 1.0f)).xyz,
|
||||
screenToView(float4(pViewParams.screenDimensions.x - 100.0f, 100.0f, -1.0f, 1.0f)).xyz,
|
||||
screenToView(float4(100.0f, pViewParams.screenDimensions.y - 100.0f, -1.0f, 1.0f)).xyz,
|
||||
screenToView(float4(pViewParams.screenDimensions - float2(100.0f, 100.0f), -1.0f, 1.0f)).xyz
|
||||
};
|
||||
viewFrustum.sides[0] = computePlane(origin, corners[2], corners[0]);
|
||||
viewFrustum.sides[1] = computePlane(origin, corners[1], corners[3]);
|
||||
@@ -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);
|
||||
@@ -99,6 +99,7 @@ void meshMain(
|
||||
uint vertexIndex = pScene.vertexIndices[m.vertexOffset + v];
|
||||
VertexAttributes attr = pVertexData.getAttributes(md.indicesOffset + vertexIndex);
|
||||
vertices[v] = attr.getParameter(inst.transformMatrix);
|
||||
vertices[v].vertexColor = m.color;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ struct BoundingSphere
|
||||
bool result = true;
|
||||
for(int i = 0; i < 4 && result; ++i)
|
||||
{
|
||||
if(dot(frustum.sides[i].n, transformed) - frustum.sides[i].d < scaledRange)
|
||||
if(dot(frustum.sides[i].n, transformed) - frustum.sides[i].d < -scaledRange)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
@@ -48,7 +48,7 @@ struct AABB
|
||||
for(int i = 0; i < 8; ++i)
|
||||
{
|
||||
float3 adjusted = corners[i].xyz / corners[i].w;
|
||||
if(frustum.pointInside(corners[i].xyz))
|
||||
if(frustum.pointInside(adjusted))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ struct Plane
|
||||
float d;
|
||||
bool pointInside(float3 point)
|
||||
{
|
||||
return dot(n, point) - d < 0.0f;
|
||||
return dot(n, point) - d > 0.0f;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -49,7 +49,7 @@ struct Frustum
|
||||
{
|
||||
for(int p = 0; p < 4; ++p)
|
||||
{
|
||||
if(sides[p].pointInside(point))
|
||||
if(!sides[p].pointInside(point))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user