You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'd like to implement warping (e.g. https://iquilezles.org/articles/warp/) using this library. An example warping function is provided in that article. It looks like:
float pattern( invec2 p )
{
vec2 q =vec2( fbm( p +vec2(0.0,0.0) ),
fbm( p +vec2(5.2,1.3) ) );
return fbm( p +4.0*q );
}
where fbm(..) is a fractal noise function that takes, in this case, a 2D vector and returns the noise value at that point. This example therefore deals with the same kind of noise as makeRectangle(..) in fractal-noise-js.
This technique requires being able to get noise values at arbitrary points and is therefore not presently possible with the grid-like approach used in this library.
One way to be able to support this and maintain the grid-first approach that makes this library very approachable would be to provide a function like:
getRectangleNoiseValue(noise2: Noise2Fn,options: Options,x: number,y: number): number {
Which gets the 2D noise value at x and y, which can here be non-integer, non-positive, etc, but still describe the same surface as makeRectangle(..). makeRectangle(..) could then be adjusted to use the above function.
Extra Benefits
There are many other techniques that similarly make use of being able to sample arbitrary points. For example, calculating normals.
For situations in which the grid is too large to be stored in memory and it is better to iterate through and reduce.
Example
An example of how this could look is in this draft PR: #6. Let me know if you agree with the approach or would prefer changes (or disagree with its inclusion in this repo) and then it can potentially be finalised.
The text was updated successfully, but these errors were encountered:
Hi, I'd like to implement warping (e.g. https://iquilezles.org/articles/warp/) using this library. An example warping function is provided in that article. It looks like:
where
fbm(..)
is a fractal noise function that takes, in this case, a 2D vector and returns the noise value at that point. This example therefore deals with the same kind of noise asmakeRectangle(..)
infractal-noise-js
.This technique requires being able to get noise values at arbitrary points and is therefore not presently possible with the grid-like approach used in this library.
One way to be able to support this and maintain the grid-first approach that makes this library very approachable would be to provide a function like:
Which gets the 2D noise value at x and y, which can here be non-integer, non-positive, etc, but still describe the same surface as
makeRectangle(..)
.makeRectangle(..)
could then be adjusted to use the above function.Extra Benefits
Example
An example of how this could look is in this draft PR: #6. Let me know if you agree with the approach or would prefer changes (or disagree with its inclusion in this repo) and then it can potentially be finalised.
The text was updated successfully, but these errors were encountered: