Working better
This commit is contained in:
@@ -50,14 +50,25 @@ void setupScreenspace(in UnpackedNode node) {
|
||||
vec4 pPoint = (VP*vec4(vec3((i&1)!=0,(i&2)!=0,(i&4)!=0)*32,1));//Size of section is 32x32x32 (need to change it to a bounding box in the future)
|
||||
pPoint += base;
|
||||
vec3 point = pPoint.xyz/pPoint.w;
|
||||
//TODO: CLIP TO VIEWPORT
|
||||
minBB = min(minBB, point);
|
||||
maxBB = max(maxBB, point);
|
||||
}
|
||||
//printf("Screenspace MIN: %f, %f, %f MAX: %f, %f, %f", minBB.x,minBB.y,minBB.z, maxBB.x,maxBB.y,maxBB.z);
|
||||
|
||||
size = maxBB.xy - minBB.xy;
|
||||
|
||||
}
|
||||
|
||||
//Checks if the node is implicitly culled (outside frustum)
|
||||
bool outsideFrustum() {
|
||||
return any(lessThanEqual(maxBB, vec3(-1f, -1f, 0f))) || any(lessThanEqual(vec3(1f, 1f, 1f), minBB));
|
||||
}
|
||||
|
||||
bool isCulledByHiz() {
|
||||
if (minBB.z < 0) {//Minpoint is behind the camera, its always going to pass
|
||||
return false;
|
||||
}
|
||||
vec2 ssize = size.xy * vec2(ivec2(screenW, screenH));
|
||||
float miplevel = ceil(log2(max(max(ssize.x, ssize.y),1)));
|
||||
vec2 midpoint = (maxBB.xy + minBB.xy)*0.5;
|
||||
@@ -66,5 +77,6 @@ bool isCulledByHiz() {
|
||||
|
||||
//Returns if we should decend into its children or not
|
||||
bool shouldDecend() {
|
||||
return (size.x*size.y) > (64*64F);
|
||||
//printf("Screen area %f: %f, %f", (size.x*size.y*float(screenW)*float(screenH)), float(screenW), float(screenH));
|
||||
return (size.x*size.y*screenW*screenH) > (64*64F);
|
||||
}
|
||||
@@ -77,8 +77,8 @@ layout(binding = 2, std430) restrict buffer QueueData {
|
||||
|
||||
|
||||
void addRequest(inout UnpackedNode node) {
|
||||
printf("requested");
|
||||
if (!hasRequested(node)) {
|
||||
printf("requested");
|
||||
//TODO: maybe try using only 1 variable and it being <0 being bad
|
||||
if (requestQueueIndex < requestQueueMaxSize) {
|
||||
//Mark node as having a request submitted to prevent duplicate submissions
|
||||
@@ -113,7 +113,7 @@ void main() {
|
||||
|
||||
//debugDumpNode(node);
|
||||
|
||||
if (isCulledByHiz()) {
|
||||
if (outsideFrustum() || isCulledByHiz()) {
|
||||
//printf("HizCulled");
|
||||
//We are done here, dont do any more, the issue is the shader barriers maybe
|
||||
// its culled, maybe just mark it as culled?
|
||||
|
||||
Reference in New Issue
Block a user