Jump to content

  • Log In with Google      Sign In   
  • Create Account


XNA 4.0 voxel map rendering, using noise techniques


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
46 replies to this topic

#21 japro   Members   -  Reputation: 887

Like
0Likes
Like

Posted 01 February 2012 - 06:39 AM

One nice way is to "blend" two different functions with a third one:
blend_factor = smoothclamp(10*noise2d(x,z),0,1)
result = terrain1(x,y,z)*blend_factor + terrain2(x,y,z)*(1-blend_factor)

Edit: shameless plug: also check out my twitter photos.

Sponsor:

#22 winsrp   Members   -  Reputation: 273

Like
0Likes
Like

Posted 01 February 2012 - 08:50 AM

hmm... but to draw the mesh you will need to go through each cube, I'm kind of doing that, if you look at the screen I'm only drawing the faces that have air in front of them, and the result looks like a mesh, all the other cubes that are not visible by the player have all their faces hidden.

I'm using vertexes with indexes, is there a better way to draw this mesh?

#23 winsrp   Members   -  Reputation: 273

Like
0Likes
Like

Posted 01 February 2012 - 08:52 AM

wow japro, great landscapes!!!, how do you manage to have such large view distance? and how do you color your terrain? and how do you make the soft shadows..!!!.. so many questions..

#24 japro   Members   -  Reputation: 887

Like
0Likes
Like

Posted 01 February 2012 - 09:07 AM

I don't actually store cubes I only get the faces from the noise function and put those into 32x32x32 chunks. Each chunk has its own vbo (i'm using OpenGL not sure what the equivalent in XNA is). The way I can get so many to display is by not actually building a "conventional" vbo with vertex data. Instead there are two 4byte ints for each quad that contain all the info (color, occlusion, offset inside chunk...). The quads are then generated in a geometry shader.
The large scale ambient occlusion is done at mesh creation by shooting rays from the blocks and intersecting them with the terrain. The darkening of concave edges is done by putting gradients on the quads depending on their immediate surroundings.
The coloring in the acid trip picture is pretty much color = (noise3(x,y,z),noise3(x,y,z),noise3(x,y,z))... so nothing special there ;).

#25 winsrp   Members   -  Reputation: 273

Like
0Likes
Like

Posted 01 February 2012 - 09:24 AM

ok, now i need to wiki almost half of the words you just put... lol... thanks for the info.

#26 winsrp   Members   -  Reputation: 273

Like
0Likes
Like

Posted 01 February 2012 - 11:46 AM

hmmm my noise function seems too slow, I might need to make a new one.

#27 winsrp   Members   -  Reputation: 273

Like
0Likes
Like

Posted 01 February 2012 - 03:17 PM

ok all good, but I have another question, I want to make the overhangs, but not have floating islands... , something that looks like this

lots of overhangs, but no floating islands, I can use a rigged multifractal to get the overhangs, but how do I remove the floating islands it produces?

Posted Image

#28 swiftcoder   Senior Moderators   -  Reputation: 9603

Like
0Likes
Like

Posted 01 February 2012 - 03:21 PM

if that image was produce procedurally (which I wouldn't bet on, not knowing the source), then it it by combining of dozens (maybe as many as a hundred) of different noise functions.

Look at the tree placements, the vertical cliffs, the flat planes - you will never find all those features in a single noise function.

Tristam MacDonald - Software Engineer @Amazon - [swiftcoding]


#29 winsrp   Members   -  Reputation: 273

Like
0Likes
Like

Posted 01 February 2012 - 05:04 PM

allow me to put a video then...
http://www.youtube.c...d&v=WRjfful_L-4
http://www.youtube.c...d&v=Kefd1mH1dRs

and the source http://wollay.blogspot.com/

and yes trees are procedural too.

#30 swiftcoder   Senior Moderators   -  Reputation: 9603

Like
0Likes
Like

Posted 01 February 2012 - 05:11 PM

if you look back through the archives, you'll see that each environment in the game is very different. Although it is all procedurally generated, each environment has a different set of generator functions, which are probably blended together based on a number of other, global functions. Not to mention that the algorithms for lakes, rivers, castles, trees, etc. are all layered on top of the basic procedural landscape functions...

Tristam MacDonald - Software Engineer @Amazon - [swiftcoding]


#31 winsrp   Members   -  Reputation: 273

Like
0Likes
Like

Posted 01 February 2012 - 05:27 PM

very true, but I cant seems to find how this guy can have those huge view distances, not to mentions heights and depths, with destruction. You would need to save millions of cubes in memory, not to mention a file, or something. And 3D noise functions seems way too slow to use them in combination, so those should all be 2d noise functions somehow.

#32 japro   Members   -  Reputation: 887

Like
0Likes
Like

Posted 01 February 2012 - 05:32 PM

You don't actually have to save all the cubes. Most of the information is given implicitly by the procedural generation. Now to handle the destruction you only have to store the deltas to the generated world. basically you have a sparse datastructure (octree, hashmap or similar) and only store changes in there (so destroyed and built blocks). Usually the player won't build or destroy millions of blocks. The changes he makes to the world are very sparse. So you can actually get away with storing the parameters of the generator function + the changes.

#33 winsrp   Members   -  Reputation: 273

Like
0Likes
Like

Posted 01 February 2012 - 05:47 PM

interesting... I'll try generating some land without saving box information and see what do I get from there.

but that would mean that I cannot check if the object below is land or air, without calling the function again and check for the previews block value... So I'll have to display all the blocks faces again...

Any ideas on how can I accomplish that?

#34 japro   Members   -  Reputation: 887

Like
0Likes
Like

Posted 01 February 2012 - 05:52 PM

Well you might want to keep some of the information explicitly around. For example if you partition the world in chunks like i said earlier. you can keep and explicit representation of the chunks surrounding the player in memory to do fast collision checking an mesh recomputation in case something gets changed. If he walks away you kick some of the old chunks out of memory and load new ones etc.

#35 winsrp   Members   -  Reputation: 273

Like
0Likes
Like

Posted 01 February 2012 - 07:39 PM

I saw that the bounding box object consumes lots of memory, almost as much as my hole box definition and the creation of a bounding box on the fly also consumes quite some cpu power, but of course is a lot less than the whole array of boxes, so I'll try to keep my chunks with their corresponding bounding boxes in order to maintain the frustum culling, and try to keep list of changes in each chunk, so I can reapply those, if the chunk gets out of memory, then I might as well save those changes to a file latter on.

I'll try to maximize memory allocation as that seems the key to large areas, and by the way japro, how do you make it so that the quads gets generated by the geometry shader? Do you have any sample code?

#36 way2lazy2care   Members   -  Reputation: 782

Like
0Likes
Like

Posted 02 February 2012 - 09:48 AM

If all your cubes are the same size, you shouldn't need a bounding box for each cube. You can either hard code the box values, or just create/alter a box when you are actually doing your narrow phase collision.

#37 winsrp   Members   -  Reputation: 273

Like
0Likes
Like

Posted 02 February 2012 - 11:55 AM

So started from scratch for the third time, but I wan't to make the generation as good as possible before I start with something else.

I'm going to try making hardware instancing of the cubes (too many fancy words for a noob I know, I just passed the last half hour reading about it and seem awesome) to see how what comes out, I've already made my cube in blender (actually just opened blender and a cube came out, how great is that!!) and exported it to fbx.

I have also made a plane of quads to show up without saving a thing, also created a new 2d perlin function, and running the perlin against the generation now takes 0.9 seconds to generate a 256 *256 array... not bad.

I also found some holes in the memory where returning arrays in functions will leave some data left in memory. Fixing all that.

#38 winsrp   Members   -  Reputation: 273

Like
0Likes
Like

Posted 03 February 2012 - 08:06 AM

question, If I have a 16x16 block and I use perlin noise 3d to retrive only 8 values, how would I go to use trilinear interpolation to get the other blocks?

Or how can I interpret the 3d noise values to produce a form from 3d space, what would the -1 to 1? values have to mean to know how to interpolate them?

#39 winsrp   Members   -  Reputation: 273

Like
1Likes
Like

Posted 03 February 2012 - 12:17 PM

ok I managed to get nearly as much boxes as I want on screen... pic attached (2048*2048 cubes), the problem now seems to be the frame rate which drops dramatically, but the mem footprint on the system is brutal at 8.5mbs only, and the generation type (of this simple terrain its only 33 secs, which is not bad for so many blocks) !!! This is without fructum culling, I'll try adding that now, and reduce the size of the sections which now is 16*16 sections of 128*128 cubes. To something that the fructum culling can take more advantage of, probably will need increase the mem foot print due to the bounding boxes for the sections that I need to add (I'll try to create those on the fly for reference on the FPS count and see what comes out.)

lots of cubes test.png

This is loading 2 perlin 2d functions, one for land, and another for grass painting. the water is colored based on depth of water, which looks kind of cool.

Did someone got a look on the trilinear interpolation questions? tx

#40 winsrp   Members   -  Reputation: 273

Like
0Likes
Like

Posted 03 February 2012 - 03:31 PM

I'm having a bit of a transparency issue here that I can't seems to figure out.

I set the color of the water to

new color(color.blue.r,color.blue.g, color.blue.b, ctype(color.blue.A/2, integer))

but it seems to have some artifacts, any ideas?

transparency issue.png




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS