-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Calculation of the Perlin noise derivatives (gradients). #14635
Comments
If I understood correctly, then the code already has calculations of the noise gradient. Can I call them from the LUA API? I also saw the interpolation and would like to be able to call these functions from the LUA API. For example, I use 2d noise to generate rivers and other 2d noise to generate surfaces. I need to make sure that the river is in a depression and for this I could use interpolation of two noises with different settings. It is possible to write interpolation in LUA, but I am not sure how good an idea this is in terms of performance. I also think it would be useful to be able to calculate the gradient by selecting the desired octaves. Thus, if necessary, you can filter out unnecessary "noise" and see the trend at the desired level of detail. Are there any plans to add other noises? |
Would approximating the derivatives though a linear delta calculation not be precise enough? You can already get the noise value at a given position, thus checking the neighbours (table lookup) of the heightmap provided by the mapgen should be feasible. |
I am currently studying the mapgen object api, apparently you are writing about it. You suggest trying to calculate the values of the first and second order derivatives from the values of the noise functions of the previous and next integer coordinate values. This is: I was planning to use this mechanism in this mod: Questions for clarification:
|
minetest/src/script/lua_api/l_env.cpp Lines 1123 to 1140 in c4703a7
The noise values are calculated only when you use a getter function, such as
It creates a new table minetest/src/script/lua_api/l_noise.cpp Lines 155 to 176 in c4703a7
|
I understood, then I didn't understand, then I started to figure it out and got into the code. I don't understand the c++ source code by almost 90%. I realized that The Well, returning to the question of the derivative, is it possible to add the I have already realized that by calculating noise over a region, I can use these values using numerical differentiation methods to approximately calculate the values of the derivative with some accuracy (depending on the method). |
Problem
For example, I am writing a world generator and when inserting a node in a certain place on the surface of the earth, I would like to know which way the height of the surface will grow and at what speed. And depending on the growth rate and direction, it is up to me to decide whether to insert earth or stone. If the mountain is growing and the growth rate is higher than the threshold I set, I could put a stone on top and I would have high cliffs without earthen nodes spoiling the landscape. That is, we predict in advance how the noise value will change when any of the coordinates change and we can make a decision depending on this.
Solutions
As far as I know, it is enough to write functions for calculating partial derivatives of each coordinate. And second-order derivatives will allow us to find out how quickly the noise value will increase or decrease in a given direction. The advantage of this approach is that all this can be learned by working with the coordinate of one node, without calculating the noise values of the surrounding coordinates and without generating the world "in advance" in order to correct it later.
If we recall the school course of mathematical analysis, then the first derivative shows us which way the graph will be tilted. That is, if x increases, then y increases or decreases. The second derivative will show how much the graph is tilted, i.e. how fast the y coordinate changes depending on the x coordinate.
Alternatives
nothing
Additional context
I think this description is enough to justify the usefulness of this feature, especially for developers of LUA generators. I looked in the documentation and searched for this topic in the issues on github, but found nothing. I hope that I explained everything clearly and did not confuse anything. I learned about this approach when I watched a video about generators of worlds and the author of the video said that the authors of "No man's sky" used it for soil erosion.
The text was updated successfully, but these errors were encountered: