Skip to content

Commit 76d1903

Browse files
committed
add black white example
Signed-off-by: Umair Khan <[email protected]>
1 parent 9257f2e commit 76d1903

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import in.omerjerk.processing.video.android.*;
2+
3+
Capture cap;
4+
5+
PShader bwShader;
6+
7+
void setup() {
8+
9+
fullscreen(P2D);
10+
11+
cap = new Capture(this);
12+
String[] list = cap.list();
13+
cap.setCamera(list[0]);
14+
cap.start();
15+
bwShader = loadShader("fragmentShader.glsl");
16+
}
17+
18+
void draw() {
19+
shader(bwShader);
20+
image(cap, 0, 0);
21+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#ifdef GL_ES
2+
precision mediump float;
3+
precision mediump int;
4+
#endif
5+
6+
#define PROCESSING_TEXTURE_SHADER
7+
8+
uniform sampler2D texture;
9+
10+
varying vec4 vertColor;
11+
varying vec4 vertTexCoord;
12+
13+
const vec4 lumcoeff = vec4(0.299, 0.587, 0.114, 0);
14+
15+
void main() {
16+
vec4 col = texture2D(texture, vertTexCoord.st);
17+
float lum = dot(col, lumcoeff);
18+
if (0.5 < lum) {
19+
gl_FragColor = vertColor;
20+
} else {
21+
gl_FragColor = vec4(0, 0, 0, 1);
22+
}
23+
}

0 commit comments

Comments
 (0)