Giter Club home page Giter Club logo

grunge's Introduction

Grunge Build Status

Grunge is a pseudo-random coherent noise library in the spirit of libnoise, ACL, and the Coherent Noise Library. Unlike earlier libraries, it uses the [Simplex Noise] (http://en.wikipedia.org/wiki/Simplex_noise) algorithm, and should have better performance as a result. Hopefully, it will one day contain more features as well.

The API should be familiar to users of libnoise and the Coherent Noise Library, but is subject to change without notice at this point in the project -- which is currently in the very early stages of development.

Example

The following writes a PGM file using the PinkNoise generator.

use std::io::{File, Truncate, Write};
use cgmath::vector::Vector2;
use grunge::module::{NoiseModule, PinkNoise};

let noise = PinkNoise::new(0u);
let p = Path::new("example.pgm");

let mut file = match File::open_mode(&p, Truncate, Write) {
    Ok(f) => f,
    Err(e) => fail!("--- File error: {}", e),
};

// Write the PGM header first. P5 is for binary data (i.e. u8).
let _ = file.write_str(format!("P5\n{0} {1}\n{2}\n", 500u, 500u, 255u).as_slice());
    
// Write a sample of 500x500 pixels to the image file
for y in range(-250i, 250i) {
    for x in range(-250i, 250i) {
        let point = Vector2::new((x as f32) / 100.0, (y as f32) / 100.0);
        let tmp = noise.generate_2d(point).unwrap() * 0.15 + 0.5; // Usually fits in [0, 1]
        let _ = file.write_u8((tmp * 255.0) as u8);
    }
}

println!("--- Output image written to example.pgm");

In case you can't open the PGM format, ImageMagick's convert example.pgm example.png may do the trick.

Planned Features

  • Simplex noise primitives in 2D, 3D, and 4D.
  • "Fractal" noise types: pink noise, billow niose, and ridged multifractal noise.
  • Voronoi noise types
  • Geometric noise types: sphere, cylinder, aribtrary functions.
  • Modifier types: add, subtract, multiply, turbulence, and so on.
  • Helpful utilities for generating images, textures, and so on.
  • Paralellization when it improves performance.
  • Many examples.
  • Language bindings?

grunge's People

Contributors

atheriel avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

jurya

grunge's Issues

1.0 Release Checklist

In addition to closing other issues, a full 1.0 release should also included:

  • A license
  • A proper README file that corresponds to the landing page of the rustdoc documentation.

Consider using Rc instead of Box for modifying modules.

It is not clear that owner pointers are better than shared pointers, especially if one wanted to update the source module. Since this should be memory safe, that might be a more sensible option than cloning boxes, as is done at the moment.

Re-export cgmath vectors from the library.

I noticed while writing the examples that having extern crate cgmath at the top of every file that uses even basic functionality is a little odd. This could be fixed by using Rust's re-exporting features. I know this approach is recommended by some other Rust game math libraries.

Implement seeds in the simplex functions.

Right now seed is an unused argument to the simplex function. It should be fairly easy to use the seed as an offset in the permutation, which would give 289 variants instead of the current 1.

Implement the modifying noise modules.

Those provided by Libnoise and CoherentNoise are equivalent to:

  • ScaledBiasedNoise (added as of 178fca0)
  • ClampedNoise (added as of 178fca0)
  • RotatedNoise (added as of 6935a1a)
  • TranslatedNoise (added as of b97f076)
  • PerturbedNoise
  • ModifierNoise, which takes a closure function (added as of 6138194)
  • TurbulentNoise, which may belong with the fractal group instead

Implement the classic examples.

  • Perlin's examples:
    • Marble texture
    • Water, Clouds, Fire spheres
    • The corona movie
  • The "wood" texture of libnoise.
  • Toy world generation.

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.