Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (804)
Games in Android Showcase (239)
games submitted by our members
Games in WIP (868)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  How to add noise  (Read 6702 times)
0 Members and 1 Guest are viewing this topic.
Offline Ging3rtoby
« Posted 2014-01-09 16:34:46 »

Hi this is my voxel engine so far...

This is my chunk class -
This is my main game class -

Could someone please tell me how to add random noise to this engine, so my voxels have different heights thus making random generation, I have looked a simplex noise i just dont know how to add it to my engine

Thanks Toby
Offline Sabomoth

Junior Devvie

Medals: 4
Exp: 3 years

« Reply #1 - Posted 2014-01-09 17:02:05 »

Several threads on it. Simply use the result as a heightmap.
Offline Ging3rtoby
« Reply #2 - Posted 2014-01-09 17:55:07 »

These help a bit but i need some help on how to add these to my code
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline jonjava
« Reply #3 - Posted 2014-01-09 18:28:37 »

Noise is a bunch of values related to each other. In your case, it seems like you want to add these values to your heights.

So just do that.

Create a noise map and add its values to your your blocks height value. How big should the noise map be? Preferably the same size as your game map. Makes sense right?

e.g. it could look like this for a 2d map:

for (int i = 0; i < map_width; i++) {
  for (int j = 0; j < map_height; j++) {
    gameMap[i][j].height = noiseMap[i][j];

Offline philfrei
« Reply #4 - Posted 2014-01-09 18:46:20 »

To add to Jonjova's answer:

for each [i,j], you would execute the following call:
double noiseValue = SimplexNoise.noise(i * widthFactor, j * heightFactor);

This will return values that range from -1 to 1. How you convert those values to ones that are useful for your voxels is up to you. The two most common strategies are scaling ("smooth" noise) and applying an Abs function to the results prior to scaling ("turbulent" noise).

The values widthFactor and hightFactor above are used to control how quickly the values transition. With SimplexNoise, progressing integers tend to just generate unrelated, random values. I'd try using a factor such as 1/128 (give or take a power of two) as then you will get the transitions between the random peaks.

To get more interesting effects, you will have to make multiple calls to the function at differing width/height factors, and weight the various answers depending on the frequency content you desire. Also, the noise result can be used to permute another function such as a sin or radial gradient.

music and music apps:
Offline Ging3rtoby
« Reply #5 - Posted 2014-01-09 19:18:17 »

Ok have no idea but what the hell
Offline Ging3rtoby
« Reply #6 - Posted 2014-01-09 19:33:15 »

Whats the game map array I havent got that
Offline Sabomoth

Junior Devvie

Medals: 4
Exp: 3 years

« Reply #7 - Posted 2014-01-09 20:29:01 »

How do you create your map? The map array is what contains the data that will be rendered as your map. For example an array of floats with the values -1 to 1 as described below. You then tell the game to go trough every single post in the array and render all numbers between lets say -1 to -0.40 as a dirt block, -0.40 to -0 as grass, etc etc.
Pages: [1]
  ignore  |  Print  

Riven (581 views)
2019-09-04 15:33:17

hadezbladez (5510 views)
2018-11-16 13:46:03

hadezbladez (2402 views)
2018-11-16 13:41:33

hadezbladez (5772 views)
2018-11-16 13:35:35

hadezbladez (1223 views)
2018-11-16 13:32:03

EgonOlsen (4661 views)
2018-06-10 19:43:48

EgonOlsen (5682 views)
2018-06-10 19:43:44

EgonOlsen (3198 views)
2018-06-10 19:43:20

DesertCoockie (4095 views)
2018-05-13 18:23:11

nelsongames (5115 views)
2018-04-24 18:15:36
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!