lot of metal changes, but no idea how this stuff works
This commit is contained in:
@@ -89,7 +89,7 @@ void cullLights(ComputeShaderInput in)
|
||||
float maxDepthWS = clipToWorld(float4(0, 0, fMaxDepth, 1)).z;
|
||||
float nearClipWS = clipToWorld(float4(0, 0, 0, 1)).z;
|
||||
|
||||
Plane maxPlane = {float3(0, 0, -1), -maxDepthWS};
|
||||
Plane maxPlane = {float4(0, 0, -1, -maxDepthWS)};
|
||||
|
||||
for ( uint i = in.groupIndex; i < pLightEnv.numPointLights; i += BLOCK_SIZE * BLOCK_SIZE )
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ struct BoundingSphere
|
||||
bool result = true;
|
||||
for(int i = 0; i < 4 && result; ++i)
|
||||
{
|
||||
if(dot(frustum.sides[i].n, getCenter()) - frustum.sides[i].d < -getRadius())
|
||||
if(dot(frustum.sides[i].getNormal(), getCenter()) - frustum.sides[i].getDistance() < -getRadius())
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
@@ -39,11 +39,11 @@ struct AABB
|
||||
bool result = true;
|
||||
for(int i = 0; i < 4 && result; ++i)
|
||||
{
|
||||
const float r = extents.x * abs(frustum.sides[i].n.x)
|
||||
+ extents.y * abs(frustum.sides[i].n.y)
|
||||
+ extents.z * abs(frustum.sides[i].n.z);
|
||||
const float r = extents.x * abs(frustum.sides[i].getNormal().x)
|
||||
+ extents.y * abs(frustum.sides[i].getNormal().y)
|
||||
+ extents.z * abs(frustum.sides[i].getNormal().z);
|
||||
|
||||
const float signedDistance = dot(frustum.sides[i].n, center) - frustum.sides[i].d;
|
||||
const float signedDistance = dot(frustum.sides[i].getNormal(), center) - frustum.sides[i].getDistance();
|
||||
if(signedDistance < -r)
|
||||
{
|
||||
result = false;
|
||||
|
||||
@@ -101,11 +101,18 @@ float4 clipToScreen(float4 clip)
|
||||
|
||||
struct Plane
|
||||
{
|
||||
float3 n;
|
||||
float d;
|
||||
float4 nd;
|
||||
float3 getNormal()
|
||||
{
|
||||
return nd.xyz;
|
||||
}
|
||||
float getDistance()
|
||||
{
|
||||
return nd.w;
|
||||
}
|
||||
bool pointInside(float3 point)
|
||||
{
|
||||
return dot(n, point) - d > 0.0f;
|
||||
return dot(getNormal(), point) - getDistance() > 0.0f;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -131,9 +138,11 @@ Plane computePlane(float3 p0, float3 p1, float3 p2)
|
||||
float3 v0 = p1 - p0;
|
||||
float3 v2 = p2 - p0;
|
||||
|
||||
plane.n = normalize(cross(v0, v2));
|
||||
float3 n = normalize(cross(v0, v2));
|
||||
|
||||
plane.d = dot(plane.n, p0);
|
||||
float d = dot(n, p0);
|
||||
|
||||
plane.nd = float4(n, d);
|
||||
|
||||
return plane;
|
||||
}
|
||||
|
||||
@@ -2,10 +2,8 @@ import Common;
|
||||
|
||||
struct DispatchParams
|
||||
{
|
||||
uint3 numThreadGroups;
|
||||
uint pad0;
|
||||
uint3 numThreads;
|
||||
uint pad1;
|
||||
uint4 numThreadGroups;
|
||||
uint4 numThreads;
|
||||
RWStructuredBuffer<Frustum> frustums;
|
||||
};
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ struct PointLight : ILightEnv
|
||||
|
||||
bool insidePlane(Plane plane, float3 position)
|
||||
{
|
||||
return dot(plane.n, position) - plane.d < -colorRange.w;
|
||||
return dot(plane.getNormal(), position) - plane.getDistance() < -colorRange.w;
|
||||
}
|
||||
|
||||
bool insideFrustum(Frustum frustum, float3 position, float minDepth, float maxDepth)
|
||||
|
||||
Reference in New Issue
Block a user