ksundberg / CS5500

Course project for CS5500 at Utah State University
GNU General Public License v2.0
2 stars 11 forks source link

Optimize Voxel Rendering #45

Closed tefu closed 9 years ago

tefu commented 9 years ago

Currently, the voxel engine renders the sides of chunks even when two chunks are next to each other. To illustrate this, suppose we have a layer of square voxels being rendered in the world, render3

It’s a lot of graphics overhead to render all those inner voxels, so we should probably ignore them. Currently, the world does ignore rendering voxel sides that are next to each other, provided they’re in the same chunk. render2

However, if two voxels are next to each other but in separate chunks, the voxels’ sides still get rendered. render

This should be optimized so it ignores those inter-chunk textures. This problem can be seen if you navigate the camera inside the world right now. 2015-03-28-04_39_23

Parallel Analysis

When updating a chunk’s vertex buffer for rendering, each chunk needs to examine all neighboring chunks around it. render4

If we were to update a large grid of chunks, this would be open to a parallel stencil pattern for optimization. If we’re updating n chunks, the work has O(n) complexity. The span would be the time required to update one chunk, which has O(1) complexity. Thus, the maximum speedup we can expect in this task from adding more cores is, render6

Meaning this algorithm will scale.

waredavid commented 9 years ago

Code to do this on a chunk and on a voxel level is implemented in our chunk mager which we are still working on integrating into the project.

On Sat, Mar 28, 2015 at 1:19 PM, tehul notifications@github.com wrote:

Currently, the voxel engine renders the sides of chunks even when two chunks are next to each other. To illustrate this, suppose we have a layer of square voxels being rendered in the world, [image: render3] https://cloud.githubusercontent.com/assets/10508654/6882500/70c46454-d54c-11e4-8ca4-89e383460c04.png

It’s a lot of graphics overhead to render all those inner voxels, so we should probably ignore them. Currently, the world does ignore rendering voxel sides that are next to each other, provided they’re in the same chunk. [image: render2] https://cloud.githubusercontent.com/assets/10508654/6882499/6cfd9d9a-d54c-11e4-9225-870531f4b09c.png

However, if two voxels are next to each other but in separate chunks, the voxels’ sides still get rendered. [image: render] https://cloud.githubusercontent.com/assets/10508654/6882496/65b88d56-d54c-11e4-89a6-6d860bb50a00.png

This should be optimized so it ignores those inter-chunk textures. This problem can be seen if you navigate the camera inside the world right now. [image: 2015-03-28-04_39_23] https://cloud.githubusercontent.com/assets/10508654/6882510/cadcc7ec-d54c-11e4-83fa-ba1438ca8c76.png Parallel Analysis

When updating a chunk’s vertex buffer for rendering, each chunk needs to examine all neighboring chunks around it. [image: render4] https://cloud.githubusercontent.com/assets/10508654/6882501/72a2786a-d54c-11e4-9a2a-b59467cf7784.png

If we were to update a large grid of chunks, this would be open to a parallel stencil pattern for optimization. If we’re updating n chunks, the work has O(n) complexity. The span would be the time required to update one chunk, which has O(1) complexity. Thus, the maximum speedup we can expect in this task from adding more cores is, [image: render6] https://cloud.githubusercontent.com/assets/10508654/6882503/7623e0f0-d54c-11e4-8e3a-182b2e13f3cf.png

Meaning this algorithm will scale.

— Reply to this email directly or view it on GitHub https://github.com/ksundberg/CS5500/issues/45.

tefu commented 9 years ago

I was mostly talking about improving the conditionals here so they can check voxels in neighboring chunks. I'm not sure I see this in your branch (this maybe?) so I'm still gonna consider this as non-implemented.

You can cover this if you want, but I highly recommend getting a pull request to fix the graphics issues and crashes you're seeing first. Development without feedback isn't exactly easy.