0 Members and 2 Guests are viewing this topic.
First off, it is important to note that whenever the camera is within a voxel, the voxels that are rendered are sorted relative to the distance they are to that voxel. Consequently no matter what voxel the camera is in, the order of the rendered voxels is always the same relative to the center camera voxel. What this means is that you can presort a large number of voxel positions into an array based on how far they are from a center voxel, and simply use those positions relative to the camera to render.
This works, but it can take up a large amount of memory. If that is a problem, there is another solution that I discovered when working on my Castle Storm game, which uses a similar rendering method. The way it would work is by drawing the voxels (still relative to the camera position) in shells, and it is painfully difficult to explain, so if you are interested, I can whip up some sort of gif or example and we can talk from there
Now, this would speed up the sorting of cubes, but it would not actually speed up the drawing, which is probably another main bottleneck. First off, since you are only rendering cubes, you can always discard the faces that are facing away from you. This is a rendering trick you can use on convex objects, that any faces that are facing away from you cannot actually be seen. Additionally, you can use a simply dot product to detect whether or not a face is facing away from you, so it is super speedy and results in half of your faces being discarded!
Another method would be to look at the cubes surrounding a cube to be rendered. When you go to render a cube, you can look at neighboring cubes to see if they are solid, if not, you do not have to render the connecting face! This should result in significant speedups hopefully, since using these methods would drastically cut down on the number of polygons you need to render in any given frame.
Seems interesting. Could you give an exemple ? Because of my poor English skills, I'm not sure that I've got it very well...
Quote from: Chockosta on September 27, 2012, 02:32:42 pmSeems interesting. Could you give an exemple ? Because of my poor English skills, I'm not sure that I've got it very well...Mmm it's a bit hard to explain, but think of it this way. Every single frame you are sorting the blocks according to distance, and every single frame you arrive at the exact same order. Every single frame you always render the farthest blocks first, followed by closer blocks, and finally centering on the camera. Instead of re-sorting the blocks every frame, you could just generate a sorted list when the game starts, that way you never have to sort again.
Quote from: Builderboy on September 27, 2012, 02:55:24 pmQuote from: Chockosta on September 27, 2012, 02:32:42 pmSeems interesting. Could you give an exemple ? Because of my poor English skills, I'm not sure that I've got it very well...Mmm it's a bit hard to explain, but think of it this way. Every single frame you are sorting the blocks according to distance, and every single frame you arrive at the exact same order. Every single frame you always render the farthest blocks first, followed by closer blocks, and finally centering on the camera. Instead of re-sorting the blocks every frame, you could just generate a sorted list when the game starts, that way you never have to sort again.I can't really see how well that would work when you rotate the camera though.
Quote from: calc84maniac on September 27, 2012, 03:11:51 pmQuote from: Builderboy on September 27, 2012, 02:55:24 pmQuote from: Chockosta on September 27, 2012, 02:32:42 pmSeems interesting. Could you give an exemple ? Because of my poor English skills, I'm not sure that I've got it very well...Mmm it's a bit hard to explain, but think of it this way. Every single frame you are sorting the blocks according to distance, and every single frame you arrive at the exact same order. Every single frame you always render the farthest blocks first, followed by closer blocks, and finally centering on the camera. Instead of re-sorting the blocks every frame, you could just generate a sorted list when the game starts, that way you never have to sort again.I can't really see how well that would work when you rotate the camera though.Well I suppose you would have to be considering all blocks around you equally, and then throw them out if they are outside of the camera view. Since the sorting of blocks should be independent of camera angle anyway.