Initial Commit

This commit is contained in:
plane000
2018-04-20 10:15:15 +01:00
parent 49150ccfe4
commit 62101e8e61
2870 changed files with 520122 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
/**
* Edge Detection
*
* Change the default shader to apply a simple, custom edge detection filter.
*
* Press the mouse to switch between the custom and default shader.
*/
PShader edges;
PImage img;
boolean enabled = true;
void setup() {
size(640, 360, P2D);
img = loadImage("leaves.jpg");
edges = loadShader("edges.glsl");
}
void draw() {
if (enabled == true) {
shader(edges);
}
image(img, 0, 0);
}
void mousePressed() {
enabled = !enabled;
if (!enabled == true) {
resetShader();
}
}

View File

@@ -0,0 +1,40 @@
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
#define PROCESSING_TEXTURE_SHADER
uniform sampler2D texture;
uniform vec2 texOffset;
varying vec4 vertColor;
varying vec4 vertTexCoord;
void main(void) {
// Grouping texcoord variables in order to make it work in the GMA 950. See post #13
// in this thread:
// http://www.idevgames.com/forums/thread-3467.html
vec2 tc0 = vertTexCoord.st + vec2(-texOffset.s, -texOffset.t);
vec2 tc1 = vertTexCoord.st + vec2( 0.0, -texOffset.t);
vec2 tc2 = vertTexCoord.st + vec2(+texOffset.s, -texOffset.t);
vec2 tc3 = vertTexCoord.st + vec2(-texOffset.s, 0.0);
vec2 tc4 = vertTexCoord.st + vec2( 0.0, 0.0);
vec2 tc5 = vertTexCoord.st + vec2(+texOffset.s, 0.0);
vec2 tc6 = vertTexCoord.st + vec2(-texOffset.s, +texOffset.t);
vec2 tc7 = vertTexCoord.st + vec2( 0.0, +texOffset.t);
vec2 tc8 = vertTexCoord.st + vec2(+texOffset.s, +texOffset.t);
vec4 col0 = texture2D(texture, tc0);
vec4 col1 = texture2D(texture, tc1);
vec4 col2 = texture2D(texture, tc2);
vec4 col3 = texture2D(texture, tc3);
vec4 col4 = texture2D(texture, tc4);
vec4 col5 = texture2D(texture, tc5);
vec4 col6 = texture2D(texture, tc6);
vec4 col7 = texture2D(texture, tc7);
vec4 col8 = texture2D(texture, tc8);
vec4 sum = 8.0 * col4 - (col0 + col1 + col2 + col3 + col5 + col6 + col7 + col8);
gl_FragColor = vec4(sum.rgb, 1.0) * vertColor;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB