name : 'ReactionDiffusion',
preset0 : function() { this.feed = 0.040; this.kill = 0.060; this.da = 1.00; this.db = 0.60; },
preset1 : function() { this.feed = 0.034; this.kill = 0.059; this.da = 1.00; this.db = 0.60; },
preset2 : function() { this.feed = 0.080; this.kill = 0.060; this.da = 1.00; this.db = 0.40; },
preset3 : function() { this.feed = 0.015; this.kill = 0.050; this.da = 1.00; this.db = 0.60; },
preset4 : function() { this.feed = 0.072; this.kill = 0.062; this.da = 0.50; this.db = 0.25; },
preset5 : function() { this.feed = 0.071; this.kill = 0.063; this.da = 0.40; this.db = 0.20; },
preset6 : function() { this.feed = 0.023; this.kill = 0.052; this.da = 0.50; this.db = 0.50; },
preset7 : function() { this.feed = 0.029; this.kill = 0.056; this.da = 0.60; this.db = 0.46; },
createCanvas(windowWidth, windowHeight, WEBGL);
gui.add(rdDef, 'da' , 0, 1 ).listen();
gui.add(rdDef, 'db' , 0, 1 ).listen();
gui.add(rdDef, 'feed' , 0.01, 0.09).listen();
gui.add(rdDef, 'kill' , 0.01, 0.09).listen();
gui.add(rdDef, 'dt' , 0, 1);
gui.add(rdDef, 'iter' , 1, 10);
gui.add(rdDef, 'preset0');
gui.add(rdDef, 'preset1');
gui.add(rdDef, 'preset2');
gui.add(rdDef, 'preset3');
gui.add(rdDef, 'preset4');
gui.add(rdDef, 'preset5');
gui.add(rdDef, 'preset6');
gui.add(rdDef, 'preset7');
gui.add(rdDef, 'reset' );
var gl = this._renderer.GL;
var VERSION = gl.getVersion();
gl.newExt(gl.getSupportedExtensions(), true);
fbo = gl.newFramebuffer();
,filter : [gl.NEAREST, gl.LINEAR]
var tex_w = ceil(width * SCREEN_SCALE);
var tex_h = ceil(height * SCREEN_SCALE);
tex.src = gl.newTexture(tex_w, tex_h, def);
tex.dst = gl.newTexture(tex_w, tex_h, def);
var fs_grayscott = shaderfiles["webgl"+VERSION+".fs_grayscott"];
var fs_display = shaderfiles["webgl"+VERSION+".fs_display"];
shader_grayscott = new Shader(gl, {fs:fs_grayscott});
shader_display = new Shader(gl, {fs:fs_display });
function windowResized() {
var tex_w = ceil(w * SCREEN_SCALE);
var tex_h = ceil(h * SCREEN_SCALE);
tex.src.resize(tex_w, tex_h);
tex.dst.resize(tex_w, tex_h);
function randomizeColors(){
var num = pallette.length /3;
for(var i = 1; i < num-1; i++){
translate(-width/2, -height/2, 0);
var w = tex.dst.w / SCREEN_SCALE;
var h = tex.dst.h / SCREEN_SCALE;
shader_display.viewport(0, 0, w, h);
shader_display.uniformF('PALLETTE', pallette, 7);
shader_display.uniformT('tex', tex.src);
shader_display.uniformF('wh_rcp', [1.0/w, 1.0/h]);
gl.clearColor(1.0, 0.0, 0.0, 0.0);
gl.clear(gl.COLOR_BUFFER_BIT);
gl.disable(gl.DEPTH_TEST);
ellipse(-100, 0, 100, 100);
ellipse(+100, 0, 100, 100);
ellipse(0, -100, 100, 100);
ellipse(0, +100, 100, 100);
for(var i = 0; i < rdDef.iter; i++){
gl.clearColor(1.0, 0.0, 0.0, 0.0);
gl.clear(gl.COLOR_BUFFER_BIT);
gl.disable(gl.DEPTH_TEST);
shader_grayscott.begin();
shader_grayscott.uniformF("dA" , [rdDef.da]);
shader_grayscott.uniformF("dB" , [rdDef.db]);
shader_grayscott.uniformF("feed" , [rdDef.feed]);
shader_grayscott.uniformF("iter" , [i]);
shader_grayscott.uniformF("kill" , [rdDef.kill]);
shader_grayscott.uniformF("dt" , [rdDef.dt]);
shader_grayscott.uniformF("wh_rcp", [1.0/w, 1.0/h]);
shader_grayscott.uniformT("tex" , tex.src);
ellipse(mouseX, mouseY, 50, 50);
var loadJS = function(filename){
var script = document.createElement("script");
script.setAttribute("type","text/javascript");
script.setAttribute("src", filename);
document.getElementsByTagName("head")[0].appendChild(script);
loadJS("https://rawgit.com/diwi/p5.EasyCam/master/dwgl.js");
loadJS("https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.6.5/dat.gui.min.js");
document.oncontextmenu = function() { return false; }
document.onmousedown = function() { return false; }