• Create Account

# winsrp

Member Since 19 Jan 2012
Offline Last Active Feb 10 2014 03:21 PM

### #5079587Generating Volumetric Terrain

Posted by on 22 July 2013 - 09:00 AM

well its almost 5 seconds actually...

The display area contains much less than 55M (around 2M+ displayed), the 55M are just the ones marked as solid.. (including the ones underground, that are not rendered, since they are not needed) there are other 225M that are marked as air (lots of air here).

This is just a height map (which combines 2 or 3 fractal functions) with "patches" of 3D artifacts here and there, where the patches go, is also defined by 2D fractals. The trick is reading the 2D fractal as a possibility gradient map, instead of a height map, the view would be the same as a height map, the difference is how you interpret the values returned, in my case is value >0.5 check for 3D formations, <= 0.5 no 3D formations. Then I use the actual value 0.73, convert it from value range {0.5,1} to value range {0,1}^3 using fx=((value -0.5) * 2)^3 for example, and use the resulting value as a gradient for that 3D so that it kind of sticks to the ground.

I also used multi-threading to make the 8500+ sections of 32*32*32. This map does not uses the minecraft kind of generation where you can go from 0 to 128, and that's it, In here you could go as high or low as you wanted.

### #5079171Generating Volumetric Terrain

Posted by on 20 July 2013 - 11:42 AM

that's and old prototype I'm no longer working on. Here is a wider look at it.

### #5079155Generating Volumetric Terrain

Posted by on 20 July 2013 - 10:10 AM

Hi dude,

I'm going to skip the actual intellectual mumbo jumbo about how to get things done and put some ideas you might work on based on your question on the first post.

How to use noise to generate landscape: remember that noise returns a value between -1 and +1, for whatever position you are trying to get. So, you can use this to you advantage in different ways, for example, you can convert the values to a scale from 0 to 100 and use it as a height map... how do you do that.. simple, first convert it to a scale from 0 to 1... using something like 0.5 + 0.5 * perlin_result, then you can multiply that by whatever you need... 100, 1000, 100000, etc. You can now use that value as a elevation map and just fill cubes from 0 up to the point that perlin results. so if you do 0 to 100, and you get a 53, you will fill 53 cubes with solid, and the remaining up to 100 with non solid or air.

Now how do I put ground on top and something like rock below, well, you can grab something simple like 10% of the value you got, so lets say 5.3, round that either up or down, and put that as dirt, then grab the remaining and put rock, and you can so these kind of calculation to different effects.

How do you make the terrain in chunks, make the world know about other chunks, make smooth transitions and such. Define your view distance, say, 512*512 cubes, assuming the center is at around position 256. then slip that into a size that the program can render fast, say 16*16 or 32*32 or 64*64, it will depend on your optimizations. then make an array of chunks, so if you have 512 and chunks of 64, that will be 512/64 = array of 8 by 8. Each chunk will have an ID, which could be for simplification purposes the position where its first cube starts. so first section ID is {x=0, z=0} next section is {x=64,z=0} and so on... so if you want to know about chunks of another section just check for the cube position, get the section where that cube is at, extract is value, done.

Making smooth transitions between chunks, well, I would recommend that when getting the perlin value from your noise function, you don't do {x=5,y=0,z=7}, you do something like {x=5/2048, y=0, z=5/2048}. this will allow you go get a lot of numbers in a very smooth transition (you also need to tweak you noise frequency and other values)

Why do I use y=0 all the time, well, if you get the x and z value you will always get a height map. if you go up in y imagine a whole different height map, but very similar to the one you had below. That is the 3D perlin.

I don't want to use 2D perlin for noise height maps I want to use 3D, well first off computing a perlin value is not really expensive, computing a billion of perlin values is. But that will be really up to you.

I tried to make 3D noise but it look like a cut in an Ant farm, wtf do I do with it? Well if you use 3D noise as it is, you will end up with flying formation of all kinds. One way to bring all those formation down to earth and still keep some of the variations is to use a vertical gradient. ... Now you are thinking.. Say what!!, yes a gradient, you know... full wait down, full black on top, and lots of grays in the middle.

Using a gradient you will tell your program, for example, if you get a position at Y=0, that's full white in the gradient then it has a 100% change of using whatever value the perlin got. if you get a value in y=50, then you can have 50% chance of using that value, and so on, this will end up looking a bit better but it will not solve your problem entirely, different other approaches give different results so you have to try them out.

Try using curves, instead of a linear one... the linear one is when you have y=x (type y=x in google), an exponential curve is when you have y=x^2, or y=x^3 and so on (type y=x^2 in google to get the idea), you can also use y = sqrt(x), for an inverted curve. The properties of both exponential and roots is that if you have a value from 0 to 1 they will always give you at the end points 0 and 1, its the numbers in between that change their factor. So get the pelin value perlin={x=5/2048, y=0, z=5/2048}, apply and exponential or root formula, perlin = perlin^3, then check to see the value is withing your threshold.

Also in order to make a voxel engine you need to optimize a LOT, so don't draw the cube faces that are occluded by other cubes, for example, if you have 2 cubes, one on top of the other, the upper face of the lower cube, and the lower face of the upper cube are hidden so, why would you make triangles there...  this seems like a small optimization but multiply that by 1billion cubes most of the all next to each other, and that will save you a lot of performance.

Use frustum culling with you chunks, this will save lots of rendering time by not sending entire chunks out off view to the GPU.

Another trick you can do, is some sort of data compression, for example if you have a cube tower, from you value 0 to 255 as max height, you will start to notice that you will probably end up with, 20 cubes of solid rock, then 5 of air (cave),  then other 40 cubes of solid rock, 5 cubes of dirt and 185 cubes of air, having an array to hold 255 values for just 5 transitions seems dumb. so you could make an array with a structure that will tell you the cube type and how much of them are on top of each other. This will not remove the computational burden of calculating lots of cubes, but it will reduce the amount of information you work with, but this is a rather advanced topic that must be worked on after you have a system in place as it will break a lot of stuff in the process.

Another trick you can do, is have a geometry shader do the cubes for you, based on you positions array, but that a story for another day.

An advice I will give you is that even when the fractal functions produce a really nice looking result if combined right, you should not leave 100% of the generation to combining fractals, try for example using a fractal function to figure out the placing of rocks...small round pre-calculated figures of 3x3 or so, that will first fit on the current chunk, and second will show up if perlin value has an exact value of some constant you have.

I'm going to leave it there so you can chew on all that, and lots of tests.

### #4987998Is XNA dying and MS forcing to C++?

Posted by on 08 October 2012 - 08:18 AM

once you get pong going, its time for something like pacman.

### #4981333Experienced programmer, where do I start?

Posted by on 18 September 2012 - 12:19 PM

with out reading all the other comment, here is my take on how to make an MMORPG

first make the G... it does not have to be entirely functional, this includes the basic of what you would very later on call an engine, so very basics here, display terrain, make guy, put in on ground, make it hit the ground, jump, stuff like that. (you might need to build several of these Gs, in order to get something very functional, and optimized, and you will revisit this part on every iteration ahead)

then once you have G... you make a PG.. so a playable game, you actually build interaction with your player, pick stuff of the ground, hit enemies, talk to NPCs... all that things.

then you make an RPG... where you actually try to build the beginnings of a story and give you player a role of what he should do, and what it will do to save the world/princess/continent/family/universe/etc etc.

after that you start with the first M, which stands for multiplayer, so you get an MRPG, and add other players to the mix from the lan environment, with the same objective and stuff to do, if you did a good job on the R part of the mix, you might have users do different stuff at the same time to help each other.

all that good, but you have to add the O after yo hit this point, so an OMRPG, you manage to make other users connect over internet, should not be that hard if all things are don't right to this point.

And finally you will do the last M.. the massive. and when you get here, you better have your player do a whole lot of stuff, which a huge map, and an even bigger server backbone, otherwise your home computer will explode.

So if you are a total newb, there is a VERY long road ahead, that's my 2 cents here.

### #4958521"Make Games, Not Engines".. But how?

Posted by on 12 July 2012 - 01:41 PM

I have also started not long ago, about 4 months or so, trying to make games.

Initially my advice is become a sponge, there are lots and lots of techniques, names, and stuff you just need to learn to even display a single triangle on the screen, the other advice is, find a simple basic demo, like how to display a triangle or sprite, and go step by step with it, trying to make it on your own, and understading completely each step done.

At this point don't think about engines or games, just think of learning small pieces of info that will get you closer to you initial goal, which should be make x or y kind of game. once you have a grasp on the absolute basics, start learning things that will help you shape your game a little more, for example, on a pong game, you need to learn,

how to display single images, like cubes, bars, and balls,
next learn how to make the ball move on its own,
how to make the user tap a key and make something happen, then make it move the bar,
lear about coalitions, how to make the ball hit the moving bar,
how to make the ball hit the fixed blocks,
how to make the ball bounce on the corners,
how to make the blocks on your screen dissaper on hit, and maybe spwan items on a random basis, make you bar collect those falling items,
how to play sounds on impact,
keep track of your score of each hit, and how to make a level up once all blocks on screen are gone
make a menu screen, a you loose screen, and a you won screen.

At the end of your learning curve, before you know it, you will have small basic parts of what will become a simple game engine. Then on your next project you can grab the player input code and expand it to accept more keys, the sound code to play more sounds at the same time, make a differnt kind of layout, for a tile game maybe, make the player code accept a sprite for a guy instead of a bar, and make move in all direction instead of just left and right, well you get the idea... you knowladge will start growing and you game engine will evolve with it, from a pong game engine it can become an rpg, an rts, or what ever you want it.

On the other hand comercial game engines are designed to accept variables for lots of game types, that makes it normally a waste of time for developer that are focusing on a single game, and want to develop their games from 0.

All this to say, Focus on your current game, and your next game and engine will evolve with the knowledge you gather from your previews experience.

### #4950732Few questions - collision detection

Posted by on 19 June 2012 - 03:09 PM

also start here, it will teach you most of the basics. I started here too.

### #49506623D Perlin Noise Map Ridges

Posted by on 19 June 2012 - 12:15 PM

that kind of landscape is not hard to make, took me a while to figure it out also, worst than a company secrect, no one want to tell

you need to use a 3d perlin function, in combination with a 2d perlin function.

whit 2d perlin you make a height map, just like you are now. So you probably do something like

```for x = 0 to widht
for z = 0 to depth
get perlin 2d for height
for y = 0 to perlin2d
make cube
```

In order to add the 3d, you need to call one 3d perlin value and use it as density.

```for x = 0 to widht
for z = 0 to depth
get perlin 2d for height
for y = 0 to perlin2d
get perlin 3d for density
if density > 0 then
make cube.
```

You would normally also want to use the perlin 3d after you have some ground under you, otherwise you will get empty spaces as in your first screen.

```for x = 0 to widht
for z = 0 to depth
get perlin 2d for height
for y = 0 to perlin2d
if y > waterlevel+(some number lets say 8, so you have some nice beach)
get perlin 3d for density
if density > 0 then
make cube.
else
make cube (density is not important on lower levels)
```

Now in order to avoid some of the anoying floating islands you just apply a gradient to the density of the 3d perlin such as

```for x = 0 to widht
for z = 0 to depth
get perlin 2d for height
for y = 0 to perlin2d
if y > waterlevel+(some number lets say 8, so you have some nice beach).
get perlin 3d for density
make cube.
else
make cube (density is not important on lower levels)
```
.

Which this you will have your 3d terrain in no time.

Calneon, how the hell you did the lighting... that thing is killing me....

### #4949180need help on a simple math equation.

Posted by on 14 June 2012 - 09:48 AM

holy crap, that was fast!!, let me test it out a bit, and I'll let you know.

### #4947179Senior Project - XNA

Posted by on 07 June 2012 - 02:35 PM

well, I would advice to first take some C# classes, or tutorials, since moving from C++ to C# is not exactly a smooth walk in the park. And having high school programing experience is not equal to having game programing experience... belive me, I have just started game programing a couple months ago, and I have 10+ years of programing experience in mayor US companies, its not the same thing, I can make multiclient-server enterprise applications with my eyes closed, but game programing is a whole lot different, even in a simple enviroment such as XNA.

Also you need to learn HLSL, which is fundamental, otherwise your game won't even show on screen, (and if you use the built in shaders your game will look like crap) the good thing is that it looks like C# in the code, but the math related to it its kind of crazy.

I'm not saying don't do it, but it is a pain, so be prepared for it, there also that great fealing of making a game with your own rules that makes it all worth it.

### #4947175Creating graphics for a full screen game? What dimensions?

Posted by on 07 June 2012 - 02:24 PM

on topic

I think the biggest resolution you should care is the 30" monitor resolution, after that if you game ever gets to support something like 3 monitor view, you can still have your GUI centered on the middle monitor without streching it too far.

Still you have to decide what resolution suits you best, for example I have a 27" monitor with 1920*1200 resolution which is bigger than 1080p, and I do like to have my GUIs on the main monitor.

Is also advice that when planning your gui, some of the elements can be separeted, for example dont make a gui that is a square all around the monitor otherwise your are in a deep problem when you have a bigger resolution where the elements cannot be moved.

normally you will have a small element on the bottom of the screen that can be streach horizontally as needed, and maybe some floating elements on the sides, like stats, friend names, chat boxes, etc, and maybe some information on the top middle like monster life, etc. Just check any modern game and try to separete the details.

### #4909250XNA 4.0 voxel map rendering, using noise techniques

Posted by on 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.)

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

PARTNERS