PerlinNoise | 1D/2D/3D Perlin noise function for Unity | Game Engine library

 by   keijiro C# Version: Current License: No License

kandi X-RAY | PerlinNoise Summary

kandi X-RAY | PerlinNoise Summary

PerlinNoise is a C# library typically used in Gaming, Game Engine, Unity applications. PerlinNoise has no bugs, it has no vulnerabilities and it has low support. You can download it from GitHub.

This is straight implementation of the Perlin noise function for Unity, which is based on Perlin’s SIGGRAPH 2002 paper "Improving Noise". You may use the script (Perlin.cs) in your projects freely.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              PerlinNoise has a low active ecosystem.
              It has 266 star(s) with 54 fork(s). There are 16 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 0 open issues and 3 have been closed. On average issues are closed in 1 days. There are 1 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of PerlinNoise is current.

            kandi-Quality Quality

              PerlinNoise has 0 bugs and 0 code smells.

            kandi-Security Security

              PerlinNoise has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              PerlinNoise code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              PerlinNoise does not have a standard license declared.
              Check the repository for any license declaration and review the terms closely.
              OutlinedDot
              Without a license, all rights are reserved, and you cannot use the library in your applications.

            kandi-Reuse Reuse

              PerlinNoise releases are not available. You will need to build from source code and install.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of PerlinNoise
            Get all kandi verified functions for this library.

            PerlinNoise Key Features

            No Key Features are available at this moment for PerlinNoise.

            PerlinNoise Examples and Code Snippets

            No Code Snippets are available at this moment for PerlinNoise.

            Community Discussions

            QUESTION

            Multiprocessing only utilizing a single core
            Asked 2021-May-27 at 10:24

            I'm trying to create a FBM texture using the module perlin-noise, but it takes a very long time to execute. I've implemented multiprocessing, only to find that the program was still running off a single core. I've tried looking for other people with the same problem, but most threads were 7+ years old and / or involved problems and solutions related to different OSs.

            My OS is Windows 8.1, I have a quad-core CPU, and I'm running Python 3.9.2

            Here is the program:

            ...

            ANSWER

            Answered 2021-May-27 at 10:24

            Reason why it only use one Process is simple. You only passed 1-length list in Pool.map.

            What Pool(n).map(function, iterable) does is, applying provided funtion to each element of provided iterable(in this case, list) with n number of worker processes.

            Since you only have 128 in nums it's only creating one task thus no other processes are ever used.

            Proper usage would look like this:

            Source https://stackoverflow.com/questions/67719075

            QUESTION

            Two different Vector3.zero's, but no parent?
            Asked 2021-Apr-16 at 09:45

            UPDATE

            I found out that the mesh center of the mesh object is not at 0,0,0. Does that do anything?

            I have the following problem. I am generating a terrain from Perlin noise and that works fine. However, as soon as I try to instantiate any objects on it, some are spawned in the terrain area and some completely outside. When I reset the object's transform, it teleports to (0,0,0) as expected, but when I reset another object, that was not instantiated at runtime, the (0,0,0) is at a completely different location! I have no parent set to these objects and no parent set to the other object as well. Below is my code for generating the objects:

            ...

            ANSWER

            Answered 2021-Apr-16 at 09:35

            I have no parent set to these objects and no parent set to the other object as well.

            Actually, you do set parent:

            Source https://stackoverflow.com/questions/67109025

            QUESTION

            How Do I Generate Procedural Cube Asteroid Formations?
            Asked 2021-Mar-11 at 20:06

            I'm trying to find the best way to generate perlin-noise-based cube voxel asteroids, but cannot seem to find a consistent method to do so.

            I've tried to use this perlin noise library: https://github.com/warmwaffles/Noise/blob/master/src/prime/PerlinNoise.java

            Along with this static method to get 3D noise out of it:

            ...

            ANSWER

            Answered 2021-Mar-11 at 20:06

            I'm not quite sure exactly what you are doing so I'll just tell you how I generally do it. My voxels use some variation of marching cubes so I'll change it a bit to suit what you're doing.

            First you can loop though all your voxels and take the center point. Then normalize it. I'm assuming your asteroid has (0.0,0.0,0) in the middle, if not just offset everything. In any case that gives you points around a unit sphere. You can then multiply those points by some constant to get a bigger sphere of points, like say 5 or 10. The bigger the number the higher the frequency of your noise. Play with it until it looks good to you. Next plug those points in 3D nose, Perlin or simplex. Simplex is generally better. This will give you a value from around -1 to 1 for every voxel.

            Then you just need to have a base radius for your asteroid. For instance if your voxels go from -10 to +10 in all dimensions you can use a base radius of say 8. If you add that to your noise you get values of roughly 7 to 9 for every voxel all the way around the sphere. If the distance of the center of a voxel to the origin is less than it's calculated number it's solid. If it's greater, it's non-solid. Bingo you're done.

            You can also scale your noise up and down to give you higher peaks and lower valleys. And then there are various ways to combine noise to get a lot of different kinds of terrain. The Ridged Multi-Fractal is one of my favorites. With low resolution it's not so important however since you won't see the details anyway.

            Source https://stackoverflow.com/questions/66582835

            QUESTION

            Tricky Perlin Noise Question. How does the Grad Function Use Normalized Vectors?
            Asked 2021-Jan-03 at 01:16

            I'm currently in the process of understanding improved Perlin noise. I understand the theory entirely however, I am confused by an aspect of its common implementation, such as this.

            My question is, how does the grad() function return the dot product of normalized vectors (gradient and direction)? What I mean is that the dot product of normalized vectors has a range of -1 to 1 which is the normal output of Perlin noise after blending (fading) all dot products together. But the vectors which undergo the dot product are not normalized (none of the gradient functions are nor are the direction vectors). So, how does the output fall within the -1 to 1 range?

            My only guess is that the gradient vectors all have a magnitude of root 2 and that all axes of the direction vectors are in the range of -1 to 1. So, I assume this is why the Perlin noise output ultimately falls within the -1 to 1 range. Is this why? Can anyone prove or find a proof?

            Thanks guys

            ...

            ANSWER

            Answered 2021-Jan-02 at 22:52

            In the article you linked, the grad() function returns a dot product of two vectors, but I don't see what leads you to say these vectors are expected to have unit magnitude. The sampling position may be continuously anywhere in the cube. Supposing a cube of unit size, the distance vector to the sampling position could have magnitude between 0 and sqrt(3). So, it looks like ||gradient vector|| = sqrt(2) and ||distance vector|| ≤ sqrt(3), bounding the output of grad() between −sqrt(6) and +sqrt(6) (≈ 2.45).

            Source https://stackoverflow.com/questions/65540146

            QUESTION

            Unity: Is Mathf.PerlinNoise consistent across all implementations / devices / platforms?
            Asked 2020-Aug-31 at 13:09

            If I create a game in Unity that is played on Windows / Mac / Android etc. is there a guarantee that,

            For each pair of x and y, Mathf.PerlinNoise(x,y) is same for every device running the application around the world?

            ...

            ANSWER

            Answered 2020-Aug-31 at 13:09

            Yes.

            See Mathf.PerlinNoise

            Any point in the plane can be sampled by passing the appropriate X and Y coordinates. The same coordinates will always return the same sample value [...]

            Source https://stackoverflow.com/questions/63667297

            QUESTION

            How to smooth between multiple perlin noise chunks?
            Asked 2020-Aug-15 at 19:02
            Smoothing Between Chunks

            So I've been working on a game in unity and want to expand my world from a 150x150 map into a seemingly infinite procedural world. My plan is to use Perlin Noise as the base and use the different values from 0-1 to determine the terrain type. The issue I'm running into is when I draw out my chunks and offset accordingly my chunks do not line up correctly, which kind of break the illusion of an infinite world.

            (seen here)

            WorldChunk.cs

            ...

            ANSWER

            Answered 2020-Aug-14 at 07:01

            The key word you are looking for is tileable.

            But I have a great news for you, noise function such as perlin are periodic in nature. So instead of calling ChunckSize * ChunkSize a noise function you should only call it once and then divide the results.

            I will advice you to read this excellent tutorial:

            https://www.scratchapixel.com/lessons/procedural-generation-virtual-worlds/procedural-patterns-noise-part-1/creating-simple-1D-noise

            Source https://stackoverflow.com/questions/63407212

            QUESTION

            My Perlin Noise function having too many dark spots, and little strips of white
            Asked 2020-Aug-14 at 18:13

            I created a Perlin noise function by loosely following a java tutorial in C#. I then used Unity to visualize it (I don't think the issue is with unity, as their inbuilt func works perfectly)

            The problem is that there are too many large dark spots. Here is a photo

            This is how I would like it to look

            As you can see, it looks as if the points are not blending well.

            Here is my code for the noise:

            ...

            ANSWER

            Answered 2020-Aug-14 at 18:13

            It's the gradient set being used. Directions (1, 1) point directly at diagonal neighbors. If those diagonal neighbors have (-1, -1), then they constructively interfere. Same for other corner pairs, and for when they point negative instead of positive at each other. EDIT: You can try +x + ROOT2*y, +ROOT2*x + y, and all sign permutations thereof, to produce 8 gradients.

            Also, even if you improve the gradients, you may have heard that Perlin is an older method for noise, which produces a lot of 45 and 90 degree bias. There aren't a lot of cases where I recommend it. If you want to implement noise as a programming exercise, that's great. But if you want to use noise in a project, I would either code or import a good 2D simplex implementation.

            EDIT: See comments. I looked at the wrong image. Solution you need, is only sample = sample * 0.5 + 0.5 to rescale the output so that the negative values don't all get cut off in the image.

            Also if you want to convert your noise into a rudimentary simplex, you can do this:

            1. Define constants double F2 = 0.366025403784439 and double G2 = -0.211324865405187. These will be used below, to work with the triangular grid.
            2. At the beginning of GetPixel(double x, double y) add double s = (x + y) * F2; x += s; y += s;. This will convert the coordinates which produce integers on a square grid, to coordinates which produce integers on a diagonally-compressed square grid which represents equilateral triangles.
            3. After you define xdec and ydec, add double t = (xdec + ydec) * G2; xdec += t; ydec += t;. This will unskew these coordinates relative to the base of the compressed square, so that they can now be used for distance and gradients again.
            4. Define doubles xdec2 = xdec - 1 - G2; ydec2 = ydec - G2;. Define xdec3 = xdec - G2; ydec3 = ydec - 1 - G2;. Define xdec4 = xdec - 1 - 2*G2; ydec4 = ydec - 1 - 2*G2;. You need this, because simply subtracting 1 doesn't work anymore to get the relative coordinates to the other four corners, because the corners aren't aligned with a square anymore. Now, any time you subtract 1 from either of the coordinates, you also need to subtract G2 from both. Thus, for #2 and #3 you subtract G2 once from each, and for #4 you subtract it twice (2*G2). You can re-derive this yourself by seeing what happens if you had already subtracted 1 from one or both of the coordinates, before calculating the previous step where you define double t.
            5. Change d2, d3, d4 to use these values instead, like d2 = grad(g2, xdec2, ydec2);
            6. Remove everything starting with double u and ending with return yInter;. Add double value = 0;. You will add stuff to this value.
            7. Define double a1 = 0.5 - xdec*xdec - ydec*ydec; double a2 = 0.5 - xdec2*xdec2 - ydec2*ydec2; and the same pattern for a3 and a4. These functions represent circles around each triangle vertex, which stop at the triangle edges.
            8. Add if (a1 > 0) value += (a1 * a1) * (a1 * a1) * d1; and the same for a2, a3, a4. These add a value to the noise inside each of those circles, based on the gradient and distance.
            9. If you use the improved gradients I suggested for Perlin, add return value * 38.283687591552734375;. If you use the original ones, I think the right value to multiply by is 75.3929901123046875 but I'm not sure. It will be something close to that, though. Really, you probably want more gradients for simplex, but the 8 should make it look better than Perlin at least.

            The noise will not look very good without the improved gradients. You will still see a lot of 45 degree bias. If you want to really improve the noise, here is my suggestion, with 24 gradients. You can find these gradients here. Use 99.83685446303647 as the value you multiply by at the end.

            Source https://stackoverflow.com/questions/63321155

            QUESTION

            does Mathf.PerlinNoise() rely on the internal random number generator?
            Asked 2020-Jul-16 at 17:26

            I am using Unity c#, and I am coding something that relies on Perlin noise to determine a random number between 0 and 1. I would like to implement a feature in my code that allows the user to define a specific pre-determined seed number to use for this, but I am not sure if the Perlin noise function actually uses the same random seed as the Random class does.

            For example; if I want to generate Perlin noise using Mathf.PerlinNoise() - will it always be the same if I always set the RNG seed priory, using the same number?

            minimal code example:

            ...

            ANSWER

            Answered 2020-Jul-16 at 17:26

            The two are not related!

            The only thing that Random.InitState changes is the way how e.g. Random.Range or Random.value work.

            Without using it it would simply use values based on the system time instead.

            Mathf.PerlinNoise is not connected to that. You can actually try different seeds and always see the same perlin result. This is actually stated in the API

            The same coordinates will always return the same sample value but the plane is essentially infinite so it is easy to avoid repetition by choosing a random area to sample from.

            They already give you a hint how to solve your problem: Use a different offset!

            Now here comes your seed into play: Simply choose a random offset based on the seed -> random but always equal for the same seed!

            Source https://stackoverflow.com/questions/62939798

            QUESTION

            Random float using coordinate as seed
            Asked 2020-Jul-09 at 09:13

            The Mathf.PerlinNoise(float x, float y) function returns a float that I use. I want a more completely random function that can use coordinates as it's seed.

            My ideal would have the exact same input and output as the aforementioned Mathf.PerlinNoise function, . The point is that it can be switched out with the Perlin Noise function to return completely random floats that return the same float for any given coordinate each and every time.

            ...

            ANSWER

            Answered 2020-Jul-09 at 09:13

            So your question consists of 2 problems:

            1. Create a seed from the 2 float values that always maps the same input to the same seed.

            2. Using a seed to generate a random float.

            For the first problem this can be solved by creating a hashcode, there are different ways to do it but I'll refer to this answer by John Skeet for more information on that. For you the hashing would look like this:

            Source https://stackoverflow.com/questions/62810801

            QUESTION

            CoreImage: CIColorKernel.init with .metallib causes EXEC_BAD_ACCESS
            Asked 2020-Jul-08 at 22:38

            I've made a Perlin Noise filter for CoreImage using Metal Shader Language. My first version of it works fine, and allows me to specify 2 colors to use as the low and high. My next step is to allow it to accept a color map such that it can produce multi-color output. The color map version compiles fine, but when my CIFilter subclass tries to create a CIColorKernel from it using the init(functionName:fromMetalLibraryData:) method, I get an EXEC_BAD_ACCESS with code=1. Any idea what about my color map implementation might be causing this?

            Here's the simple, 2-color version:

            ...

            ANSWER

            Answered 2020-Jul-08 at 22:38

            Based on Frank's comment, I reverted my Perlin Noise filter to its original, functional state and instead applied the color map as a following step using this improved version of the CIColorMap filter which can generate its own gradient image based on a [CGFloat: CIColor] dictionary.

            Source https://stackoverflow.com/questions/62780170

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install PerlinNoise

            You can download it from GitHub.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/keijiro/PerlinNoise.git

          • CLI

            gh repo clone keijiro/PerlinNoise

          • sshUrl

            git@github.com:keijiro/PerlinNoise.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular Game Engine Libraries

            godot

            by godotengine

            phaser

            by photonstorm

            libgdx

            by libgdx

            aseprite

            by aseprite

            Babylon.js

            by BabylonJS

            Try Top Libraries by keijiro

            AICommand

            by keijiroC#

            Skinner

            by keijiroC#

            KinoGlitch

            by keijiroC#

            AIShader

            by keijiroC#

            Kino

            by keijiroC#