GithubHelp home page GithubHelp logo

jimothy001 / grayscottperlin Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 71.88 MB

Reaction diffusion Gray Scott model over a Perlin noise vector field

License: MIT License

Procfile 0.05% JavaScript 42.33% HTML 13.38% CSS 4.43% GLSL 39.80%
glsl gray-scott-model p5js perlin-noise reaction-diffusion

grayscottperlin's Introduction

Reaction Diffusion Gray Scott Model with Perlin Noise

A running instance of this experiment can be found here: https://gray-scott-perlin.herokuapp.com/

This is an experiment to see what happens when the Gray Scott model of reaction diffusion is subjected to directional biases (currents), as produced by a perlin noise vector field.

The effect of the noise is most apparent at tight vector circulation points.

Reaction Diffusion With Local Biases

Reaction diffusion is a simulation of how two chemicals react to each other and diffuse when combined.

An outstanding explainer for reaction diffusion can be found here: http://karlsims.com/rd.html

The reaction diffusion equations use 2D Laplacian functions that describe diffusion behaviors for chemicals A and B across a 2D array. They are convolutional operations, insofar as the state of each cell is based on its neighbors. Weights are symmetrical and add up to 1.

Image below illustrates basic 2d Laplacian operations for reaction diffusion, where:

2A = cell value of chemical A

2B = cell value of chemical B

CA = weighted influence of neighbor cell value A

CB = weighted influence of neighbor cell value B

w = weight of neighbor cell value A or B influence. Orthogonal neighbors are weighted at 0.2 and diagonal neighbors are weighted at 0.05.

A local bias (Perlin noise) can be applied to diffusion functions by modifying the base weights with:

For chemical A: the magnitude of a vector that is the sum of the bias vector and neighbor direction vector, multiplied by the base weight and an arbitrary scalar.

For chemical B: the magnitude of a vector that is the difference between the bias vector and neighbor direction vector, multiplied by the base weight and an arbitrary scalar. This is effectively a mirrored version of the chemical A weights.

The resulting modified weights for chemicals A and B must be normalized so that they add up to 1.

NOTE: Vector Y positive direction is reversed relative to row positive direction in column/row notation.

NOTE: Perlin noise bias is generated and applied at the level of the reaction diffusion cell, but the linework that visually represents it in the app is averaged within a bin and drawn at a larger scale for human readability.

Image below illustrates 2d biased Laplacian operations for reaction diffusion, where:

2A = cell value of chemical A

2B = cell value of chemical B

CA = weighted influence of neighbor cell value A

CB = weighted influence of neighbor cell value B

WA = biased weight of neighbor cell value A influence

WB = biased weight of neighbor cell value B influence

w = base weight of neighbor cell value A or B influence. Orthogonal neighbors are weighted at 0.2 and diagonal neighbors are weighted at 0.05.

$\vec{d}$ = direction to neighbor cell from center cell where Laplacian result is being calculated

$\vec{k}$ = local bias vector

s = global arbitrary bias scalar, which can be thought of as current strength

Interaction

In addition to 'painting' more solution B into solution A, you are able to experiment with different parameters for perlin vectors, reaction diffusion, and paint brush size.

Acknowledgements

Karl Sims, Reaction Diffusion Tutorial: http://karlsims.com/rd.html

Daniel Shiffman, the Coding Train: https://youtu.be/BV9ny785UNc

Pmneila, jsexp: https://github.com/pmneila/jsexp

grayscottperlin's People

Contributors

jimothy001 avatar jyamadacm avatar

Stargazers

 avatar

Watchers

 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.