Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (535)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Noise (bandpassed white)  (Read 34987 times)
0 Members and 1 Guest are viewing this topic.
Offline Wiki Duke

?





« Posted 2012-08-10 10:42:04 »

Note: you are watching revision 5 of this wiki entry. ( view plain diff )
Stub for Perlin-like and value noise.

Theoretical background stuff (that isn't useless)
White noise is like what one hears on a radio tuned to no station.  It's also like old broadcast TVs on a channel with no signal.  Generation a 2D texture of white noise is easy..just use any reasonable random number generator and set each pixel to a random value.  But white noise isn't really very useful in creating content.  What we really want is to be able to create random numbers, but random numbers that aren't totally independent of one another.  What was want is to approximate a bandpass filtering of white noise.  What? you cry!  Sadly to explain requires a touch of notions from signal processing.

Some dude figured out that all signals can be exactly recreated by summing up an infinite number of functions.  Originally considered were sinusoids (a.k.a sin or cos).  A sine or cosine on a given amplitude is a nice pair of spikes in the frequency domain. (umm..forgot I said that if not clear)  Here there some nice little pictures of creating a square wave out of sinusoids.  Hand-wavingly what you do is add together different (say) sine evaluations of different amplitudes, frequencies and phase shifts:  Ai sin(Fix + Si) to approximate the final signal (you need an infinite number to get it exact).

This is the basic notion behind signal processing.  Generally in signal processing you take an existing signal and modify it for compression, some effect or whatever else.  In terms of noise we want to do the opposite and procedurally create a signal.  Instead of using sin or cosine as our "building block" we're going to use an approximation of band-pass filtered white noise.  Roughly the notion of the band-pass filtering is that we want a narrow range of frequencies for our building block so (like in the sin/cos example) we can vary the amplitude, frequency and phase shift of our function and combine some number of them together to create a signal.

Why bring any of this up?  It's simple.  The various noise functions all have some defects and additionally some are better at approximating band-pass filtering than others.  Additionally they will have different distributions of amplitudes and frequency ranges.  This boils down to you can't easily change between different noise functions as all you're neat effects would require at least tweaking if not a total rewrite.  Now the issue with how good a given function is at band-pass filtering comes into play because (roughly speaking) the better it is at the filter, the less summation (evaluations of noise) is required to create the same complexity.  The classic example here is that value-noise is very cheap to evaluate and so many people will use it when they would be better off using a more expensive function and

(still thinking here)
This wiki entry has had 21 revisions with contributions from 2 members. (more info)
Offline Roquen
« Reply #1 - Posted 2012-08-10 20:17:29 »

OK.  Does my first pass at the theory and why I've put it there make sense to someone that knows zero about signal processing?
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #2 - Posted 2012-08-14 20:36:00 »

I'm getting the general gist of it, but I have to admit I know a thing or 2 about signal processing.
But my general feeling about the article is that it kind of covers too many things at once at a purely theoretical level without being very practical.
Perhaps you could try targeting it to a developer with a specific need, for example procedural texture generation, hight-map generation, or some other procedural content generation. And then explaining why a certain noise algorithm would make sense in that particular case.

I'm trying to deride your article (in fact I'm very interested in the subject), but I feel it covers too many areas to be useful in just one wiki article.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Best Username Ever

Junior Member





« Reply #3 - Posted 2012-08-18 21:37:14 »

I think people that don't already know the subject will be lost. What's the purpose of bandpass filtering? Isn't the goal of certain noise algorithms to achieve a subjective aesthetic effect?
Offline pjt33
« Reply #4 - Posted 2012-08-19 00:59:13 »

To someone who knows a bit about signal processing, it raises a number of questions. E.g. did you intend your description of decomposition in terms of basis functions to be broad enough to include Taylor expansion? Would it be worth defining "signal"? Does it make sense to talk about Fourier analysis of non-periodic functions in an introduction to noise?

Someone who doesn't know anything about signal processing is guaranteed to not know what you mean by the frequency domain. They may also pick up on the Gibbs phenomenon in the pictures about creating a square wave, and wonder whether it contradicts what you're saying. And they won't have a clue what "band-pass filtered" means.
Offline Roquen
« Reply #5 - Posted 2012-08-19 15:10:17 »

Well talking in a hand waving kinda way about signal processing is tricky.  I guess the more important question is if it's even worth talking about at all? 
Offline keldon85

Senior Member


Medals: 1



« Reply #6 - Posted 2012-08-19 17:46:27 »

I've seen some sensational shaders making use of perlin noise to make some really convincing wood textures, and for scene generation it helps to have a little taste for different ways of producing controlled modulation.

Though it would help if we could arrange the structure a little to be more helpful in some way because this is a very useful topic to be covered.

Offline philfrei
« Reply #7 - Posted 2012-08-19 23:15:48 »

I'm trying to get better acquainted with using noise in textures right now, grappling with it conceptually, having just had my first working experience with calling Simplex noise to assemble a cloudy texture.

I'm not at all clear that getting into Fourier analysis is helpful. I can see where using 'harmonics' can make the coding neater, and it seems to work well with the mathematics of fractals, but it doesn't seem to be entirely necessary. One can add noise that has energy at frequencies that are unrelated to the base frequency with no problem. Visual textures are not like sound waves, where one deals with the prevalence nodes and anti-nodes and standing waves in the "real world," and the ear and hearing portions of the brain has evolved to make use of data in this form.

So, is it simpler, instead, to describe noise as having components that are at various periods, and not worry about the Fourier analysis, at least, at the "beginner" level? Or are techniques to analyze textures to determine their strongest component frequencies in use and an important part of creating textures?

I'm thinking, for a dimension, given a length L and a value "n" along that length, a "basic" unit of noise might be of length n/L. Since n can go from 0 to L, the result of this fraction is 0 to 1. One can multiply this value by different factors to get different degrees of scaling. Obtaining noise with (n/L * K) will be K times more detailed than noise at n/L.

But we are free to make K whatever we want. K can be a float or double. It doesn't have to be an integer or a progression of integers.

(We might also talk about how to "relate" the periodicity of one type of noise to another via a scaling factor that is applied to the n/L (O to 1) results of the different noise generation techniques? Maybe this is already done?)

Then, there is total latitude with what we do with the output noise values (which range from -1 to 1), whether to sum them or lerp them, or use them in trig functions. It seems wide open, as long as the function results in a legal Color value for a pixel.

(It occurs to me, one could also talk about a more concrete value the periodic nature of noise by finding a number of pixels that corresponds to an average of one swing in the random number. But I think I am getting into fuzzy thinking, as I don't know how to describe a "period" of randomness, and the way in which we relate the numbers to pixels on the screen is so fluid.)

As I said, I'm a beginner with using noise, and am happy to be corrected on any point.

"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Offline Roquen
« Reply #8 - Posted 2012-08-20 07:51:21 »

Doing octaves is exactly construction that's obvious in the frequency domain and one reason why I thought this might be useful.  I'm thinking about a complete different track that describes as coherent pseudo-random numbers and walking though the historic progression of how they work.  Detailed usage is a ton of work and was thinking that provide a bunch of links would be reasonable for a first pass.  (plus I'm too lazy to make pictures)
Offline keldon85

Senior Member


Medals: 1



« Reply #9 - Posted 2012-08-21 00:20:55 »

Hmm, when generating textures like clouds and terrain it helps to know a little about the effects of noise colouring, distortion and how it can be fun to mess around with to produce different results.

And thinking back to clouds, isn't the very reason you see clouds down to the low frequency bias, with the overtones creating the fuzziness.

I think it would help to show the differences visually though, or even better yet, produce an app to demonstrate it. I learned a lot just by tweaking my 2d noise generator. This could be the difference between generating really mundane levels or elaborate worlds that feel like they've been really well designed  IMO.

I agree with what philfrel said about having components at various periods, and experimentation is key. When I was at uni I remember toying around rending series upon series of sine waves, some directional, some radial, until (*I swear*) it looked like plasma. Of course that wasn't the memorable part, the memorable part was when I made a few small modifications and ... err ... it stopped looking awesome and had to investigate and figure out what on Earth was going on Cheesy Still don't know how I did it Sad

In terms of good, I think it's key to remember that these random values can be feeding into game behaviour. This could be what gives flavour to your map generation algorithm. The more applicable and relative to games the examples are the more that people will digest and be able to use it.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Roquen
« Reply #10 - Posted 2012-08-21 11:52:06 »

No doubt experience is all important for creating effects and the theory is of marginal use.  My thinking is more geared toward choosing what set of base generators to use.  Precomputed effects is easy:  improved gradient if you want to quickly bang stuff out based on other peoples work (as pretty much everything is written to gradient noise) and/or simplex noise.  The 'better' noise methods are too expensive for fast turn around to be useful IHMO.  The trickier part is for runtime generated stuff.
Offline Roquen
« Reply #11 - Posted 2012-08-23 15:27:44 »

OK. I made a first pass at a second pass.  Any better or still wankery?
Offline philfrei
« Reply #12 - Posted 2012-08-23 19:48:52 »

Many improvements!  Smiley

"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Offline Roquen
« Reply #13 - Posted 2012-09-27 16:59:16 »

Fixed some typo's.  Completed "brief" and added a sketch for gradient noise.
Offline philfrei
« Reply #14 - Posted 2012-09-27 20:40:00 »

Would love to get some more feedback as to what can be done to make the visualizer I started [http://www.java-gaming.org/topics/simplex-noise-experiments-towards-procedural-generation/27163/view.html] something you'd consider adding as a link on the main page of this wiki.

P.S., I'm seriously looking at "open sourcing" the project on GitHub, making the emphasis more on helping devs write and test a wider range of textures. (Just figured out "perspective" but haven't integrated it yet.)

"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Offline matheus23

JGO Kernel


Medals: 106
Projects: 3


You think about my Avatar right now!


« Reply #15 - Posted 2012-09-27 20:44:52 »

P.S., I'm seriously looking at "open sourcing" the project on GitHub, making the emphasis more on helping devs write and test a wider range of textures. (Just figured out "perspective" but haven't integrated it yet.)
This is almost always a very good idea! Do this, (I'd be intrested too Smiley but mind licensing!)  Grin

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline Roquen
« Reply #16 - Posted 2012-09-27 21:52:34 »

Hey, it's a wiki...do it yourself!  Seriously I was thinking this is getting about as long as is reasonable and that talking about basics of using noise should be on another page and have code-snippets like your tutorial.  There no reason why your tool shouldn't be linked from both.
Offline philfrei
« Reply #17 - Posted 2012-09-27 23:38:53 »

Doh! Looky there. A "modify" button on the first post.

"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Offline Roquen
« Reply #18 - Posted 2013-04-05 17:36:37 »

Tossed together a quick WebGL demo (link in overview).
Offline matheus23

JGO Kernel


Medals: 106
Projects: 3


You think about my Avatar right now!


« Reply #19 - Posted 2013-12-27 12:55:10 »

Quote
So to compute value noise in 'n' dimensions, the work required is related to n2 (1D = line segment or 2 vertices, 2D = square or 4 verts, 3D = cube and 8, etc)

Shouldn't it be 2^n? I'm not sure that's why I'm asking...

1  
2  
3  
4  
5  
1D = 2^1 = 2 vertices
2D = 2^2 = 4 vertices
3D = 2^3 = 8 vertices
4D = 2^4 = 16 vertices
...


Yeah. Pretty sure now.

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline Roquen
« Reply #20 - Posted 2013-12-27 13:52:04 »

I'm seeing 2^n in what you've quoted...check your browser and/or the source that you're seeing.  I see that it's wrong in the simplex noise part though (reading n^2)...sigh.
Offline matheus23

JGO Kernel


Medals: 106
Projects: 3


You think about my Avatar right now!


« Reply #21 - Posted 2013-12-27 13:52:36 »

I'm seeing 2^n in what you've quoted...check your browser and/or the source that you're seeing.  I see that it's wrong in the simplex noise part though (reading n^2)...sigh.

Yeah, I've modified it in the first part already ^^

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline Roquen
« Reply #22 - Posted 2013-12-27 14:59:25 »

Wait!  You...fixed....it...and Wait!  You corrected the second error as well?  Someone understands the concept of a wiki!  I'm so happy I could cry.  (nice catch).
Offline matheus23

JGO Kernel


Medals: 106
Projects: 3


You think about my Avatar right now!


« Reply #23 - Posted 2013-12-27 15:09:25 »

Wait!  You...fixed....it...and Wait!  You corrected the second error as well?  Someone understands the concept of a wiki!  I'm so happy I could cry.  (nice catch).

Glad to make someone happy Grin

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Pages: [1]
  ignore  |  Print  
 
 

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

E.R. Fleming (20 views)
2014-07-29 03:07:13

E.R. Fleming (8 views)
2014-07-29 03:06:25

pw (39 views)
2014-07-24 01:59:36

Riven (39 views)
2014-07-23 21:16:32

Riven (26 views)
2014-07-23 21:07:15

Riven (28 views)
2014-07-23 20:56:16

ctomni231 (59 views)
2014-07-18 06:55:21

Zero Volt (50 views)
2014-07-17 23:47:54

danieldean (42 views)
2014-07-17 23:41:23

MustardPeter (45 views)
2014-07-16 23:30:00
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!