mirror of
https://github.com/processing/processing4.git
synced 2026-01-30 03:41:15 +01:00
updated conway example
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// GLSL version of Conway's game of life, ported from GLSL sandbox:
|
||||
// http://glsl.heroku.com/e#207.3
|
||||
// Exemplifies the use of the buffer uniform in the shader, that gives
|
||||
// access to the previous frame.
|
||||
// Exemplifies the use of the ppixels uniform in the shader, that gives
|
||||
// access to the pixels of the previous frame.
|
||||
PShader conway;
|
||||
PGraphics pg;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ precision highp float;
|
||||
uniform float time;
|
||||
uniform vec2 mouse;
|
||||
uniform vec2 resolution;
|
||||
uniform sampler2D buffer;
|
||||
uniform sampler2D ppixels;
|
||||
|
||||
vec4 live = vec4(0.5,1.0,0.7,1.);
|
||||
vec4 dead = vec4(0.,0.,0.,1.);
|
||||
@@ -28,15 +28,15 @@ void main( void ) {
|
||||
}
|
||||
} else {
|
||||
float sum = 0.;
|
||||
sum += texture2D(buffer, position + pixel * vec2(-1., -1.)).g;
|
||||
sum += texture2D(buffer, position + pixel * vec2(-1., 0.)).g;
|
||||
sum += texture2D(buffer, position + pixel * vec2(-1., 1.)).g;
|
||||
sum += texture2D(buffer, position + pixel * vec2(1., -1.)).g;
|
||||
sum += texture2D(buffer, position + pixel * vec2(1., 0.)).g;
|
||||
sum += texture2D(buffer, position + pixel * vec2(1., 1.)).g;
|
||||
sum += texture2D(buffer, position + pixel * vec2(0., -1.)).g;
|
||||
sum += texture2D(buffer, position + pixel * vec2(0., 1.)).g;
|
||||
vec4 me = texture2D(buffer, position);
|
||||
sum += texture2D(ppixels, position + pixel * vec2(-1., -1.)).g;
|
||||
sum += texture2D(ppixels, position + pixel * vec2(-1., 0.)).g;
|
||||
sum += texture2D(ppixels, position + pixel * vec2(-1., 1.)).g;
|
||||
sum += texture2D(ppixels, position + pixel * vec2(1., -1.)).g;
|
||||
sum += texture2D(ppixels, position + pixel * vec2(1., 0.)).g;
|
||||
sum += texture2D(ppixels, position + pixel * vec2(1., 1.)).g;
|
||||
sum += texture2D(ppixels, position + pixel * vec2(0., -1.)).g;
|
||||
sum += texture2D(ppixels, position + pixel * vec2(0., 1.)).g;
|
||||
vec4 me = texture2D(ppixels, position);
|
||||
|
||||
if (me.g <= 0.1) {
|
||||
if ((sum >= 2.9) && (sum <= 3.1)) {
|
||||
|
||||
Reference in New Issue
Block a user