Jump to content


Photo

Perlin Noise


  • Please log in to reply
26 replies to this topic

#1 Skarik

Skarik

    GMC member

  • GMC Member
  • 1068 posts
  • Version:GM:Studio

Posted 16 October 2009 - 04:10 AM

Possible uses: Textures, Clouds, Detail maps, Bump maps, Rocks, Planet generation, Animation uncertainty, Character realism, Camera movement effects, etc etc.
What I use it for: Planet generation, dungeon generation, town generation (it's very powerful and can give a repeated result with the same seed, very desirable for testing)
Uses a slow, iterative algorithm for noise. This is not your "simplex noise," though I can add that on request.
Version 4 (May 2013):
 
EpicHouseStudios.com/staff/skarik/help/Perlin%20Noise%20V4.zip
 
Now that I understand C, no longer uses ridiculous indirection. GMKs now work with GM Studio. Thank you Brawl, again.
 
July 2014: If you have a question for me, try to email me or catch me on GameJolt. I don't go on this forum until someone from elsewhere tells me to, but I will update this sucker.

old versions:
Spoiler

Edited by Skarik, 26 July 2014 - 02:52 AM.

  • 2

#2 hanson

hanson

    GMC Member

  • GMC Member
  • 444 posts
  • Version:GM8

Posted 16 October 2009 - 04:24 AM

Great! Good luck in the <5mb game making!

Edited by hanson, 16 October 2009 - 04:35 AM.

  • 0

#3 Skarik

Skarik

    GMC member

  • GMC Member
  • 1068 posts
  • Version:GM:Studio

Posted 16 October 2009 - 05:04 AM

Great! Good luck in the <5mb game making!

Ha ha, you're not supposed to see this, but I guess it's safe to say that <5mb is the most popular poll choice.

But yeah, if you want, you can use this as well. It's REALLY nice for the extra details those procedural textures need.

Just set the GM blend mode to multiply and change the input value to go a little bit higher.

Edited by Skarik, 16 October 2009 - 05:05 AM.

  • 0

#4 Newly Discovered

Newly Discovered

    Harmonious Genius

  • GMC Member
  • 2475 posts
  • Version:GM8

Posted 16 October 2009 - 07:00 AM

awe it doesn't work for me! it keeps telling me I fail at life.
  • 0

poof_sig.png


#5 Skarik

Skarik

    GMC member

  • GMC Member
  • 1068 posts
  • Version:GM:Studio

Posted 16 October 2009 - 03:32 PM

awe it doesn't work for me! it keeps telling me I fail at life.

Yeah, there seems to be a problem with the indexes. It'll say that if there's an invalid index. Um, I'll check it out tonight and see what's up. Maybe a better version.

But for now, just avoid DeletePerlin.

Edited by Skarik, 16 October 2009 - 03:33 PM.

  • 0

#6 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • GMC Elder
  • 9603 posts
  • Version:GM:Studio

Posted 16 October 2009 - 04:16 PM

I get the same vague "Fail" error popping up until I CTRL+ALT+DEL the game (or, I suppose, until I'd let it pop up 65,536 times, but I don't have the patience for that).

The problem, it seems, is not in DeletePerlin, but in NshGetPerlin.

-IMP :) :(
  • 0

:GM123: Are you an artist who likes creating original creature designs? Maybe you can help out with Elementa here! Give it a look; you might like the idea :)

:bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny:


#7 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 16 October 2009 - 07:58 PM

This could be optimized a lot with the use of GMAPI (direct access to surfaces, too!).
  • 0

#8 Skarik

Skarik

    GMC member

  • GMC Member
  • 1068 posts
  • Version:GM:Studio

Posted 17 October 2009 - 02:40 AM

NshGetPerlin? Really? Huh...must be something different then. This is from just from the example?

GMAPI would be pretty cool, but I'm not too concerned about that, since I'm doing this for 3d stuff right now.
  • 0

#9 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • GMC Elder
  • 9603 posts
  • Version:GM:Studio

Posted 17 October 2009 - 02:42 AM

Yup, just the example that was zipped in the download. No edits; just opened it and hit Run, and those errors kept popping up.

-IMP :) :(
  • 0

:GM123: Are you an artist who likes creating original creature designs? Maybe you can help out with Elementa here! Give it a look; you might like the idea :)

:bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny:


#10 Skarik

Skarik

    GMC member

  • GMC Member
  • 1068 posts
  • Version:GM:Studio

Posted 17 October 2009 - 04:36 AM

That's strange. I don't want to have to write an Init function, as that should be called automatically on DLL loadup.

Well, I'll write an Init function anyways. Just in case, you know. I'll upload another like later. Or in a week. Or something.

Arg, I still gotta upload that error for the guys that make Newton...

Edited by Skarik, 17 October 2009 - 04:36 AM.

  • 0

#11 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 17 October 2009 - 05:16 AM

but I'm not too concerned about that

Not concerned about speed? I think you should be.
  • 0

#12 Skarik

Skarik

    GMC member

  • GMC Member
  • 1068 posts
  • Version:GM:Studio

Posted 17 October 2009 - 05:25 AM

It has nothing to do with speed. It has to do with the fact that I'm not using this to draw directly to GM. It also has to do with the fact that draw_pixel is slow whether from calling the GM function from C++ or from plain GM.

Crap, man. You want to tell me how to make it, make it yourself. I'm not too concerned about using GMAPI. I'm concerned more about college applications, friends, organizing contests, and other stuff like that that you probably don't have or don't do. Don't tell me what to be concerned about.

And don't say sorry. That word has no meaning anymore.
  • 0

#13 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 17 October 2009 - 03:16 PM

The biggest thing I have against this would actually be the use of a grid instead of a surface, and the 256 * 256 DLL calls. I understand you have a life, that's great. You do not need to get angry. I was just talking about the future of your DLL, it shouldn't matter too much as you have the source. But for your game, you might not want it to be slow. :(
  • 0

#14 Skarik

Skarik

    GMC member

  • GMC Member
  • 1068 posts
  • Version:GM:Studio

Posted 17 October 2009 - 04:08 PM

( My game uses Ultimate 3D )
  • 0

#15 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 18 October 2009 - 03:13 AM

That has nothing to do with this, if you're using this, it will be slow.

1. GML is slow, avoid using massive loops.
2. GM DLL calls are slow, avoid mass-use.

You had a massive loop with a DLL call in it. D:
  • 0

#16 Skarik

Skarik

    GMC member

  • GMC Member
  • 1068 posts
  • Version:GM:Studio

Posted 18 October 2009 - 04:54 AM

It takes like one second to generate a 256x256 texture, man. I don't see why it'll be slow.

Normal people shouldn't be using this to generate noise real time. Animated noise, or realism to camera or model animations, I can see that. I don't see people calling this 65536 times per step in normal circumstances.

O_o

And anyways, calling a GML function from C++ is still slow.

Edited by Skarik, 18 October 2009 - 04:59 AM.

  • 0

#17 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 18 October 2009 - 03:30 PM

It takes like one second to generate a 256x256 texture, man. I don't see why it'll be slow.

Normal people shouldn't be using this to generate noise real time. Animated noise, or realism to camera or model animations, I can see that. I don't see people calling this 65536 times per step in normal circumstances.

O_o

And anyways, calling a GML function from C++ is still slow.

On my PC it takes a few seconds, I'm just saying you could probably make it fast enough to animate. By the way, calling GML functions from C++ isn't that slow, you probably wont notice a difference. (Setting a pixel on a surface can probably be done without a single function call.)

Edited by TheMagicNumber, 18 October 2009 - 03:32 PM.

  • 0

#18 Maarten Baert

Maarten Baert

    GMC Member

  • GMC Member
  • 750 posts
  • Version:GM8.1

Posted 18 October 2009 - 09:01 PM

By the way, calling GML functions from C++ isn't that slow, you probably wont notice a difference. (Setting a pixel on a surface can probably be done without a single function call.)

Calling GML functions from a DLL is faster than calling them in Game Maker :D.
  • 0
Posted Image

#19 Skarik

Skarik

    GMC member

  • GMC Member
  • 1068 posts
  • Version:GM:Studio

Posted 18 October 2009 - 10:50 PM

It's still slow. Drawing a circle 10001 times took 16 seconds pure GML, but 3 seconds GML from C++. Still slow.

Hey, I'll see about it in the future. Maybe. I'll check out what's wrong with the DLL today, though. Maybe add some 3d stuff for 2d animated textures.

Edit: Whoops, looks like I was passing the address to the index list instead of the number. Tee hee. 3D noise support added a whole 1 KB. :skull: That bums me out. I think I fixed everything. Will update in a little bit.

Edited by Skarik, 18 October 2009 - 11:51 PM.

  • 0

#20 Skarik

Skarik

    GMC member

  • GMC Member
  • 1068 posts
  • Version:GM:Studio

Posted 19 October 2009 - 12:00 AM

Right, new version:

http://www.box.net/shared/4susvfotsh

Might have fixed the problems some of you were getting. I had to move some of the code, so the size is increased by 1 Kb, totaling at 16 Kb. However, I also added support for 3D noise. Unfortunately, I forgot to include the GML, so for you guys, the function name is "GetPerlin3D" with four arguments.
  • 0

#21 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • GMC Elder
  • 9603 posts
  • Version:GM:Studio

Posted 27 October 2009 - 03:26 AM

Well, now there's no errors :) . But it's still fairly slow. I coded a timer, and it takes ~1.5s to create noise and ~1.5s to draw it (I was drawing to a surface so it doesn't kill the FPS). So 3 seconds each time I needed new noise.

It's not great for realtime applications, but it does look good, so kudos for that.

-IMP ;) :P
  • 0

:GM123: Are you an artist who likes creating original creature designs? Maybe you can help out with Elementa here! Give it a look; you might like the idea :)

:bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny:


#22 rymate1234

rymate1234

    GMC Member

  • GMC Member
  • 30 posts

Posted 25 April 2011 - 03:34 PM

This seems to be what I'm looking for :D

It seems to generate the same noise each time though

Edited by rymate1234, 25 April 2011 - 08:09 PM.

  • 0

#23 Digisynth

Digisynth

    GMC Member

  • Validating
  • 55 posts

Posted 01 May 2012 - 01:39 PM

It takes like one second to generate a 256x256 texture, man. I don't see why it'll be slow.

Normal people shouldn't be using this to generate noise real time. Animated noise, or realism to camera or model animations, I can see that. I don't see people calling this 65536 times per step in normal circumstances.

O_o

And anyways, calling a GML function from C++ is still slow.


Thanks man! You rule! You are completely right. Generating noise does take time. I also once made my own Perlin Noise generator using only GML, but it would take TWO MINUTES to render a 512*512 image using only seven noise layers.

Thanks again! I will make use of this! :thumbsup:
pi = 3,1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679

#24 Mischaal

Mischaal

    GMC Member

  • GMC Member
  • 32 posts
  • Version:GM:Studio

Posted 13 February 2014 - 01:39 PM

hey! First of all thanks for this great post! I'm getting a 512x512 map with rgb-value changes in about 2 seconds!

that's great but I want to get this game also working in html5.
Attempts to get perlin noise with similar effects only in GML took about 30 seconds to create.
It seems another solution would be to run this code in javascript. Without knowledge of JavaScript I'm having some problems here.

But first I'd like to know your opinion (before I spend hours of converting code) if this would be the solution. Maybe there is a solution without a dll which helps me better. Or maybe someone actually made a JAvascript version of this.

 

Thanks for your help

 

Mischaal


  • 0

#25 gff1979

gff1979

    GMC Member

  • GMC Member
  • 26 posts
  • Version:GM:Studio

Posted 04 March 2014 - 09:15 AM

I'm interested in having a Simplex version but only because after reading Perlin's notes, and getting brain fuzzed a little, I assumed it was much faster on the whole and his replacement for the old noise algorithm, not just in higher iterations and dimensions. If I'm wrong then that's fine and this is great work anyway since I don't have to rewrite my own since switching to GM:S. Thanks!


  • 0

#26 HellCreator

HellCreator

    GMC Member

  • GMC Member
  • 115 posts
  • Version:Unknown

Posted 21 June 2014 - 01:15 PM

Now I know this topic is very old, but how do I implement the 3d Noise...where are the scripts located because GetPerlin3D doesn't show up...


  • 0

#27 Skarik

Skarik

    GMC member

  • GMC Member
  • 1068 posts
  • Version:GM:Studio

Posted 26 July 2014 - 03:04 AM

Now I know this topic is very old, but how do I implement the 3d Noise...where are the scripts located because GetPerlin3D doesn't show up...

Sorry for the late reply, but I'm pretty much not here, ever! Anyhooo you don't. You take in the GML scripts, which are targeted for GM8 and below. Loads in the symbols in the GML.

I'll take some time to update it to GM:S, since apparently the latest Yoyo compiler has a few issues AND IT WOULD BE GREAT TO HAVE MORE PEOPLE COMPLAIN TO ME LIKE I'M SOME SORT OF GOD BECAUSE THAT'S WHAT PEOPLE DO WITH GODS RIGHT, but I don't own GM:S at the moment! It might take a few months I'M ACTUALLY KIND OF BUSY

I'm interested in having a Simplex version but only because after reading Perlin's notes, and getting brain fuzzed a little, I assumed it was much faster on the whole and his replacement for the old noise algorithm, not just in higher iterations and dimensions. If I'm wrong then that's fine and this is great work anyway since I don't have to rewrite my own since switching to GM:S. Thanks!

I have the code somewhere for Simplex (I use both in my project) and it uses the same framework as this one. Who knows, maybe I'll add it! Maybe some diamond-square fun too, because I made an implementation of that that sits on top of the noise.

tl;dr Toot toot updates ahead (once I buy GM:S)
  • 0