Noise!
Pages: [1]
|
|
Programming Help
|
Down Rodeo
Cap'n Moth of the Firehouse


2007 Oct 19 • 5328
57,583 ₧
|
It's probably about time I let someone see my code. So here it is: GET SOME
At the moment, it is nothing more than a simple command-line program to produce Perlin noise and FBM of various octaves. It's all pretty simple but is completely uncommented. You run it like
code ./noise size cellsize octaves output_file
The images are all square, so that's what size is, the cellsize defines what scale the noise is on, larger cellsizes make large noise features, smaller makes it more intricate. The octaves thing... broadly speaking, adding more octaves (you can leave it at zero for instance) will add higher-frequency noise but at a smaller amplitude. At the moment that's not hugely modifiable.
I've just realised what I've said is lies. I've added some domain warping and at the moment, it can't be turned off. The plan for the next bit is to add support for a file that all the data is read from, because there are only so many pieces of data you can put on the command line. If you want to remove the domain warping it will require a little source editing. If anyone is really interested I'll tell you what to do. Expect pictures in the next few days, perhaps!
Everyone stares when you walk in the room, they stare when you go....
|
|
|
|
|
(Edited 2012 Jan 16 at 19:15)
2012 Jan 16 at 19:15
|
|
|
sprinkles


2009 Sep 6 • 2480
10 ₧
|
I see we meet again Mr. McBain.
...then I got some ap, and shot a big ass lazar at everyone.
|
|
|
|
|
2012 Jan 16 at 20:07
|
|
|
superjer
superjer

2005 Mar 20 • 3767
|
gcc --std=c99 -lm -o noise noise.c
./noise 400 50 1 a.pgm
./noise 400 50 5 b.pgm
./noise 400 50 10 c.pgm
./noise 400 200 5 d.pgm
NEAT.
|
|
|
|
|
(Edited 2012 Jan 17 at 18:33)
2012 Jan 17 at 18:29
|
|
|
Down Rodeo
Cap'n Moth of the Firehouse


2007 Oct 19 • 5328
57,583 ₧
|
I compile with -pedantic and -Wall and it's still fine! You'll notice that, at the moment, there's a fairly severe bias toward vertical lines - I am not sure why. But I have one idea; it might be related to the noise function I use (repeatedly, which I think is the issue). I'm bust right now but I'm going to do a little this evening, see if I can't do some function pointer magic to change which type of fbm is produced.
Everyone stares when you walk in the room, they stare when you go....
|
|
|
|
|
2012 Jan 18 at 05:15
|
|
|
Down Rodeo
Cap'n Moth of the Firehouse


2007 Oct 19 • 5328
57,583 ₧
|
Found it. Of course it was a p that should be q. So you get this now:
./noise 700 50 10 output.pgm
Interestingly, this image is actually larger when compressed using PNG. I mean it might be the program I used, but perhaps I have finally found my pathologic image! Of course as we know for any given lossless compression format there will always be some sequence of bytes that is larger when "compressed" by that format. So maybe I've found one of them.
This is what happened when I added the second domain warping:
./noise 400 25 10 output.pgm
As you can see it's not working here, there is far too much random noise. Compare with the stuff going on in this page.
It's also going to need optimisation soon. It's a little slow. There's a really easy one, that being to cache the vectors generated at each grid point. At the moment they're recomputed each pixel and they involve a call to a fairly complex function and quite a bit of trigonometry. So that really ought to help, I hope. When I can be bothered/have time.
Everyone stares when you walk in the room, they stare when you go....
|
|
|
|
|
2012 Jan 18 at 18:56
|
|
|
Down Rodeo
Cap'n Moth of the Firehouse


2007 Oct 19 • 5328
57,583 ₧
|
:o
Supes, I think I might need your help with this, at some stage. Say I wanted configurability to the max - how might I go about creating some small config file that can change lots of the program, rather than a couple of numbers? Anyway, now's not the time. I might ask more in a few days.
Everyone stares when you walk in the room, they stare when you go....
|
|
|
|
|
2012 Jan 19 at 19:07
|
|
|
Rockbomb
Dog fucker

2009 Nov 13 • 1943
-190 ₧
|
That looks like a puddle full of oil... I like it :D
Also, you should make a GUI at some point... I don't like typing. In fact, I'm not even going to finish typing this sente
|
|
|
|
|
2012 Jan 19 at 21:15
|
|
|
Down Rodeo
Cap'n Moth of the Firehouse


2007 Oct 19 • 5328
57,583 ₧
|
Rockbomb said: you should make a GUI at some point
Fuck off! You should make a GUI. I'd be impressed if you could write one that was worth the complexity! :p
Apart from anything else the current method makes it considerably easier to rerun the program with different parameters and is in fact scriptable.
Everyone stares when you walk in the room, they stare when you go....
|
|
|
|
|
2012 Jan 20 at 02:09
|
|
|
Rockbomb
Dog fucker

2009 Nov 13 • 1943
-190 ₧
|
Down Rodeo said: You should make a GUI.
What language are you doing this in?
If it's C++, I could prolly make something in VB.NET for it.
|
|
|
|
|
2012 Jan 20 at 09:11
|
|
|
sprinkles


2009 Sep 6 • 2480
10 ₧
|
Are you going to make it move like in the last video of that page?
...then I got some ap, and shot a big ass lazar at everyone.
|
|
|
|
|
2012 Jan 20 at 09:58
|
|
|
Down Rodeo
Cap'n Moth of the Firehouse


2007 Oct 19 • 5328
57,583 ₧
|
Rockbomb said: What language are you doing this in?
If it's C++, I could prolly make something in VB.NET for it.
C. Moreover, C on GNU/Linux. GUIs are by and large pointless, it is much easier to fire all the data into a file, read it and run it.
sprinkles said: Are you going to make it move like in the last video of that page?
Ideally. But it will require some more smarts that I am not sure I currently own. Neither do I have the time for that, of course. But I'll do a little more work on the colours.
Everyone stares when you walk in the room, they stare when you go....
|
|
|
|
|
(Edited 2012 Jan 20 at 11:43)
2012 Jan 20 at 11:42
|
|
|
superjer
superjer

2005 Mar 20 • 3767
|
Down Rodeo said: how might I go about creating some small config file that can change lots of the program, rather than a couple of numbers?
With fopen() and fscanf().
That's how I usually do it, anyways.
|
|
|
|
|
2012 Jan 20 at 19:03
|
|
|
Down Rodeo
Cap'n Moth of the Firehouse


2007 Oct 19 • 5328
57,583 ₧
|
Well yes, I get that. It's more... how do I structure my program intelligently such that I can use a file to configure the program? I've done quite a bit of file IO in Java, and a small amount in C. But I always feel that saying something along the lines of "look for parameter -> save into variable -> find code path" is a bit... inefficient. And I always seem to find that either lots of code is duplicated or there are if statements EVERYWHERE. And that is definitely inefficient.
Everyone stares when you walk in the room, they stare when you go....
|
|
|
|
|
2012 Jan 20 at 19:21
|
|
|
SRAW
Rocket Man

2007 Nov 6 • 2146
601 ₧
|
How do you get the code from bitbucket?
|
|
|
|
|
2012 Jan 20 at 19:23
|
|
|
Rockbomb
Dog fucker

2009 Nov 13 • 1943
-190 ₧
|
SRAW said: How do you get the code from bitbucket?
install mercurial: link
then use code hg clone https://bitbucket.org/DuncanMcBain/noise
|
|
|
|
|
2012 Jan 20 at 19:26
|
|
|
superjer
superjer

2005 Mar 20 • 3767
|
They also have a link on the downloads page.
|
|
|
|
|
2012 Jan 20 at 19:30
|
|
|
SRAW
Rocket Man

2007 Nov 6 • 2146
601 ₧
|
Soooo I tried compiling it in msvc++ 2008, and it failed, WHY
|
|
|
|
|
2012 Jan 21 at 20:27
|
|
|
Rockbomb
Dog fucker

2009 Nov 13 • 1943
-190 ₧
|
Because you tried compiling it in msvc++ 2008, presumably.
Try GCC? Or if you're only using Windows, try MinGW?
|
|
|
|
|
2012 Jan 21 at 20:34
|
|
|
Down Rodeo
Cap'n Moth of the Firehouse


2007 Oct 19 • 5328
57,583 ₧
|
|
|
|
|
|
2012 Jan 21 at 20:41
|
|
|
SRAW
Rocket Man

2007 Nov 6 • 2146
601 ₧
|
Ok, I got it to compile, but how Im too lazy to search how to open pgm files
|
|
|
|
|
2012 Jan 22 at 11:52
|
|
|
Rockbomb
Dog fucker

2009 Nov 13 • 1943
-190 ₧
|
SRAW said: Ok, I got it to compile, but how Im too lazy to search how to open pgm files
GIMP supports PGM files: linkzor
Or if you have Photoshop, you can install CartaPGM Sausage Link
|
|
|
|
|
2012 Jan 22 at 12:01
|
|
|
Down Rodeo
Cap'n Moth of the Firehouse


2007 Oct 19 • 5328
57,583 ₧
|
I used pgm because it is braindead-simple. They look like this:
code PX //X is a number 1-6, depending on type: monotone, greyscale, colour and ASCII/binary xsize ysize if it's binary maximum intensity (say, 255) from now, data. One line per line of image, if it's ASCII, otherwise it's a big lump of binary.
Oh yeah, each thing is a char. Including each channel for colour images. Whatever, it's really simple. The stuff I've not posted here yet is slightly different again so you might want to update.
Everyone stares when you walk in the room, they stare when you go....
|
|
|
|
|
2012 Jan 22 at 17:16
|
|
|
SRAW
Rocket Man

2007 Nov 6 • 2146
601 ₧
|
Could you NOT declare the ints in the for loops also, because noobs even worse at programming than me might not know how to compile this thing in sexually transmitted disease '99 standard or fix it...
|
|
|
|
|
2012 Jan 22 at 20:16
|
|
|
Down Rodeo
Cap'n Moth of the Firehouse


2007 Oct 19 • 5328
57,583 ₧
|
|
|
|
|
|
2012 Jan 22 at 21:30
|
|
|
Down Rodeo
Cap'n Moth of the Firehouse


2007 Oct 19 • 5328
57,583 ₧
|
|
|
|
|
|
2012 Jan 26 at 02:59
|
|
|
|
Pages: [1]
|