Stuff kinda works
This commit is contained in:
@@ -17,13 +17,19 @@ layout(binding = VISIBILITY_BUFFER_BINDING, std430) restrict buffer VisibilityBu
|
||||
uint[] visibility;
|
||||
};
|
||||
|
||||
layout(location=0) uniform uint visibilityCounter;
|
||||
void main() {
|
||||
uvec4 node = nodes[minVisIds[gl_LocalInvocationID.x]];
|
||||
uint id = minVisIds[gl_LocalInvocationID.x];
|
||||
uvec4 node = nodes[id];
|
||||
uvec2 res = node.xy;
|
||||
if (all(equal(node, uvec4(0)))) {//If its a empty node, TODO: DONT THINK THIS IS ACTUALLY CORRECT
|
||||
res = uvec2(-1);
|
||||
}
|
||||
outputBuffer[gl_LocalInvocationID.x] = res;//Move the position of the node id into the output buffer
|
||||
|
||||
//outputBuffer[gl_LocalInvocationID.x].x = visibility[minVisIds[gl_LocalInvocationID.x]];//
|
||||
//This is an evil hack to not spam the same node 500 times in a row
|
||||
//TODO: maybe instead set this to the current frame index
|
||||
// visibility[id] += 30;
|
||||
visibility[id] = visibilityCounter;
|
||||
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
//#define OUTPUT_SIZE 128
|
||||
|
||||
layout(local_size_x=128, local_size_y=1) in;
|
||||
layout(local_size_x=WORK_SIZE, local_size_y=1) in;
|
||||
//256 workgroup
|
||||
|
||||
#import <voxy:lod/hierarchical/node.glsl>
|
||||
@@ -54,9 +54,36 @@ void main() {
|
||||
return;
|
||||
}
|
||||
UnpackedNode node;
|
||||
unpackNode(node, gl_GlobalInvocationID.x);
|
||||
if (unpackNode(node, gl_GlobalInvocationID.x)==uvec4(-1)) {
|
||||
return;//Unallocated node
|
||||
}
|
||||
|
||||
if (isEmptyMesh(node) || (!hasMesh(node))) {//|| (!hasChildren(node))
|
||||
return;
|
||||
}
|
||||
//TODO: FIXME: DONT HARDCODE TOP LEVEL LOD LEVEL
|
||||
if (node.lodLevel == 4) {// (!hasChildren(node)) -> Assume leaf node
|
||||
return;//Cannot remove geometry from top level node
|
||||
}
|
||||
|
||||
/*THIS IS COMPLETLY WRONG, we need to check if all the children of the parent of the child are leaf nodes
|
||||
// not this node
|
||||
|
||||
//Very sneeky hack, ensure all children are leaf nodes
|
||||
if (hasChildren(node)&&!childListIsEmpty(node)) {
|
||||
uint ptr = getChildPtr(node);
|
||||
uint cnt = getChildCount(node);
|
||||
for (uint i = 0; i < cnt; i++) {
|
||||
UnpackedNode child;
|
||||
unpackNode(child, i+ptr);
|
||||
if (hasChildren(child)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
bubbleSort(0, gl_GlobalInvocationID.x);
|
||||
}
|
||||
@@ -8,9 +8,6 @@ layout(binding = NODE_DATA_BINDING, std430) restrict buffer NodeData {
|
||||
|
||||
//First 2 are joined to be the position
|
||||
|
||||
|
||||
|
||||
|
||||
//All node access and setup into global variables
|
||||
//TODO: maybe make it global vars
|
||||
struct UnpackedNode {
|
||||
@@ -32,7 +29,7 @@ struct UnpackedNode {
|
||||
#define NULL_MESH ((1<<24)-1)
|
||||
#define EMPTY_MESH ((1<<24)-2)
|
||||
|
||||
void unpackNode(out UnpackedNode node, uint nodeId) {
|
||||
uvec4 unpackNode(out UnpackedNode node, uint nodeId) {
|
||||
uvec4 compactedNode = nodes[nodeId];
|
||||
node.nodeId = nodeId;
|
||||
node.lodLevel = compactedNode.x >> 28;
|
||||
@@ -50,6 +47,7 @@ void unpackNode(out UnpackedNode node, uint nodeId) {
|
||||
node.meshPtr = compactedNode.z&0xFFFFFFu;
|
||||
node.childPtr = compactedNode.w&0xFFFFFFu;
|
||||
node.flags = ((compactedNode.z>>24)&0xFFu) | (((compactedNode.w>>24)&0xFFu)<<8);
|
||||
return compactedNode;
|
||||
}
|
||||
|
||||
bool hasMesh(in UnpackedNode node) {
|
||||
|
||||
Reference in New Issue
Block a user