|
|
View previous topic - View next topic |
Author |
Message |
RuneLancer Mage
Joined: 17 Jun 2005 Posts: 441
|
Posted: Sun Oct 23, 2005 12:47 am Post subject: Procedurally-generated media |
[quote] |
|
[This is partly an article/tutorial, partly a discussion on the subject of procedural content generation. Since most of the forum seems to polarize around various filth and filthy individuals lately, a little more developement meat wouldn't hurt.]
Procedurally-Generated Media
If you've been any interested in the demo scene, you've seen it: a program that contains more media than you'd expect to reasonably find in its mere handfull of kilobytes. Examples include the visually stunning Heaven 7 raytracer, and the legendary ".produkt" demo, both of which generate enough media to fill a CD but are small enough to fit on a disk - the floppy single-sided 5 1/2" kind. Another example is pouet.net's first-place-winning tube demo: a mere 256 bytes!
The trick here is to generate the media on the fly, obviously. No amount of compression currently exists that can compress a CD's worth of data into 64k, nor can there ever reasonably be such a tight compression. This is acheived mainly through noise-generation.
What Is A Noise Function?
A noise function is, basically, a seeded random number generator. Given a "seed," it generates a "random" number. You give it 45, it returns 4921. You give it 13, it returns 1592. You give it 45 again, it returns 4921. It's important to note that a noise function, given the same seed, will always return the same value. Hence why "random" is in quotes: the result would more likely be called unpredictable.
When generating media with noise, the noise function would "seed" the content by generating a few basic points here and there. Imagine tracing 'x' random dots along a graph: this is what the noise function returns (the y of the dot) if the x of the dot is fed into it. If you draw them too close by and link them together with a straight line, you get a zig-zag mess. If you space them out enough and interpolate between them with smooth curves, you get something much nicer...
1D Noise
What the noise function generates, when graphed, is 1D noise. Uninteresting noise, however. Chances are your dots are somewhat distant along your graph, and you get a smooth, boring irregular slope.
If you use the same noise function but flatten it (reduce the amplitude of the wave) and stretch it (increase the frequency), then overlay it over your previous wave, you get... a mess. :) But if you average the two, your initial boring curve becomes more complex and interesting. Suppose you generate 4 sample curves this way, reducing the amplitude and increasing the frequency, then average them, what do you get?
Pretty bad image, I know; I did that almost on the fly. Though it's hard to tell here, the slope is generally fractal in nature, but not chaotic.
This can be applied to a 2D grid the exact same way.
2D Perlin Noise
Well... what is there to say? The technique's the same as 1D noise, but applied over a 2D area instead of a 1D curve.
These are the basics of perlin noise-generation. The application of perlin noise relies a lot on creativity.
Creating Textures
The most common use of Perlin Noise is to generate textures. Since the base code can be reused, literally thousands of textures can be generated with very little code, and thus using very little space.
Varying the degree of blending and the amount of samples generated can lead to smoother textures or rougher, more chaotic pools of colors. Applying a palette can give quite a nice feel to these textures.
Creating Maps
Perlin noise can create 2D maps very easily. Making a heightmap out of it comes to mind. Using 3D perlin noise to create clouds is another possibility (or 3D caves, by giving walls and walkable regions a certain "threshold".)
Movement and Animation
1D perlin noise can generate a wave that can be applied through a model to make it bob around in a life-like manner. Say, a character model standing still. A person standing still is likely to move about and not stand perfectly still: perlin noise is perfect for this kind of thing.
Working on some japanese hentai project with tentacled creatures and innocent schoolgirls? What better way to make your tentacled demon bob about and wave its tentacles than with perlin noise!
Closing Words
http://mrl.nyu.edu/~perlin/
This page is your god. Ken Perlin has a number of java applets showing off the potentail of perlin noise. Give it a look if you want to see hands-on examples of perlin noise use. _________________ Endless Saga
An OpenGL RPG in the making. Now with new hosting!
|
|
Back to top |
|
|
Nephilim Mage
Joined: 20 Jun 2002 Posts: 414
|
Posted: Sun Oct 23, 2005 2:10 am Post subject: |
[quote] |
|
That's fun. Have you ever experimented with using Perlin noise to generate landscape terrain? _________________ Visit the Sacraments web site to play the game and read articles about its development.
|
|
Back to top |
|
|
RuneLancer Mage
Joined: 17 Jun 2005 Posts: 441
|
Posted: Sun Oct 23, 2005 2:16 am Post subject: |
[quote] |
|
It generates pretty neat results.
(This was written in about a half hour, so it's shoddy at best. The map was normalised and smoothened out, too.) _________________ Endless Saga
An OpenGL RPG in the making. Now with new hosting!
|
|
Back to top |
|
|
biggerUniverse Mage
Joined: 18 Nov 2003 Posts: 326 Location: A small, b/g planet in the unfashionable arm of the galaxy
|
Posted: Sun Oct 23, 2005 3:11 am Post subject: |
[quote] |
|
Perhaps the best landscape renderer every created uses perlin noise extensively.
Terragen _________________ We are on the outer reaches of someone else's universe.
|
|
Back to top |
|
|
DeveloperX 202192397
Joined: 04 May 2003 Posts: 1626 Location: Decatur, IL, USA
|
Posted: Mon Oct 24, 2005 6:22 am Post subject: |
[quote] |
|
biggerUniverse wrote: | Perhaps the best landscape renderer every created uses perlin noise extensively.
Terragen |
theres no "perhaps" here man. ;)
Terragen IS the best landscape rendering software.
screw Bryce. Terragen tops it by miles in both quality & functionality. _________________ Principal Software Architect
Rambling Indie Games, LLC
See my professional portfolio
|
|
Back to top |
|
|
LeoDraco Demon Hunter
Joined: 24 Jun 2003 Posts: 584 Location: Riverside, South Cali
|
Posted: Mon Oct 24, 2005 6:37 am Post subject: Re: Procedurally-generated media |
[quote] |
|
RuneLancer wrote: | Working on some japanese hentai project with tentacled creatures and innocent schoolgirls? What better way to make your tentacled demon bob about and wave its tentacles than with perlin noise! |
How in Hell I missed that quote on my first read through, I cannot attest to. _________________ "...LeoDraco is a pompus git..." -- Mandrake
|
|
Back to top |
|
|
RuneLancer Mage
Joined: 17 Jun 2005 Posts: 441
|
Posted: Mon Oct 24, 2005 8:39 pm Post subject: |
[quote] |
|
Ken Perlin's site actually HAS a tentacle demo or two. ;) Though no schoolgirls are involved, it's still pretty cool.
I rather like his politician applet (the demonic-looking dude with the waving arms and thin, claw-like fingers.) The application of 1D noise to various joins in a model could give it some interesting "standing still" motions (head looking about, assessing the situation, while its body heaves up and down from breathing hard, etc.)
Unpredictable motions are always more interesting than canned pre-generated animations. And 1D noise makes it REAL easy to implement. Having branches and long weeds waving in the wind, water bobbing about, even butterflies flying around erratically all come to mind (and I think I'm going to implement that in Endless Saga; it's too easy to pass up.)
Weighted 2D noise could be used to make great fade textures. Ie, when averaging the layers, instead of dividing 8 layers by 8, divide by say... 6 + 4*(sinf(X) + (1 - cosf(Y)) or something (on a -1,-1 to 1,1 grid; formula's probably wrong but the basic idea's there.) Then just use that as an alpha layer for a texture. Gives an uneven fade that could simulate a bump-mapped cave floor being illuminated by a light. Recalculate the noise every frame and you have yourself a flickering torch!
Unsure how to have that pesky schoolgirl squirm? Well, now you know.
Edit: +1 vote for Terragen. ;) _________________ Endless Saga
An OpenGL RPG in the making. Now with new hosting!
|
|
Back to top |
|
|
|
Page 1 of 1 |
All times are GMT
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|