Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I want to smooth the blocky terrain in a Minecraft-like world. The smoothing affects visual appearance and physics but not the logic of placing and picking blocks. I have my mathematical formula to smooth the cubes in a way the voxel grid stays recognizable. But I have no clue how to implement such an effect.

Moreover I do not know how to store and render the effect at all. My smoothing algorithm provides a height for each pixel of a block based on the surrounding blocks. This would result in million of triangles so I might need another approach.

Therefore I thought about calculating the smooth surface dynamically in a shader on the GPU. I never used the geometry shader or the tessellation shader before, but doing so sounds reasonable to me. But with this approach things become difficult when I want to apply correct physics to the smooth terrain surface since the triangles would only be stored on the GPU.

How can I effectively generate a detailed smoothed mesh and access the result for the physics simulation? Is there a technique to implement my idea without the creating of loads of additional triangles?

share|improve this question
    
"But I have no clue how to implement such an effect." It's going to be hard for someone to suggest how to implement it... if you won't tell us what it is. There are many possible "smoothing" algorithms, and how to implement them depends entirely on what the algorithm is. –  Nicol Bolas Mar 4 '13 at 12:45
    
Oh, and if your "smoothing function" is more complicated than a table lookup based on the presence or absence of adjacent blocks, you're doing it wrong. –  Nicol Bolas Mar 4 '13 at 12:47
    
@NicolBolas. The smoothing algorithm is a mathematical formula. Given the presence of all adjacent blocks, it calculates the height z for any point x, y inside the block. These coordinates x, y, z are relative to the current block. This calculation is performed for each relative x, y step with given precision and block. every time the world changes. So why do you claim that I am doing anything wrong? I am not doing anything at all yet. I asking for a technique to apply that effect. Something like displacement maps would be great but they wouldn't let physics engine use the results, I guess. –  danijar Mar 4 '13 at 13:16

2 Answers 2

up vote 1 down vote accepted

I think a good place to start would be to make things as simple as possible because you stated you don't really know how to implement your algorithm which would make too many triangles anyway. I would like to quickly note that if you smoothed the terrain in the shader it would make huge problems with collision detection and physics since the gpu would be the only thing with access to the smoothed terrain.

The way I propose smoothing the terrain is by using rules to run through when creating the mesh for a block. This is how Castle Story does it and they have a very good blog post on it. Although it focuses on 2d tiles with different textures the bottommost picture translates it to 3d. The simplest way to make "smooth" terrain would be to connect the faces with a diagonal line.

Although I have not actually implemented this (but I will be soon) here is a good forum thread which has pictures of this implemented in games.

This method is a very simple version but it can be expanded using different rules for different sets of blocks... The good part of this method is that it makes the world look decent while still keeping the voxel feel and saving tons of time that would have been invested in a more complex algorithm.

share|improve this answer
    
Alright, I will generate smooth meshes on the CPU whenever a chunk of blocks needs to be updated. Moreover, the linked discussion and the blog post are very helpful. Even though their outcome, to be honest, isn't visually attractive their approach is interesting. I will implement by own smoothing algorithm using bezier curves and hope to show you the results in some months. –  danijar Apr 11 '13 at 9:13

I think you are looking for this: Marching cubes

Its an algorithm that forms a (relatively) smooth surface from a voxel field. For implementation I recommend searching with Google as there are lots of articles about it.

share|improve this answer
2  
Suggesting to do a Google search is neither helpful nor constructive. –  Bobby Apr 9 '13 at 13:07
    
I am looking for a particular technique to smooth the voxels. Instead I am asking about where to perform the computation, and how to effectively store the result. –  danijar Apr 9 '13 at 13:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.