Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: mvNoise, Perlin noise - problem

  1. #1

    mvNoise, Perlin noise - problem

    I've looked into making some perlin noise for my procedurally generated shooter and found this: http://www.pascalgamedevelopment.com...hi-source-code

    Unfortunately unit given here requires some strange mvMath unit, which I wasn't able to find. Any help? Game is at stage where replacing unit isn't problem, so if you have any other Perlin noise generation unit, I'd be happy to use it.
    Last edited by Darkhog; 28-05-2013 at 12:00 PM.

  2. #2
    in glscene there is a unit for that. googled 'glscene perlinnoise.pas'
    http://read.pudn.com/downloads28/sou...oise.pas__.htm

  3. #3
    Yeah, but wouldn't I then need to download whole glscene? I don't need it. All I need is 2D perlin noise, as it is for 2D game, anyway.

  4. #4
    Hi!
    At the time of 2nd PGD mini challenge I was fidling myself with Perlin Noise generation and I made my own algorithm similar to Perlin Noise.
    The biggest problem is that code which is used for combining seperate octave textures into one tends to exeds its limits sometime (value for certain pixel can exceed 255 which results in parts of the texture to become negative).

    I was also planning on adding support for further postprocessing of Perlin Noise result to get better results in the end.
    For instance I use perlin noise for generating heightmap. Height of the map can be between 0 and 255.
    I consider height range of 0-8 as seabed so I use postprocessing to smoth (almost level) it out.
    I consider height range pf 9-10 as sand beaches so I try to make them smoth and nicely sloped.
    ....
    I gues you got the point.
    I was also thinking of controlling this terain smothening with another texture for creating biomes etc.
    Unfortunately I haven't done anything on postprocessing so far as I was running out of time for 2nd PGD mini competition and later I havent returned to this.

    I have ability to specify seed nuber when I'm starting but I'm not sure if it would alow me making infinite Perlin Noise textures.
    Oh I was planning to use custom Random number algorithm implementation to gain the ability to have threadsafe random number generation which isn't posible using Delphi random number generator.

    Now if you wan't I could go and try to continue my work where I left of. I hope I comented my code

  5. #5
    As I feared I haven't comented my code so I'll first have to figure out how it currently works

  6. #6
    I have ability to specify seed nuber when I'm starting but I'm not sure if it would alow me making infinite Perlin Noise textures.
    Not infinite, in chunks. The trick is to have x/y offset variables and to waste first x/y random numbers and create actual bitmap.

    I.e. if you want to generate chunk you set x offset (for simplifying, let's assume that chunks are going in straight line) to chunksize*number of chunks already generated. Then, based of value of xoffset you "waste" first several columns. In pseudocode (for simplicity chunks are white noise):

    Code:
    function generate_chunk(rndseed,xoffset, yoffset,chunksize:Integer)
    {
     x,y,dump:Integer
     Seed=rndseed
     for x=0 to xoffset+chunksize
     {
       if x<=xoffset {dump = random(256); continue}
       for y=0 to yoffset+chunksize
       {  
          dump=random(256)
          if y<=yoffset { continue}
          
          Bitmap[x-xoffset,y-yoffset]=RGB(dump,dump,dump)
       }
     }
    
    }
    I know that much, just don't know how to apply it into real perlin noise app .

    And yes, if you can I'd appreciate if you could make it work. All I need is simple Perlin noise.

    The biggest problem is that code which is used for combining seperate octave textures into one tends to exeds its limits sometime
    Simple
    Code:
     if value>255 then value:=255;
    at the end of combining code, but before putting it into byte array should help with that.

  7. #7
    Quote Originally Posted by Darkhog View Post
    Not infinite, in chunks. The trick is to have x/y offset variables and to waste first x/y random numbers and create actual bitmap.

    I.e. if you want to generate chunk you set x offset (for simplifying, let's assume that chunks are going in straight line) to chunksize*number of chunks already generated. Then, based of value of xoffset you "waste" first several columns. In pseudocode (for simplicity chunks are white noise):
    I certainly wouldn't use your approach. Why? As you say "wasting" random numbers would be wasting CPU time. Are you aware that random number generation is one of the bottlenecks of the Perlin Noise algorithm? And other is mothening the textures.

    If you don't belive me just go and create several thousands of random numbers and see how much time would your computer need to do that. And if you think that 100x100 ofset would mean you would be wasting 10000 random generated numbers. NOT a good idea.

    For solving this problem it would be wiser to use one of custom Random Number generation algorithms which alow takind additional imputs which are then used during random number generation. Problem with most of such algorithm is that when theese inputs numbers becomes large the random number generation becomes more eratic.



    Quote Originally Posted by Darkhog View Post
    And yes, if you can I'd appreciate if you could make it work. All I need is simple Perlin noise.
    OK then I'll get to work as soon as I find some time. Anwhay I still have a gime in mind which will use this.


    Quote Originally Posted by Darkhog View Post
    Simple
    Code:
     if value>255 then value:=255;
    at the end of combining code, but before putting it into byte array should help with that.
    And the result would be flatheaded mountains. So unrealistic.
    At the time I was thinking of finding highest point and then normilize whole texture so that this highest point doesn't exceed the limit.
    Oh now I remembered that I was also planning to do a complete rewite of my algorithm.
    Storing values in 2D array would be a problem for my postprocessing functions as I will require data to be soreted by height for instance. This means storing them in a list as nodes (Height, X and Y position). This will result in need for more memory.
    Gues I should start searching for suitable Random number generator algorithm which supports accepting aditional parameters (X,Y position). This way I would be able to generate my map in chunks.

    But first let my try to get that glscene algorithm working so that you will at lest have some basic random map generation available to work further on your game.

  8. #8
    And the result would be flatheaded mountains. So unrealistic.
    Then apply some Gaussian blur to this.

    Anyway, do however you want, but I'd like to be able to generate chunks of texture (it certainly is possible as Minecraft, Minetest-c55 and other mineclones features semi-infinite world and without making it with chunks it wouldn't work).

    And don't bother with glscene thing. I can wait for proper solution (have other things to do in meantime anyway, like writing state machine and collision system).

  9. #9
    I'm checking GLscene becouse I belive it has implementation of Perlin Noise which can use offset imputs. That is what you need.

  10. #10
    PGDCE Developer Carver413's Avatar
    Join Date
    Jun 2010
    Location
    Spokane,WA,Usa
    Posts
    206
    Paul gave me a perlin noise unit. you can find it in this thread
    http://www.pascalgamedevelopment.com...arver-Explorer
    works great

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •