Resources for a Voxel-Based Game

I am currently working on a voxel based game, and I need some tips or links to resources on the following:

  • Raycasting/Raytracing and which one to use
  • Culling: Frustum and maybe occlusion
  • How to apply rotations to VBOs

Here are some of the questions I need help with:

RayCasting/Tracing:

Which is best for a voxel engine?
What is the difference?
Where do you use it and how? (Frustum culling?)

Culling:

How do you get the bounds of the frustum?
How do you work out whether a voxel is inside the frustum? (Raycasting?)
Are octrees helpful?

VBOs and rotation:

I am really stumped on this. It is for entities, which are also made up of voxels.
How do I apply a rotation to a point to put in a VBO?

If people could give me some links for these it would be great.
I don’t mind c++, even though I never learnt it it is still easy enough to understand. I just need the logic behind everything.

By the way, I use LWJGL.

Edit: Removed points that just require messing with the code and drawing complex diagrams etc

I’m afraid you’re basically asking everyone else to do all the hard work for you. Back to the drawing board for you I think.

Cas :slight_smile:

facepalm

That’s not what I meant. I have spent hours on Google looking for this stuff and I wanted to know if anyone knew of any resources.

Aha! The edited version is much better framed.

Frustum culling is trivial and Google gives you any number of excellent resources. As does a patronising search for occlusion culling.

wrt. VBOs and rotations: you do not apply rotations to VBOs. VBOs contain vertex data; you do the rotations in a vertex shader these days.

Cas :slight_smile:

… I think you need to be even more specific about which bit of each part you don’t understand.

Cas :slight_smile:

Wow!

I never would of guessed that google-ing two words would give more tutorials than google-ing those words plus “tutorial” or “resources”.

As I looked through them my brain clicked, but I realised the method I thought of would most likely be to slow, but anyway, someone tell me if this will work:

My world has already got some form of octree working. So what I do is take each of the seven visible points of the voxel/octree (if the octree is not empty) and test to see if each one is inside the frustum by adding/subtracting half the FOV fron the camera’s pitch/yaw depending on the axis. If all of them are, then it is inside. If some are, it’s intersecting. If none are, it’s outside.

If inside, test for occlusion.
If intersecting, which should I do?:

  • Test each voxel within the octree with the same method.
  • Render them all anyway
    If outside, don’t render.

I will test it tomorrow or later…

The nature of octree allows for rapid rejects/inclusions, ignore occlusions for the moment. One way to to start with near, top, bottom, right and left planes (and far if you want to do that) and traverse the root. The nature of planes allow you to (pretty much) test a single point per plane by pre-categorizing. Once a node is outside any, it and all it’s children are invisible so stop. Once a node is inside a plane your done checking with that one, so drop it. Once inside all then all children are inside. Occulsion is the tougher nut to crack.

Octrees are immensely helpful. I implemented one for hit-testing. Before I was iterating over 14000 objects and in total it took around 30 ms. Afterwards it took less than 1 ms.

You may not get as much of a performance gain but in essence you’re reducing a linear search down to a binary one.