The Architect (Voxel Engine)

This is a toy project. Guardian II is still my main game.

http://dl.dropbox.com/u/99583484/3D/Voxel%201.png

http://dl.dropbox.com/u/99583484/3D/Voxel%202.png

http://dl.dropbox.com/u/99583484/3D/Voxel%203.png

http://dl.dropbox.com/u/99583484/3D/Voxel%204.png

Infinite World or fixed size
Simplex Noise Generation with randomized octaves.
Lighting.
Fog.
Basic Movement (For test purposes. Real movement soon).

If any of the other people currently making voxel engines (or anyone else) want some help with something, feel free to ask.

Can I ask you how, or where, you learned perlin noise?

Fixed-function or programmable pipeline? :stuck_out_tongue:

this is a pretty good explanation of perlin noise, but heroesgravedev said he used simplex noise :stuck_out_tongue:

http://freespace.virgin.net/hugo.elias/models/m_perlin.htm

Oh woops :stuck_out_tongue: Thank you though!

Programmable. (Although my shaders use the gl_XMatrix uniforms.)

Simplex Noise Article: http://www.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf

That’s looks very nice! Thanks for putting that on, it’s inspiring. :slight_smile:

I put the FOV up to 90 to get more epic screenshots.

http://dl.dropbox.com/u/99583484/3D/Architect/1.png

http://dl.dropbox.com/u/99583484/3D/Architect/2.png

http://dl.dropbox.com/u/99583484/3D/Architect/3.png

That is epic, very hilly and some nice formations.

With random octaves, you sometimes get nice flat formations too:

http://dl.dropbox.com/u/99583484/3D/Architect/5.png

http://dl.dropbox.com/u/99583484/3D/Architect/6.png

http://dl.dropbox.com/u/99583484/3D/Architect/7.png

(Okay, that last one is a hill, but it’s a gentle slope)

Be nice to have the best of both in one world. I’m thinking of using a diamond star algorithm, do you have any advice/thoughts on that?

Also, I take it simplex produces a 2d height map? Are there any 3d implementations?

It’s looking great tho. Your obviously drawing lots of faces. Do you know how many?

Depends what I set the view distance to.

It works fine for me on 9x9x9 chunks. In fact, lag is caused by chunk loading. I should fix this.
Which equals 144^3 potential cubes. Probably (144^3)/2 cubes.
Most cubes are invisible.
On an almost flat world, there will be 1 cube per x,z coordinate. The cube would have around two faces visible on average.

(144^2)x2 = 41472 faces on an almost flat world.

As for simplex noise generation, I’m still looking for a way to have sections of flat and mountains.
You could try multiplying two (or more) octaves (between 1 and -1) and multiplying that by the height.

2 optimisations:

  • Uses multithreading for chunk loading.
  • Blocks are organised in chunks by an array instead of a HashMap of Vectors.

Result:

9^3 chunks (of 16^3) rendered:
Uncapped Framerate: ~110fps when loading new chunks, ~160fps when staying in one chunk.
RAM usage dropped massively due to less Vectors.

More screenshots on my blog.

You could probably just use a Vector pool, no?

A while ago I made almost all of the vectors immutable and only left mutable ones for things like player position etc
If I ever hit problems again I could refactor though.

Thanks for the suggestion, I never thought of that.

Looking good with the extra definition provided by the grass/soil texture.

I think I’m going to need some mulithreading for loading! That’s next on the list…

What you planning next?

Block breaking/building/interacting

I’m currently trying to get it to pick the right block, then I’ll move onto getting the right face.

Can you please tell me how you did the frustum culling?
I am trying to do it for last 4 hours, but i can’t make it work how it should.

Here is how i did the frustum faces loading:


public void update() {
        FloatBuffer projectionBuffer = BufferUtils.createFloatBuffer(16);
        glGetFloat(GL_PROJECTION_MATRIX, projectionBuffer);
        FloatBuffer modelBuffer = BufferUtils.createFloatBuffer(16);
        glGetFloat(GL_MODELVIEW_MATRIX, modelBuffer);

        Matrix4f projectionMatrix = new Matrix4f();
        projectionMatrix.load(projectionBuffer);
        Matrix4f modelMatrix = new Matrix4f();
        modelMatrix.load(modelBuffer);
        
        Matrix4f viewMatrix = new Matrix4f();
        Matrix4f.mul(projectionMatrix, modelMatrix, viewMatrix);

        planes[0] = new Plane(viewMatrix.m30 + viewMatrix.m00, viewMatrix.m31 + viewMatrix.m01, viewMatrix.m32 + viewMatrix.m02, viewMatrix.m33 + viewMatrix.m03);
        planes[1] = new Plane(viewMatrix.m30 - viewMatrix.m00, viewMatrix.m31 - viewMatrix.m01, viewMatrix.m32 - viewMatrix.m02, viewMatrix.m33 - viewMatrix.m03);
        planes[2] = new Plane(viewMatrix.m30 + viewMatrix.m10, viewMatrix.m31 + viewMatrix.m11, viewMatrix.m32 + viewMatrix.m12, viewMatrix.m33 + viewMatrix.m13);
        planes[3] = new Plane(viewMatrix.m30 - viewMatrix.m10, viewMatrix.m31 - viewMatrix.m11, viewMatrix.m32 - viewMatrix.m12, viewMatrix.m33 - viewMatrix.m13);
        planes[4] = new Plane(viewMatrix.m30 + viewMatrix.m20, viewMatrix.m31 + viewMatrix.m21, viewMatrix.m32 + viewMatrix.m22, viewMatrix.m33 + viewMatrix.m23);
        planes[5] = new Plane(viewMatrix.m30 - viewMatrix.m20, viewMatrix.m31 - viewMatrix.m21, viewMatrix.m32 - viewMatrix.m22, viewMatrix.m33 - viewMatrix.m23);
    }

I didn’t do frustum culling. :-\