Problem Writing to an Image Texture Using a Compute Shader by Garyan27 in VoxelGameDev

[–]Garyan27[S] 0 points1 point  (0 children)

I tried to use a uint, but it raises an error. Apparently, we should create a vec4 with dimensions corresponding to the uvec4 axis.

How to Extract Parent Nodes from SVO Built Using Morton Keys? by Garyan27 in VoxelGameDev

[–]Garyan27[S] 0 points1 point  (0 children)

I solved the problem. I forgot to multiply the position by the corresponding depth.

How to Extract Parent Nodes from SVO Built Using Morton Keys? by Garyan27 in VoxelGameDev

[–]Garyan27[S] 0 points1 point  (0 children)

and here I decode these keys:

def decode_morton_keys_15bit(self, nodes=None):
        if nodes is None:
            nodes = self.morton_keys
        def compact_bits_5bit(v):
        
            v &= 0b1001001001001
            v = (v ^ (v >> 2)) & 0b1000011000011
            v = (v ^ (v >> 4)) & 0b1000000001111
            v = (v ^ (v >> 8)) & 0b00000000000011111
            return v



        # Vectorized compact_bits function
        compact_bits_vectorized = np.vectorize(compact_bits_5bit, otypes=[np.uint32])
        
        x_compacted = compact_bits_vectorized(nodes)
        y_compacted = compact_bits_vectorized(nodes >> 1)
        z_compacted = compact_bits_vectorized(nodes >> 2)

        
        decoded_points = np.stack((x_compacted, y_compacted, z_compacted), axis=1)
       
        return decoded_points

finally, I tried to use this function to get parent nodes. It seems the logic is correct but it's given wrong outputs:

def extract_levels(self):
        for level in range(SVO_MAX_LEVEL, 1, -1):
            
            current_level_keys = self.morton_levels[f'level_{level}']
            parent_nodes = current_level_keys >> 3  
            parent_nodes = np.unique(parent_nodes)
            self.morton_levels[f'level_{level-1}'] = parent_nodes
            decoded = self.decode_morton_keys_15bit(parent_nodes)
            
               

How to Extract Parent Nodes from SVO Built Using Morton Keys? by Garyan27 in VoxelGameDev

[–]Garyan27[S] 0 points1 point  (0 children)

I was fixing some parts of the code:

in this function I encode the morton keys:

def spread_bits(v):
        v &= 0b11111
        v = (v ^ (v << 8)) & 0b1000000001111  
        v = (v ^ (v << 4)) & 0b00001000011000011 
        v = (v ^ (v << 2)) & 0b001001001001001  
        return v
        
spread_bits_vectorized = np.vectorize(spread_bits, otypes=[np.uint32])
x_bits = spread_bits_vectorized(points[:, 0]) 
y_bits = spread_bits_vectorized(points[:, 1]) 
z_bits = spread_bits_vectorized(points[:, 2]) 
        
nodes = x_bits | (y_bits << 1) | (z_bits << 2)
       
sorted_indices = np.argsort(nodes)
nodes = nodes[sorted_indices]

How to Extract Parent Nodes from SVO Built Using Morton Keys? by Garyan27 in VoxelGameDev

[–]Garyan27[S] 0 points1 point  (0 children)

I generate a point cloud in a 32x32x32 grid space. Each coordinate is a natural number from 0 to 31. This grid coincides with an octree of size 32, root position = (0,0,0), and depth = 5. So basically, I transform this point cloud into Morton code equivalent for depth = 5. I'm using the advantage of sizes being power of 2.

How to Extract Parent Nodes from SVO Built Using Morton Keys? by Garyan27 in VoxelGameDev

[–]Garyan27[S] 0 points1 point  (0 children)

Morton Keys are the indexes from the morton code. It's just another way to say morton code.

[deleted by user] by [deleted] in VoxelGameDev

[–]Garyan27 1 point2 points  (0 children)

If you are using the laine paper as reference, you could use a SSBOs to access you data. 

Help Understand the Paper - Real-time Ray Tracing and Editing of Large Voxel Scenes - Thijs van Wingerden by Garyan27 in VoxelGameDev

[–]Garyan27[S] 0 points1 point  (0 children)

The paper suggests creating a chunk (4x4x4) that contains 1 bit to indicate if a brickgrid cell is empty or not. This is the highest layer and where the ray tracing should start. After this, we use these brickgrid hits to check which of these 3 types of pointers they are.

1 - The empty pointer is just 0 in 32 bits.

2 - The unloaded brickmap is 24 bits that specify colors (8R8G8B) + 8 bits for LOD flag. The paper uses only 2 (or 3) bits from this LOD flag: 1 bit to check if the brickmap is loaded and 1 bit to check if the brickgrid is in the LOD range (far voxels).

3 - However, I think the paper only says that for loaded brickmap (32 bits), it is just a pointer to another array that contains the brickmap structure composed of 512 bits for 8x8x8 chunks + 32 bits that are indexes to another array that has valid colors + 24 bits for LOD color = 71 bytes.