Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize Voxel Rendering #45

Closed
tefu opened this issue Mar 28, 2015 · 2 comments · Fixed by #56
Closed

Optimize Voxel Rendering #45

tefu opened this issue Mar 28, 2015 · 2 comments · Fixed by #56

Comments

@tefu
Copy link
Contributor

tefu commented Mar 28, 2015

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
Copy link
Contributor

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
#45.

@tefu
Copy link
Contributor Author

tefu commented Mar 29, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants