Code Monkey home page Code Monkey logo

noise's Introduction

Noise CPU & GPU for GML

NoisePack LogoNoisePack Logo

Noise algorithms studied & ported to GML. Contains CPU and GPU noise calculation scripts.

Calculating noise on the GPU is faster than doing it on CPU couple of thousand times. This is the best method if the noise is going to be used as an image (for image processing or compositing images).

If the calculated noise needs to be turned into an array of numerical data, the process gets slower. The bottleneck is not calculating the noise, but getting the data from the image.

Since calculating noise on the GPU is extremely fast, this extension lets you calculate big sample data at once, and cache it. This is a design choice to make the process more efficient.

This initial calculation is done by the "create" script.

    Some benchmark results are presented below for the
    create script to give you an idea:

    *   256x256 gpu perlin noise calc. -> ~  1.7 ms (milliseconds)
    * 1024x1024 gpu perlin noise calc. -> ~ 13.5 ms
    * 2048x2048 gpu perlin noise calc. -> ~ 43.0 ms
    
    (Numbers may change for you depending on your CPU and GPU)

The extension caches the calculated noise in a buffer so the data lookup is as fast as looking up data from an array.

This look up actions can be done using the "gpu_noise" scripts. gpu_noise_*d scripts are fast and can be run several times on a single step event without reducing the performance of the application/game.

    Here are some benchmark results for looking up
    calculated noise data:
    
    Cached data lookup    -> ~ 0.005 ms per lookup
    Un-cached data lookup -> ~ 1.5 ms per lookup 
    
    (Numbers may change for you depending on your CPU)

Spliting the process into "create" and "lookup" gives developers a flexibility. Several noise maps can be created (for such as landmass, atmosphere, vegitation etc.) on a loading screen and look data up realtime with inexpensive scripts.

Usage

    // CREATE EVENT
    // create a noise using GPU
    landmass = gpu_noise_create(noisetype, seed, width, height);

    // or 
    // use create_ext script if you need more options
    landmass = gpu_noise_create(noisetype, seed, width, height, persistence, frequency, scale);

    // STEP or DRAW EVENT
    var value = gpu_noise_3d(landmass, x, y, z);

    // That's it. REMEMBER to delete the data from the memory using:
    gpu_noise_free(landmass);

Extras

    // if you need to create different chunks of noise, use offset script
    landmass = gpu_noise_offset(width, [height, z]);

    // if you get the GPU calculated noise as a surface,
    var surface = gpu_noise_to_surface(landmass);

    // REMEMBER to delete the data from the memory using:
    // This will delete the surface and the buffer.
    gpu_noise_free(landmass);

Extension Files

The package contains files related to the demonstration application. You don't need every file for the extension to function. Required files are GPU_Toolkit>GPU Noise scripts and the Shaders you will use.

Contributing

It's through your contributions that cbDataGUI will continue to improve. You can contribute in several ways.

Issues: Provide a detailed report of any bugs you encounter and open an issue.

Documentation: If you'd like to fix a typo or beef up the docs, you can fork the project, make your changes, and submit a pull request.

Code: Make a fix and submit it as a pull request. When making changes, add comments to describe the changes.

Author

Cem Baspinar

Thanks

Thanks to anyone who downloaded the extention from the marketplace.

Copyright and License

Copyright 2017 Cem Baspinar Code released under the MIT License.

noise's People

Contributors

aft avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

noise's Issues

[GMS1.4.999] Non-smooth noise

The noise simply isnt scalable and able to stay smooth. if you want chunked larger areas which are also smooth you simply are out of luck with this noise pack.

Example below:
https://gyazo.com/739413b6d32e408d85bfcd50509c6f36

In the example it's 11x11 chunks each of which hold 16x16 tiles/noise values. I've been working with the values to get them smooth for a few hours now and nothing seems to work well with out causing issues.

Compatibility to GMS2

After importing the Project to GMS2 and the generation of a lot of compatibility scripts I fixed some variable names which will otherwise result in a compile error (bool to _bool).
They belonged to the cbDataGUI

Crashes:

Every CPU function runs very slow (1-2 Fps) and it just show a small square in the top left corner (i'm not shure if this is intended).
The GPU functions run at about 4-5k Fps.

Maybe the compatibility Scripts slow everything down?

IDE Version: 2.2.3.436 Steam
My runtime: 2.2.3.344

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.