A bit of light culling refactor
This commit is contained in:
@@ -27,6 +27,10 @@ struct Plane
|
|||||||
{
|
{
|
||||||
float3 n;
|
float3 n;
|
||||||
float d;
|
float d;
|
||||||
|
bool pointInside(float3 point)
|
||||||
|
{
|
||||||
|
return dot(n, point) - d > 0.0f;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Frustum
|
struct Frustum
|
||||||
@@ -35,13 +39,13 @@ struct Frustum
|
|||||||
Plane basePlane;
|
Plane basePlane;
|
||||||
bool pointInside(float3 point)
|
bool pointInside(float3 point)
|
||||||
{
|
{
|
||||||
if (dot(basePlane.n, point) + basePlane.d > 0.0f)
|
if (basePlane.pointInside(point))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for(int p = 0; p < 4; ++p)
|
for(int p = 0; p < 4; ++p)
|
||||||
{
|
{
|
||||||
if(dot(sides[p].n, point) + sides[p].d > 0.0f)
|
if(sides[p].pointInside(point))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,26 +33,20 @@ struct PointLight : ILightEnv
|
|||||||
return illuminance * brdf.evaluate(params.tbn, params.viewDir_TS, normalize(lightDir_TS), colorRange.xyz);
|
return illuminance * brdf.evaluate(params.tbn, params.viewDir_TS, normalize(lightDir_TS), colorRange.xyz);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool insidePlane(Plane plane)
|
bool insidePlane(Plane plane, float3 position_CS)
|
||||||
{
|
{
|
||||||
return true;//dot(plane.n, getViewPos().xyz) - plane.d < -colorRange.w;
|
return plane.pointInside(position_CS);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool insideFrustum(Frustum frustum, float zNear, float zFar)
|
bool insideFrustum(Frustum frustum)
|
||||||
{
|
{
|
||||||
bool result = true;
|
bool result = true;
|
||||||
|
float4 clipPos = mul(pViewParams.projectionMatrix, mul(pViewParams.viewMatrix, position_WS));
|
||||||
|
float3 position_CS = clipPos.xyz / clipPos.w;
|
||||||
|
for(int i = 0; i < 4; ++i)
|
||||||
|
{
|
||||||
|
|
||||||
//if(getViewPos().z - colorRange.w > zNear || getViewPos().z + colorRange.w < zFar)
|
}
|
||||||
//{
|
|
||||||
// //result = false;
|
|
||||||
//}
|
|
||||||
//for(int i = 0; i < 4 && result; ++i)
|
|
||||||
//{
|
|
||||||
// if(insidePlane(frustum.sides[i]))
|
|
||||||
// {
|
|
||||||
// //result = false;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -36,10 +36,11 @@ Graphics::~Graphics()
|
|||||||
vkDeviceWaitIdle(handle);
|
vkDeviceWaitIdle(handle);
|
||||||
pipelineCache = nullptr;
|
pipelineCache = nullptr;
|
||||||
allocator = nullptr;
|
allocator = nullptr;
|
||||||
destructionManager = nullptr;
|
|
||||||
allocatedFramebuffers.clear();
|
allocatedFramebuffers.clear();
|
||||||
shaderCompiler = nullptr;
|
shaderCompiler = nullptr;
|
||||||
pools.clear();
|
pools.clear();
|
||||||
|
queues.clear();
|
||||||
|
destructionManager = nullptr;
|
||||||
vkDestroyDevice(handle, nullptr);
|
vkDestroyDevice(handle, nullptr);
|
||||||
DestroyDebugUtilsMessengerEXT(instance, nullptr, callback);
|
DestroyDebugUtilsMessengerEXT(instance, nullptr, callback);
|
||||||
vkDestroyInstance(instance, nullptr);
|
vkDestroyInstance(instance, nullptr);
|
||||||
@@ -483,7 +484,7 @@ void Graphics::pickPhysicalDevice()
|
|||||||
{
|
{
|
||||||
if (std::strcmp(VK_EXT_MESH_SHADER_EXTENSION_NAME, extensionProps[i].extensionName) == 0)
|
if (std::strcmp(VK_EXT_MESH_SHADER_EXTENSION_NAME, extensionProps[i].extensionName) == 0)
|
||||||
{
|
{
|
||||||
//meshShadingEnabled = true;
|
meshShadingEnabled = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -321,10 +321,10 @@ void TextureBase::executeOwnershipBarrier(Gfx::QueueType newOwner)
|
|||||||
.image = image,
|
.image = image,
|
||||||
.subresourceRange = {
|
.subresourceRange = {
|
||||||
.aspectMask = aspect,
|
.aspectMask = aspect,
|
||||||
.baseArrayLayer = 0,
|
|
||||||
.layerCount = arrayCount,
|
|
||||||
.baseMipLevel = 0,
|
.baseMipLevel = 0,
|
||||||
.levelCount = mipLevels,
|
.levelCount = mipLevels,
|
||||||
|
.baseArrayLayer = 0,
|
||||||
|
.layerCount = arrayCount,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
PCommandPool sourcePool = graphics->getQueueCommands(currentOwner);
|
PCommandPool sourcePool = graphics->getQueueCommands(currentOwner);
|
||||||
|
|||||||
Reference in New Issue
Block a user