Git Product home page Git Product logo

cl-noise's Introduction

dotfiles

my system configuration files

packages

submodules

Some configuration options depend on git submodules. Either use --recursive when cloning or run git submodule init && git submodule update in the root of the repository after cloning.

installation using gnu stow

$ stow package1 package2 ...

license

This work is dual-licensed under the following licenses:

cl-noise's People

Contributors

jakergrossman avatar

Watchers

 avatar  avatar

Forkers

ebenbruyns

cl-noise's Issues

Floating point overflow for perlin noise with a high # of octaves

SBCL Output:

Unhandled FLOATING-POINT-OVERFLOW in thread #<SB-THREAD:THREAD "main thread" RUNNING
                                               {10019B4103}>:
  arithmetic error FLOATING-POINT-OVERFLOW signalled
Operation was (FLOAT 340282366920938463463374607431768211456 SINGLE-FLOAT).

Backtrace for: #<SB-THREAD:THREAD "main thread" RUNNING {10019B4103}>
0: (SB-DEBUG::DEBUGGER-DISABLED-HOOK #<FLOATING-POINT-OVERFLOW {1001B171C3}> #<unused argument> :QUIT T)
1: (SB-DEBUG::RUN-HOOK *INVOKE-DEBUGGER-HOOK* #<FLOATING-POINT-OVERFLOW {1001B171C3}>)
2: (INVOKE-DEBUGGER #<FLOATING-POINT-OVERFLOW {1001B171C3}>)
3: (UIOP/IMAGE:HANDLE-FATAL-CONDITION #<FLOATING-POINT-OVERFLOW {1001B171C3}>)
4: (SB-KERNEL::%SIGNAL #<FLOATING-POINT-OVERFLOW {1001B171C3}>)
5: (ERROR FLOATING-POINT-OVERFLOW :OPERATION FLOAT :OPERANDS (340282366920938463463374607431768211456 SINGLE-FLOAT))
6: ((LABELS SB-BIGNUM::CHECK-EXPONENT :IN SB-BIGNUM:BIGNUM-TO-FLOAT) #<unavailable argument> #<unavailable argument> #<unavailable argument>)
7: ((LABELS SB-BIGNUM::FLOAT-FROM-BITS :IN SB-BIGNUM:BIGNUM-TO-FLOAT) 154742504910672534362390528 #<unavailable argument>)
8: (SB-KERNEL:TWO-ARG-* 340282366920938463463374607431768211456 0.0)
9: (NOISE.GEN:PERLIN 0.0 0.0 0 :OCTAVES 150 :PERSISTENCE 0.5 :PERM #(9 186 181 93 102 161 222 158 162 242 146 112 ...))
10: ((LAMBDA NIL :IN NOISE.GEN:PERLIN-GENERATOR))
11: (NOISE.TEXT::PERLIN-TEXT #<SYNONYM-STREAM :SYMBOL SB-SYS:*STDOUT* {1000008BA3}> :SIZE 1 :OCTAVES 150 :PERSISTENCE NIL :PERM NIL :SCALE NIL)
12: (NOISE.TEXT::RUN ("-s" "1" "--octaves" "150"))
13: ((LAMBDA NIL :IN UIOP/IMAGE:RESTORE-IMAGE))
14: (UIOP/IMAGE:CALL-WITH-FATAL-CONDITION-HANDLER #<FUNCTION (LAMBDA NIL :IN UIOP/IMAGE:RESTORE-IMAGE) {1000908C3B}>)
15: ((FLET SB-UNIX::BODY :IN SB-IMPL::START-LISP))
16: ((FLET "WITHOUT-INTERRUPTS-BODY-3" :IN SB-IMPL::START-LISP))
17: (SB-IMPL::START-LISP)

Caused here:

(loop for frequency = 1 then (* 2 frequency)
          for amplitude = 1 then (* amplitude persistence)
          ;; maximum possible total amplitude
          for max-amp = 1 then (+ amplitude max-amp)
          
          for octave below octaves

          ;; TODO: overflow when # of octaves is large
          for noise = (perlin-point (* frequency x)
                                    (* frequency y)
                                    (* frequency z)
                                    :perm perm)
          sum (* noise amplitude) into total
          
          finally (return (/ total max-amp)))))

frequency is doubled each time, so eventually (* frequency x) overflows.

I'd like not to cap octaves if possible.

Floating point rounding causes runs of `0.0` near data points near the edges of a unit square.

On perlin noise of sufficient size, as the sampled point approaches the boundary, the noise value is smaller than the precision limit of float.

This is a sample of one-dimensional noise taken from the first line of lperlin -s 512 (wrapped onto multiple lines):

0.0            2.4450885e-5   1.8796946e-4   6.0930516e-4   0.001386404   0.0025978687   0.0043043755   0.0065500517
0.0093638105   0.012760638    0.016742852    0.0213013      0.02641654    0.03205995     0.03819481     0.044777367
0.051757813    0.05908123     0.06668853     0.07451733     0.08250276    0.090578265    0.09867635     0.1067293
0.1146698      0.122431636    0.12995018     0.13716298     0.1440103     0.15043546     0.15638536     0.16181076
0.16666667     0.17091262     0.17451292     0.17743681     0.17965865    0.18115808     0.18192005     0.18193485
0.18119812     0.1797108      0.17747904     0.17451411     0.17083208    0.1664538      0.16140449     0.15571351
0.14941406     0.14254265     0.1351388      0.12724452     0.118903875   0.11016231     0.10106614     0.09166189
0.08199564     0.07211227     0.06205472     0.051863175    0.04157424    0.031220034    0.02082727     0.010416279
0.0            -0.01044073    -0.02101524    -0.03182934    -0.042960644  -0.054461043   -0.066359095   -0.07866233
-0.09135946    -0.10442253    -0.11780899    -0.1314636     -0.14532042   -0.15930447    -0.1733336     -0.18732001
-0.20117188    -0.21479475    -0.22809303    -0.24097113    -0.25333485   -0.26509237    -0.27615538    -0.2864401
-0.29586792    -0.3043665     -0.31187025    -0.31832108    -0.32366896   -0.32787228    -0.33089828    -0.33272338
-0.33333334    -0.33272338    -0.33089828    -0.32787228    -0.32366896   -0.31832108    -0.31187022    -0.30436647
-0.29586792    -0.2864401     -0.27615538    -0.26509234    -0.25333485   -0.24097113    -0.22809303    -0.21479475
-0.20117188    -0.18732       -0.1733336     -0.15930445    -0.14532042   -0.1314636     -0.117808975   -0.10442253
-0.09135946    -0.07866236    -0.06635908    -0.054461043   -0.042960644  -0.031829357   -0.021015247   -0.010440707
0.0            0.01044073     0.02101524     0.03182934     0.042960644   0.054461043    0.066359095    0.07866233
0.09135946     0.10442253     0.11780899     0.1314636      0.14532042    0.15930447     0.1733336      0.18732001
0.20117188     0.21479475     0.22809303     0.24097113     0.25333485    0.26509237     0.27615538     0.2864401
0.29586792     0.3043665      0.31187025     0.31832108     0.32366896    0.32787228     0.33089828     0.33272338
0.33333334     0.33272338     0.33089828     0.32787228     0.32366896    0.31832108     0.31187022     0.30436647
0.29586792     0.2864401      0.27615538     0.26509234     0.25333485    0.24097113     0.22809303     0.21479475
0.20117188     0.18732        0.1733336      0.15930445     0.14532042    0.1314636      0.117808975    0.10442253
0.09135946     0.07866236     0.06635908     0.054461043    0.042960644   0.031829357    0.021015247    0.010440707
0.0            -0.010416279   -0.02082727    -0.031220034   -0.04157424   -0.051863175   -0.06205472    -0.07211227
-0.08199564    -0.0916619     -0.10106614    -0.11016231    -0.118903875  -0.12724452    -0.1351388     -0.14254265
-0.14941406    -0.15571353    -0.16140449    -0.1664538     -0.17083208   -0.1745141     -0.17747904    -0.1797108
-0.18119812    -0.18193485    -0.18192005    -0.18115808    -0.17965865   -0.17743681    -0.17451292    -0.17091262
-0.16666667    -0.16181076    -0.15638536    -0.15043546    -0.1440103    -0.13716298    -0.12995017    -0.12243161
-0.1146698     -0.10672929    -0.09867636    -0.090578236   -0.08250276   -0.07451733    -0.06668854    -0.059081238
-0.051757813   -0.044777352   -0.038194817   -0.03205995    -0.02641654   -0.021301309   -0.016742865   -0.012760639
-0.0093638105  -0.0065500736  -0.0043043694  -0.0025978882  -0.001386404  -6.0931843e-4  -1.8795331e-4  -2.4437904e-5
0.0            0.0            0.0            0.0            0.0           0.0            0.0            0.0
0.0            0.0            0.0            0.0            0.0           0.0            0.0            0.0
0.0            0.0            0.0            0.0            0.0           0.0            0.0            0.0
0.0            0.0            0.0            0.0            0.0           0.0            0.0            0.0
0.0            0.0            0.0            0.0            0.0           0.0            0.0            0.0
0.0            0.0            0.0            0.0            0.0           0.0            0.0            0.0
0.0            0.0            0.0            0.0            0.0           0.0            0.0            0.0
0.0            0.0            0.0            0.0            0.0           0.0            0.0            0.0
0.0            -2.4450885e-5  -1.8796946e-4  -6.0930516e-4  -0.001386404  -0.0025978687  -0.0043043755  -0.0065500517
-0.0093638105  -0.012760638   -0.016742852   -0.0213013     -0.02641654   -0.03205995    -0.03819481    -0.044777367
-0.051757813   -0.05908123    -0.06668853    -0.07451733    -0.08250276   -0.090578265   -0.09867635    -0.1067293
-0.1146698     -0.122431636   -0.12995018    -0.13716298    -0.1440103    -0.15043546    -0.15638536    -0.16181076
-0.16666667    -0.17091262    -0.17451292    -0.17743681    -0.17965865   -0.18115808    -0.18192005    -0.18193485
-0.18119812    -0.1797108     -0.17747904    -0.17451411    -0.17083208   -0.1664538     -0.16140449    -0.15571351
-0.14941406    -0.14254265    -0.1351388     -0.12724452    -0.118903875  -0.11016231    -0.10106614    -0.09166189
-0.08199564    -0.07211227    -0.06205472    -0.051863175   -0.04157424   -0.031220034   -0.02082727    -0.010416279
0.0            0.010416279    0.02082727     0.031220034    0.04157424    0.051863175    0.06205472     0.07211227
0.08199564     0.0916619      0.10106614     0.11016231     0.118903875   0.12724452     0.1351388      0.14254265
0.14941406     0.15571353     0.16140449     0.1664538      0.17083208    0.1745141      0.17747904     0.1797108
0.18119812     0.18193485     0.18192005     0.18115808     0.17965865    0.17743681     0.17451292     0.17091262
0.16666667     0.16181076     0.15638536     0.15043546     0.1440103     0.13716298     0.12995017     0.12243161
0.1146698      0.10672929     0.09867636     0.090578236    0.08250276    0.07451733     0.06668854     0.059081238
0.051757813    0.044777352    0.038194817    0.03205995     0.02641654    0.021301309    0.016742865    0.012760639
0.0093638105   0.0065500736   0.0043043694   0.0025978882   0.001386404   6.0931843e-4   1.8795331e-4   2.4437904e-5
0.0            0.0            0.0            0.0            0.0           0.0            0.0            0.0
0.0            0.0            0.0            0.0            0.0           0.0            0.0            0.0
0.0            0.0            0.0            0.0            0.0           0.0            0.0            0.0
0.0            0.0            0.0            0.0            0.0           0.0            0.0            0.0
0.0            0.0            0.0            0.0            0.0           0.0            0.0            0.0
0.0            0.0            0.0            0.0            0.0           0.0            0.0            0.0
0.0            0.0            0.0            0.0            0.0           0.0            0.0            0.0
0.0            0.0            0.0            0.0            0.0           0.0            0.0            0.0

It can be seen that as the noise value approaches 0.0, the surrounding values may become sufficiently small so as to round down to 0.0 as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.