Giter Site home page Giter Site logo

erkaman / glsl-worley Goto Github PK

View Code? Open in Web Editor NEW
86.0 4.0 6.0 378 KB

Worley noise implementation for WebGL shaders

Home Page: http://erkaman.github.io/glsl-worley/

License: Other

JavaScript 30.90% GLSL 69.10%
noise worley-noise cell-noise cellular-noise voronoi shader shaders webgl javascript glsl

glsl-worley's Introduction

glsl-worley

From this module, a GLSL implementation of Worley Noise written by Stefan Gustavson can be imported.

A demo can be found here

Usage

This module provides four functions, and they can be exported as

#pragma glslify: worley3D = require(glsl-worley/worley3D.glsl)
#pragma glslify: worley2x2x2 = require(glsl-worley/worley2x2x2.glsl)
#pragma glslify: worley2D = require(glsl-worley/worley2D.glsl)
#pragma glslify: worley2x2 = require(glsl-worley/worley2x2.glsl)

And then they can easily be used to generate a texture in a shader by doing something like:

  vec2 F = worley3D(vPosition, 1.0, false);
  float F1 = F.x;
  float F2 = F.y;
  gl_FragColor = vec4(vec3(F2-F1), 1.0);

worley3D is defined as vec2 worley3D(vec3 P, float jitter, bool manhattanDistance). It returns a vec2 where x is F1 and y is F2(it is assumed that the reader knows the meaning of these two). P is the input point, jitter is the amount of jitter in the pattern, and if manhattanDistance is true, then a manhattan distance is used to generate the pattern, instead of the usual Euclidean distance(this basically makes the noise appear more "jagged").

The remaining three functions take the same arguments, except that in the case of worley2D and worley2x2, P is a vec2.

worley2x2x2 is basically a faster version of worley3D. But be aware that it has some artifacts. In the same manner, worley2x2 is basically a faster version of worley2D, but with some potential artifacts.

glsl-worley's People

Contributors

erkaman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

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.