Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] What's the range of the example cave generation nodes tree? #126

Closed
Filocava99 opened this issue Jan 4, 2024 · 6 comments
Closed

Comments

@Filocava99
Copy link

Hi, I was trying out your tree example for cave generations (base64: EwCamZk+GgABEQACAAAAAADgQBAAAACIQR8AFgABAAAACwADAAAAAgAAAAMAAAAEAAAAAAAAAD8BFAD//wAAAAAAAD8AAAAAPwAAAAA/AAAAAD8BFwAAAIC/AACAPz0KF0BSuB5AEwAAAKBABgAAj8J1PACamZk+AAAAAAAA4XoUPw==) but I'm a bit confused on the values range and when it is supposed to be hollow. Is it solid on the min/max values or when it's very close to 0?

@Auburn
Copy link
Owner

Auburn commented Jan 4, 2024

In the NoiseTool the default setting is any value >= 0 is solid

You can see the generated min/max values and change the isosurface value in the debug window

@Filocava99
Copy link
Author

Filocava99 commented Jan 4, 2024

Mmm that's weird cause I am getting a very weird result (https://prnt.sc/XPb80X4USDDK). The max value that I get from the NoiseTool is a 0.02, almost all the values are negative.
For the sampling I am using fnGenSingle3D and iterating each block of a cube (16x16x256) , it's not efficient but I'm just doing some tests.
Is there any detailed documentation for the parameters of the Gen* functions (grid, single, etc)?

FastNoise2.INSTANCE.fnGenSingle3D(caveNoise, chunkX*16+x.toFloat(), y.toFloat(), chunkZ*16+z.toFloat(), seed)
Just for reference, I made a binding using JNA, it works fine but maybe I understood the parameters wrong.

@Auburn
Copy link
Owner

Auburn commented Jan 5, 2024

Sorry I got that the wrong way round, value >= 0 is air.

Max is only 0.02 to keep the cave sizes smaller, you can change this by adjusting the Subtract node.

@Auburn Auburn closed this as completed Jan 5, 2024
@Filocava99
Copy link
Author

Filocava99 commented Jan 5, 2024

Hi, thanks for replying so quickly.
I tried that but the result it's the inverse of what you see in the picture (the holes are now filled and viceversa).
At this point I am wondering if I am using the generator functions correctly.

Given a cube X * Y * Z of size 1625616, running the following code

for(int x = 0; x < 16; x++){
  for(int y = 0; y < 256; y++) {
    for(int z = 0; z < 16'; z++) {
      bool isCave = fnGenSingle3D(caveNoise, x, y, z, seed) >= 0f
      ... store result ...
    }
  }
}

it should give me a coherent list of coordinates that form up a cave.

I also tried a simple terrain generation tree and instead of sampling each 2D coordinate I tried using GenUniformGrid2D; I tried generating two chunks, which means I run the following code:

int chunkX = 0, chunkZ = 0;
float[] chunk1 = fnGenUniformGrid3D(chunkNoise, arrayPointer, chunkX*16, 0, chunkZ*16,16, 256, 16, 0.1f, seed, null)
int chunkX = 1, chunkZ = 0;
float[] chunk2 = fnGenUniformGrid3D(chunkNoise, arrayPointer, chunkX*16, 0, chunkZ*16,16, 256, 16, 0.1f, seed, null)

In that case the surface of the terrain is coherent (meaning it doesn't make any weird jump) only inside the same chunk, making highly noticeble the connection between the two chunks.
When using UniformGrid how do I specify the steps it makes with the coordinates? If x is 0 and xSize is 16, what does it use a step for reaching the required size? 1? Or does it use the frequency parameter?

I also wanted to describe the issue with the terrain generation cause everything is problably related to how I am using the APIs given I couldn't find any documentation.

@Auburn
Copy link
Owner

Auburn commented Jan 5, 2024

It's likely caused by you indexing the noise array using the incorrect axis, in your first code block above your for loops go x, y, z when it should be z, y, x. Have a look at the example code on the wiki.

As for the cave noise, I'd guess the issue is somewhere else in your code, what you have posted looks correct.

@Filocava99
Copy link
Author

Filocava99 commented Jan 5, 2024

Got the cave noise to work using GenUniformGrid instead of GenSingle3D. Weird tough

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants