Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

What's the equivalent of Mathf.PerlinNoise(float x, float y) in Unity.Mathematics?

Discussion in 'Entity Component System' started by davenirline, Apr 24, 2020.

  1. davenirline

    davenirline

    Joined:
    Jul 7, 2010
    Posts:
    948
    I see noise.pnoise() but it accepts two float2 parameters. Not sure what to pass on the second variable. Passing (0, 0) doesn't work the same as Mathf.PerlinNoise().
     
  2. SenseEater

    SenseEater

    Joined:
    Nov 28, 2014
    Posts:
    84
    davenirline likes this.
  3. davenirline

    davenirline

    Joined:
    Jul 7, 2010
    Posts:
    948
    Of course. I didn't read the comment. I thought it was another type of noise.
     
  4. SamOld

    SamOld

    Joined:
    Aug 17, 2018
    Posts:
    331
    That part of the library - and actually the mathematics library generally - has some real problems with naming and lack of documentation. I'm not sure if they can change method names now or if they're locked into those for back compat, but they at least need to fix parameter names.

    The full list of noise methods at the moment is
    cellular
    ,
    cellular2x2
    ,
    cellular2x2x2
    ,
    cnoise
    ,
    pnoise
    ,
    psrdnoise
    ,
    psrnoise
    ,
    snoise
    ,
    srdnoise
    , and
    srnoise
    . I mean, come on, that's inscrutable. The methods don't even have doc comments to explain the names. It's almost unusable, then when you eventually work your way through it, the code you end up with is unreadable.

    I really hope there's a plan to fix this ASAP, because the longer they leave it, the harder it is to fix.
     
    apkdev, exiguous, OUTTAHERE and 4 others like this.
  5. Cell-i-Zenit

    Cell-i-Zenit

    Joined:
    Mar 11, 2016
    Posts:
    290
    wow i really thought that the new lib didnt include any noise functions ... wow this is going to be gamechanging for me
     
  6. andrew-lukasik

    andrew-lukasik

    Joined:
    Jan 31, 2013
    Posts:
    240
    Code (csharp):
    1. float perlinSample = ( noise.cnoise(new float2(x,y)) + 1f ) * 0.5f;
    It's results are not identical however.
     
    Last edited: Jul 23, 2022
    mmcveigh33, kstudd, One1Guy and 3 others like this.
  7. kstudd

    kstudd

    Joined:
    Jan 29, 2018
    Posts:
    1
    I just had to reply and say thank you! I was struggling to find new values to get my noise maps the way I wanted and this conversion really helped since I was very happy with my old values.