• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
winsrp

XNA 4.0 voxel map rendering, using noise techniques

46 posts in this topic

First of all, HI all,

Second of all, I know and I'm fully aware I'm a newb on game creation.

I have programmed desktop applications for quite a while now (more than 7 years) and I wanted to make something in the gaming department.

I have tons of ideas, but I know that in programming you need to start by building a very strong foundation otherwise the whole thing would be crap.

Now I don't like c# much, even I can read it, program it, use it and all that, but I like vb.net better (personal preference), so I made my project for xna 4 which has a ground in c#, but then I made my game class in vb importing the same libraries and everything works like a charm thanks to the bless of the .net framework. I don't really care to do all the nasty conversions from c# to vb.net, actually they help me to understand the code better, instead of just copy paste.

I've made like 7 tutorials already of XNA 4.0, with lots of great techniques, and I decided that seems like time to start shaping my own game.

Having said that, I decided that my world would be made out of cubes, which will make destruction, movement and generation of new cubes by the player a rather simple operation, as they wont have weird shapes.

And as such the first thing i wanted is terrain + camera.

I've made a cube array of 32x32x32 (x,y,z), using y as height and made my camera to go around. Now with a couple simple rules, you can set, the first 4 y layers to be ground, and above it, to be air.. also made some optimization's, to have the renderer only display the vertices of the cubes that can be seen on the top layer, hiding all the vertices that are below other cubes. I still need to optimize it further so only the vertices that are on screen are displayed but that will be done in the following days.

Now the first thing that occurred to me was using a height map, which seems simple enough to start playing with the camera a little (I still, don't have gravity not hit-boxes, so the camera is only to see what is the result. Now the result is nice, and i have already tried it at a 1024x256x1024 scale, and it looks even better, but seems like missing lots of details, so 2 problems arise from this

#1 the mountains are way too smoothed.
#2 I am limiting the bounds of the map to the amount of x and z that I put on my array, currently 1024x1024, and you can see from side to side, not to mention walk from side to side in less than a minute.

For problem #1 I investigated on lots of techniques, currently read more than a hundred articles (not exaggerating here, currently have more than 150 tagged pages on this topic), and I would like to know how can you create something like this

[url="http://www.gamedev.net/blog/33/entry-2227887-more-on-minecraft-type-world-gen/"]http://www.gamedev.n...type-world-gen/[/url]

in XNA 4.0 as i have found lots of code, but have not yet fully understood the meaning of all the terms, and the combination of techniques to get this result, plus I would like to remove the floating islands that I have seen in some examples.

For problem #2, well, I first need to figure out how to get #1 done, and then how can I ask for a single [x,z] coordinate to get the array of next set of [y] cubes in any given direction, that will match the previews section.

Thanks all,

Winsrp.
0

Share this post


Link to post
Share on other sites
hmm... no love for the new guy,

I know that when your post gets to the second page, you better post an update to it, otherwise its dead.

I have managed to kind of get over problem #1, and definitively over problem #2, now the only problem i seem to have is the gradient to display more ground on the bottom and move air on top, which i have already tried like a 100 combinations and I cant get it to work..

Here are 5 sections in a cross array.

[attachment=6830:Test1.png]
0

Share this post


Link to post
Share on other sites
Just because nobody replies doesn't mean they aren't interested. It just means they have nothing to say. Keep up the good work?
0

Share this post


Link to post
Share on other sites
ok so I managed to start using the libnoise, (as I was using something else), but I still haven't figured out how to make a gradient kind of map to load more ground on the lower half than the upper half.

Any ideas? as Libnoise seems to be rather popular, then I would think I might get a little more help here.
0

Share this post


Link to post
Share on other sites
still not getting over the gradient map terrain, but i did some funny stuff, and stumble upon another interesting issue I'm shooting red balls at my terrain, when the ball hits the terrain then that block gets removed from the map. Really simple collision detection here. but it does something weird.

I've set up a test terrain of only 8 blocks on a 2x2x2 array to set out.

when i shoot the block somethings on screen it removes 2 blocks but checking on the buffers lists and all, it says it only removed one block, and the vertex and index buffer all say it only removed 1 block, still on screen 2 blocks are removed....

on the update method i check for collision and and then i clear the list that contains my vertices and indexes and refill it with the list.toarray that contains the new list of the remaining blocks, everything seems fine from the debuging stand point but not all blocks are displayed, even further more, at some point the missing blocks start to show up again... very weird.
0

Share this post


Link to post
Share on other sites
Update: Never mind it was me being stupid, and not updating the indexes. So when you remove a block you need to recalculate the indexes as vertexes are not in the same order as they were before.

This is a section with no vertex optimization.

[attachment=6886:working section.png]
0

Share this post


Link to post
Share on other sites
does anyone know how to make some fast collition detection? I can check for sections and then blocks on each section, which allows me to shoot around 250 parallel bullets but if a single one touches the ground.. the game kind of stalls.

here a screen of several sections together and some holes from my bullets.

[attachment=6892:working group.png]
0

Share this post


Link to post
Share on other sites
and i have another question, hopefully ill get some hints on this one..

If i want to use perlin noise with different frequencies, but on the same map making it smooth, how can I make them fit together without looking like pasted in and cut.
0

Share this post


Link to post
Share on other sites
There are many approaches, but one common approach is [url="http://www.graphics.stanford.edu/courses/cs248-98-fall/Assignments/Assignment4/noise.html"]Fractal Brownian Motion[/url].
0

Share this post


Link to post
Share on other sites
hmm... but whats the difference between Perlin Noise and Fractal Brownian Motion? I currently have my perlin function that creates noise based on frecuency lacunarity persistance, octaves and such, I have read the article, but it seems to be talking of the same thing I have,

If i grab my function and change any of the parameters on the fly it will normally show weird results on screen like cutted sections and such, and I wanted to make some parts with high mountains, and others like long beaches and maybe some with large deep oceans and stuff
0

Share this post


Link to post
Share on other sites
[quote name='winsrp' timestamp='1327677045' post='4906760']
hmm... but whats the difference between Perlin Noise and Fractal Brownian Motion? I currently have my perlin function that creates noise based on frecuency lacunarity persistance, octaves and such, I have read the article, but it seems to be talking of the same thing I have[/quote]
In that case, you have have already implemented fractal brownian motion.

<rant> Some idiot once [url="http://freespace.virgin.net/hugo.elias/models/m_perlin.htm"]misnamed value noise + fBm as 'Perlin noise'[/url], and ever since we are stuck with people using the wrong terminology </rant>

[quote]If i grab my function and change any of the parameters on the fly it will normally show weird results on screen like cutted sections and such[/quote]
That sounds like a bug in your implementation. Changing the parameters (within reason) should always result in a continuous terrain.

[quote]and I wanted to make some parts with high mountains, and others like long beaches and maybe some with large deep oceans and stuff[/quote]
That's a slightly different problem - fBm produces fairly uniform terrain across it's entire range. I would recommend you try out [url="http://blog.nextrevision.com/?p=52"]Ridged Multi-fractal[/url] - I don't have a reference implementation to hand, but I'm sure you can find one.


You generally have to combine several different types of fractal to achieve the kind of variety you are looking for, though. Consider using fBm to drive some of the parameters on a ridged multi-fractal...
0

Share this post


Link to post
Share on other sites
Thanks for the info, I do know that Perlin noise is what should be called as 1 octave, with fixed frequency and persistance, and fBm is the combination of different octals of a single funtions (being Perlin, or other), I do have the implementation of all the functions as I have the libnoise for xna on my project and includes several of this fractal functions.

Now if I change the coordinates on my fBm for perlin noise, the values are really nice and smooth, but if i change the octaves, frecuency, etc on the fly, this will produce the cutted out sections that i have described. So I managed to combine a 2D perlin fBn that i use for initial height map, with another 2d perlin fBn with different values, and do some manual addition (i still need to use the add function from the libnoise to see if i get the same result as my manual implementation) in order to get a flat ground from the first and some more rough looking hills with the second, and im using a third 3d perlin fBn to create some caves and such on the ground.

All this combined seems to look rather nice, but now I have 2 more questions

1. how do i make the sections be split in biomes, so i have have a more desert looking area, and then a more rocky area. the problem in hand is not the generation itself, as I can do it by combining severs fBm functions, but more looking at the transition between areas? move from desert to grass, to mountains, to jungle, etc, without looking like im cutting sections again, if i stop a single fBm at a given time i don´t know if the mountain for example has reach its joing point between the next biome lets say desert, and so the mountain just gets cut flat from where i stop.

2. trying a single 3d perlin fBm, to make terrain i take every value > 0 as air, and any value < 0 as land, which produces an image such as the first i posted on this post, is there a way to apply a gradient on this function, so that i get more land on the botom and more air on top, ensuring that the lower layers are full ground and the upper layers full air, and the result in the middle seems smootly round instead of a flat area?

thanks.

http://www.blueplanetbiomes.org/world_biomes.htm
0

Share this post


Link to post
Share on other sites
I've been fiddling around with different methods of implementing biomes in my own block engine and I think the best way to do that would be to create a different noise map (or generation layer, I do like buzz words) all together for them.

Currently I have a few noise generator modules linked together like an assembly line. Each module is responsible for generating a segment of the terrain (one module does underground cave systems, another does above ground features, etc). Doing it this way allows me to easily move/toggle the generation stages and edit them in isolation. My plan for biomes is to insert another module that generates a large scale noise and then interpolate between different biome terrain modules from this.

As for collision detection, I assume that you are using a 3D array to store your terrain. A method would be to use the camera position to index into the array and check to see if the blocks they're walking into are solid or air.

To make the terrain infinite like in Minecraft, I went with a circular array that goes pretty much like this:

[img]http://r21.imgfast.net/users/2111/38/84/62/album/wrapar10.jpg[/img]

Hope this helps.
0

Share this post


Link to post
Share on other sites
interesting bit of information, i currently can do collisions, but they seem to take quite a while, so I'm optimizing those, i had to shrink the chunks otherwise i couldn't do multiple high velocity projectiles with explosions.. after 10 concurrent projectiles the game kind of stalls at 7 fps, until most of explosions are done (and I don't even have an explosion effect yet!!, I only remove the blocks), I also make quite some memory optimization as i couldn't load too many cubes at once, only around 250K, (I'm now around 3.4M in less than 5 secs, and I can also do 7.5M blocks on screen in less than 10 secs) but my frame rate starts to slow a bit to 30 fps... so planning on optimizing this as well.

Currently I'm not advancing much as I know that if I start doing lots of stuff optimizing its going to be a pain latter, and by doing so now, I will carry all those optimization's to further stages.

I still have to make it so the maps loads as I move, but that is a really near next step now.

Thanks for all the info.

Now with that out of the way... the next question.

i don't have a model in my screen and I don't want to start learning another program such as blender, to start doing one, so I thought... why don't I make a model in game... and so the question is..

how do I make a model in code?, for example I know how to make 4 blocks on top of each other with different dimensions, but how do i make the feet move in a walk position given the following model.

[attachment=6963:model.png]

so its a head on top with a block, a body in the middle block and the 2 lower blocks are feet.

please don't mock my incredible paint skills. tx.
0

Share this post


Link to post
Share on other sites
another quick question,

I was doing frustum culling, with the following code

[code]boundingFrustum.Matrix = viewMatrix * projectionMatrix[/code]

So i then checked against my sections

[code] If boundingFrustum.Contains(Section.BoundingBox) <> ContainmentType.Disjoint Then[/code]

but then it occurred to me... what if I start moving the world instead of the camera, it will make it easier for some validations that seem to be a pain in the... you know.

Instead of updating a camera position vector, I update a worldposition vector, and then do a worlmatrix.translation based on worldposition -1 (as it has to move against the camera). But now my frustum culling its all messed up.

Any ideas how can I apply frustum with world translation in place?
0

Share this post


Link to post
Share on other sites
wow... never mind, I found out what I was doing bad!!... idiot me I had to update the section bounding box based on the new world position otherwise the world looks like moving but the bounding box of it is not... also need to update any other bounding box in the world... hmm...
0

Share this post


Link to post
Share on other sites
no good then... ill move the camera, as moving the world will imply updating the bounding boxes of all my cubes.. and so no good. Performance hit was too big.
0

Share this post


Link to post
Share on other sites
I seem to be having some trouble after 11 millon cubes, only around 400k faces loaded on mem (takes 22secs to load).., and i have applied as much culling as I have managed to find (actually didn't even knew what culling was till like 2 days ago)

memory collapses, even when frame rate is rather good at 60fps, it loads arrays with 700mb in memory, for all the cubes (only positions in x,y,z, color and height, and bounding box), and then it fills another 500mb with the vertex and index buffers... so I can load as much as near 13 million cubes, and it it goes over 1.6GB of ram and runs out of memory.

It seems like 1.6GB of mem is rather extensive for just some cubes... yes, lots of cubes I know, but still seems like it should be able to hold a larger amount, I was trying to get to near 20/30 million, but seems impossible.

So I was reading about instancing, but I don't know if this can be applied here. Here is a little screen.

[attachment=6976:nice world.png]
0

Share this post


Link to post
Share on other sites
I think you would do it like, for each chunk, generate a single mesh thing and draw that instead of every cube separately. Then when you change that chunk you regenerate the mesh. And only draw faces which touch air.
1

Share this post


Link to post
Share on other sites
One nice way is to "blend" two different functions with a third one:
[code]
blend_factor = smoothclamp(10*noise2d(x,z),0,1)
result = terrain1(x,y,z)*blend_factor + terrain2(x,y,z)*(1-blend_factor)
[/code]

Edit: shameless plug: also check out my [url="https://twitter.com/#!/JakobProgsch"]twitter photos[/url].
0

Share this post


Link to post
Share on other sites
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?
0

Share this post


Link to post
Share on other sites
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..
0

Share this post


Link to post
Share on other sites
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 ;).
0

Share this post


Link to post
Share on other sites
ok, now i need to wiki almost half of the words you just put... lol... thanks for the info.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0