MrSplosion

Member

23

100 Neutral

• Rank
Member
1. Improving Perlin Noise

Thank you guys! This works here's the best I've been able to make: I'll tweak it around but if anyone know a better or more efficiency way or whatever I'm open to anything.
2. Improving Perlin Noise

You mean like say if this value is under x make it white and if it's over x make it black? Because I've already thought about this and it doesn't quite have the desired look: It doesn't look clumpy enough if you will. Maybe it's because I should do this for every octave instead of just the summed up one? Or maybe there's more to it? Maybe instead of making each octave a value between 0 and 1 I make it a value of either 0 or 1. I just don't know.
3. Unity Improving Perlin Noise

So I've created perlin noise (with the help of the community) but I'm not quite finished yet. Here is what I've been able to produce (ignore the outlying pixels): With this accomplished I would now like to make it look more "cloudy". Where most of the image is white but there are certain spots with black. Like this: I checked out this article but It didn't work out very well as all I could accomplish was this: Yeah it looks pretty good and I've been tweaking the variables but nothing look as good as my picture. I would image the function for this would be pretty complex and I'm not a math wizard. So how can I accomplish this? Is it even possible? Thanks!
4. How to Implement Frequency into Perlin Noise

Thanks for the script but you don't seem to be looping through each pixel in the texture. Where would that go? Would this line get looped with the x and y parameters changing?: total += Smooth(x * frequency, y * frequency) * amplitude; Or perhaps the whole PerlinNoise2d(float x, float y) function gets looped with the x and y parameters changing?
5. How to Implement Frequency into Perlin Noise

Right it produces an all white texture with everything implemented exactly that script above. Oh and by the way it's only all white if persistence is 1 or higher else it's all black sorry for the confusion didn't think that would be a big deal. As for the other images not being all white that's because everything isn't implemented. In number 1 I said I fill a texture with random color values. That's all I did I looped through each pixel in the texture and assigned it a random color value nothing else, that's why it's not all white. Same thing for the other image, I didn't have frequency or amplitude I just smoothed it out with each octave. However with frequency and amplitude implemented yes, the texture is all white or black. I simply did not implement everything in order to better illustrate each answer.

7. How to Implement Frequency into Perlin Noise

What do you mean? That first one was about multiple octaves which got solved. The other one was about interpolating 2D noise which I'm still a little fuzzy on but think I got the hang of and this one is about frequency. Now that I think about it I should have probably made one thread but It would have been a little weird talking about one thing that doesn't have to do with the other. Sorry that offends you or whatever but there aren't many tutorials/articles/guides over this and a lot of them suggest I have a degree in math or don't quite go into enough detail. Not to mention each one does it a different way than the other.
8. Unity How to Implement Frequency into Perlin Noise

So I've been experimenting with Perlin Noise recently but I've encountered a problem that I can't figure out. Articles such as this say that frequency is implemented by taking 2 to the power of the current octave then you multiply x and y by that. As shown here: function PerlinNoise_2D(float x, float y) total = 0 p = persistence n = Number_Of_Octaves - 1 loop i from 0 to n frequency = 2i //2 to the power of the current octave amplitude = pi total = total + InterpolatedNoisei(x * frequency, y * frequency) * amplitude //multiply x and y by that end of i loop return total end function Adding this into my script doesn't work and I have no idea why it just gives me a pure white texture. My script uses Unity3D but don't worry you can easily tell what it's doing: using UnityEngine; using System.Collections; public class noise2 : MonoBehaviour { public int width; public int height; public int octaves; public float persistence; void Start(){ Texture2D texture = new Texture2D(width, height, TextureFormat.ARGB32, false); genorateWhiteNoise(texture); texture.Apply(); genorateSmoothNoise(texture); texture.Apply(); renderer.material.mainTexture = texture; } void genorateWhiteNoise(Texture2D texture){ System.Random random = new System.Random(0); //seed to 0 for testing for(int x = 0; x < width; x++){ for(int y = 0; y < height; y++){ float perlinValue = (float)random.NextDouble(); Color perlinColor = new Color(perlinValue, perlinValue, perlinValue, 1); texture.SetPixel(x, y, perlinColor); } } } void genorateSmoothNoise(Texture2D texture){ for(int o = 0; o < octaves; o++){ int frequency = Mathf.Pow(2, o); //same thing as above take 2 to the power of the current octave float amplitude = Mathf.Pow(persistence, o); for(int x = 0; x < width; x++){ for(int y = 0; y < height; y++){ float perlinValue = noise2D(x * frequency, y * frequency, texture) * amplitude;//multiply x and y by that Color perlinColor = new Color(perlinValue, perlinValue, perlinValue); texture.SetPixel(x, y, perlinColor); } } } } public float noise2D(int x, int y, Texture2D t){ Color corners = (t.GetPixel(x-1, y-1) + t.GetPixel(x-1, y+1) + t.GetPixel(x+1, y-1) + t.GetPixel(x+1, y+1))/4; Color sides = (t.GetPixel(x-1, y) + t.GetPixel(x+1, y) + t.GetPixel(x, y-1) + t.GetPixel(x, y+1))/4; Color center = t.GetPixel(x, y); return (corners.r + sides.r + center.r)/3; } } Could I get help on implementing frequency into my script? Thanks!

10. Creating Perlin Noise

So I've been experimenting with perlin noise but I'm having trouble adding multiple octaves together. There aren't that many sources out there and articles such as this and this don't quite go into enough detail. The first article I linked really doesn't talk about it at all and the other says I should make a array of both an x and y number then multiply it by 2 squared by the current octave. I've tried this method but haven't had any success. I'm confused could someone please help me or go into more detail about adding multiple octaves together? Script: function PerlinNoise(){ var texture = new Texture2D(width, height, TextureFormat.ARGB32, false); for(q=0; q<=width; q++){ for(w=0; w<=height; w++){ var a = Noise2d(q, w); var b = new Color(a, a, a, 0); texture.SetPixel(q, w, b); } } texture.Apply(); renderer.material.mainTexture = texture; } function Noise2d(x : int, y : int){ var n; n = x + y * 57; n = (n<<13) ^ n; var res = (1.0 - ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0); return res; } Pics Thanks!
11. Creating Perlin Noise

I see, thanks for the help! I will use this to make multiple octaves then try to combine them together. Chances are I'll ask another question but interpolating doesn't too difficult.
12. Creating Perlin Noise

That's what having multiple octaves are for. It sounds to me like you're only doing one octave. You should be doing multiple octaves, and then sum each octave up (but each successive octave has a higher frequency and a lower amplitude). Are you getting stuck on how to combine the octaves/making each successive octave have a higher frequency and lower amplitude?  On second thought, is it the interpolation method you're struggling with? Because you need to interpolate between the octaves as well. I know there can be a lot of new terms when it comes to making perlin noise (octaves, amplitude, frequency, interpolation, etc.), but I'm not sure which one of them it is you're struggling with so I'm not sure exactly what more to say. [/quote] Ah! I see what you're saying quick question though: In the link you provided why is all that necessary? I bet if you just simply looped though each pixel and randomly picked if it was black or white it would look the exact same. Or is there more to it? Does each pixel have a certain color to it or is it just binary black or white?
13. Creating Perlin Noise

That's pure noise though, I want smooth coherent noise such as: Sorry probably should have made that more apparent.
14. Creating Perlin Noise

Ok, so I've been having difficulties on how to implement 2D perlin noise in my game. The problem that the articles I've read such as this and this really don't explain the concept very well. The best article I've found is this, however I still think it doesn't go into enough detail, plus there different methods. I want to turn a texture into perlin nose. From what I understand (please correct me if I'm wrong and keep in mind I'm discussing 2D noise) you need a function that takes in a x and y grid point and returns a value with which you can then use for the gray-scale of that point or pixel in the texture. So I would loop through every pixel in my texture and assign it a gray-scale value using the function. Generating this color value is the hard part though. Again correct me if I'm wrong but I'm pretty sure you use the grid points and make a random number out of it between 0 and 1. Let's just use (2, 4) as an example. First I need a number to give the generator, how about the average of the two points? So I put in 3 and it gives me something like 0.634. After this I get completely confused because I need to check the neighboring values and have that effect my value 0.634 right? If I don't It will look completely random and not have "patches" of a color somewhere. Nothing explains how to do this well and I need help badly!!! Could someone please explain this concept to me in a little bit better detail? Thanks!
15. Can't Seek Over Pre-existing Data?

I can't prepend data? So there is no way to simply move the pointer somewhere and start writing without deleting whats after the pointer? I can only do it in some other mode other than append mode which will deleting whats after the pointer? And yes I'm using System.IO.StreamWriter.