Jump to content

  • Log In with Google      Sign In   
  • Create Account


Helixirr

Member Since 27 Jan 2013
Offline Last Active May 07 2013 02:46 AM
-----

Posts I've Made

In Topic: How could one implement voxel-based level editor for a game?

10 April 2013 - 08:43 AM

One question is still unanswered: is it good idea to convert voxel-based terrain to 3D model (all terrain details and smoothings applied), so that in-game, instead of dealing with voxels and then geometry, there could be only geometry (quads, triangles) to render?

I think this is necessary if you want to get sufficient performance, but I don't know your requirements. Notice that using a block with half the width will increase the density of blocks with a factor of 8. There are some steps of varying complexity (from easy to hard):

  • Sort surfaces on type.
  • Remove hidden surfaces (sides of adjacent cubes).
  • Merge adjacent surfaces (triangles) into bigger triangles.
  • Detect what chunks are outside of the view frustum, and ignore them for drawing.
  • Detect what chunks are hidden behind other chunks. Sounds easy, but not trivial.
  • Implement LOD (Level Of Detail). This is complex for voxel based drawing, especially in the transition from one resolution to another that can lead to artefacts.
  • Use impostors for far distant chunks.

For smoothing, there are a couple of possible technologies. The marching cubes is frequently mentioned, but I think it is difficult if you are going to support more than one type of block. Another solution is to use a kind of a filter that transforms the corners of the cubes. You can see an example of it in my implementation. It will get you smooth terrain, but still with sharp boundaries between block types. There is also the concept of "Elastic surface nets". I haven't looked much at it, it may be similar to what I am using.

 

For the world editor, I switch between a smooth world display and a blocky display when I enter edit mode.

 

Wow, this is more like it! Thanks a lot, Lars, I'll take a look at this! smile.png


In Topic: How could one implement voxel-based level editor for a game?

10 April 2013 - 12:49 AM

It can be difficult to draw a world built from voxels efficiently. It is obviously not impossible, it has been done elsewhere. But you have to be prepared to spend quite a lot of effort on optimization, especially if the voxels are small. In my world, the voxels are cubes 0.5m wide, and you need a good graphic card to enable a view distance of 180 blocks.

 

A common solution is to organize the voxels into chunks. These chunks then need to be transformed into something that can be drawn. Save the transformation, as you will need it every frame.

 

When you have the drawing up and running, there are a couple of ways to make a level editor. Every time a block is updated in a chunk, the corresponding draw representation has to be updated. This may be a costly process, I use all available threads from the CPU I can have for it.

 

The editor can be simple:

  1. Select a block from a list of available types
  2. Click on the screen
  3. Detect what face of a block and chunk that was selected (color picking or ray tracing)
  4. Compute the position and chunk of the new block (could be the adjacent chunk)
  5. Add the block to the chunk

A more advanced editor would allow you to select one or more faces, and then extrude from them (see Blender how this is done). That will allow you to more quickly create large scale objects. It might also be a good idea to seed your world with something, maybe a height map. For this, I recommend using 2D and 3D simplex functions for randomness.

 

Nice suggestions, larpensjo! happy.png Optimization seems to be the keyword here.

 

The editor can be simple:

Select a block from a list of available types
Click on the screen
Detect what face of a block and chunk that was selected (color picking or ray tracing)
Compute the position and chunk of the new block (could be the adjacent chunk)
Add the block to the chunk

 

This approach is basic, but that's where I have to start from. Terrain smoothing adding details requires more knowledge of voxel-based terrains. wink.png

 

A more advanced editor would allow you to select one or more faces, and then extrude from them (see Blender how this is done). That will allow you to more quickly create large scale objects. It might also be a good idea to seed your world with something, maybe a height map. For this, I recommend using 2D and 3D simplex functions for randomness.

 

I don't think these are that necessary to me, especially 2D and 3D simplex functions, since I don't need procedurally generated terrains. All I want is voxel-based, simple to use voxel-based terrain editor. On the other hand, I might actually be very useful, since it adds surprises to a game. One thing where I might use procedural terrain generation is to add varying backgrounds, landscapes to my in-game levels. smile.png The gameplay areas of levels stay the same, but backgrounds change to create refreshing atmosphere and variety. It would be kinda cool. laugh.png

 

One question is still unanswered: is it good idea to convert voxel-based terrain to 3D model (all terrain details and smoothings applied), so that in-game, instead of dealing with voxels and then geometry, there could be only geometry (quads, triangles) to render? huh.png


In Topic: Game programming - Using vectors called forward, left/right and up

14 February 2013 - 08:49 AM

In fact, forward, right and up vector is so basic for defining an orientation, that you can put them directly into the columns of a matrix, and you have a rotation matrix that transforms your points into the orientation.

 

Oh, interesting. Thank you for pointing that out. smile.png

 

No wonder they used these vectors in Ratchet and Clank 3, then. wink.png


In Topic: Game programming - Using vectors called forward, left/right and up

13 February 2013 - 01:59 PM

This is the kind of reply I was looking for!   Thank you, Polaris!

 

You're welcome.  I edited the original post to add more detail.  (I may have veered a bit off track though. laugh.png )

 

Feel free to add more or PM me if you have any further questions.

 

Thanks for the PM offer, but I prefer discussing subjects on the forums, so that everyone can see them. Helpful resources should belong to everyone. smile.png


In Topic: Why is collision cast expensive?

13 February 2013 - 01:56 PM

Just a little note - the game above was originally released on PS2 (on which the developers probably play the game), but eventually got it's release on PS3 in HD as well.


PARTNERS