mirror of
https://github.com/processing/processing4.git
synced 2026-02-17 04:15:36 +01:00
Adding the shader examples
This commit is contained in:
41
java/examples/Topics/Shaders/BadPrint/data/BadPrintFrag.glsl
Normal file
41
java/examples/Topics/Shaders/BadPrint/data/BadPrintFrag.glsl
Normal file
@@ -0,0 +1,41 @@
|
||||
// Copyright (C) 2007 Dave Griffiths
|
||||
// Licence: GPLv2 (see COPYING)
|
||||
// Fluxus Shader Library
|
||||
// ---------------------
|
||||
// BadPrint NPR Shader
|
||||
// This shader tries to emulate the effect
|
||||
// of a bad printing process. Can be controlled
|
||||
// with different settings for RGB
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform vec3 Scale;
|
||||
uniform vec3 Offset;
|
||||
uniform vec3 Register;
|
||||
uniform vec3 Size;
|
||||
|
||||
varying vec3 N;
|
||||
varying vec3 P;
|
||||
varying vec4 S;
|
||||
varying vec3 L;
|
||||
|
||||
void main() {
|
||||
vec3 l = normalize(L);
|
||||
vec3 n = normalize(N);
|
||||
vec2 p = S.xy;
|
||||
|
||||
vec2 sr = p * Size.r + Register.r;
|
||||
vec2 sg = p * Size.g + Register.g;
|
||||
vec2 sb = p * Size.b + Register.b;
|
||||
|
||||
float diffuse = dot(l,n);
|
||||
|
||||
float r = (sin(sr.x) + cos(sr.y)) * Scale.r + Offset.r + diffuse;
|
||||
float g = (sin(sg.x) + cos(sg.y)) * Scale.g + Offset.g + diffuse;
|
||||
float b = (sin(sb.x) + cos(sb.y)) * Scale.b + Offset.b + diffuse;
|
||||
|
||||
gl_FragColor = vec4(step(0.5, r), step(0.5, g), step(0.5, b), 1);
|
||||
}
|
||||
30
java/examples/Topics/Shaders/BadPrint/data/BadPrintVert.glsl
Normal file
30
java/examples/Topics/Shaders/BadPrint/data/BadPrintVert.glsl
Normal file
@@ -0,0 +1,30 @@
|
||||
// Copyright (C) 2007 Dave Griffiths
|
||||
// Licence: GPLv2 (see COPYING)
|
||||
// Fluxus Shader Library
|
||||
// ---------------------
|
||||
// BadPrint NPR Shader
|
||||
// This shader tries to emulate the effect
|
||||
// of a bad printing process. Can be controlled
|
||||
// with different settings for RGB
|
||||
|
||||
uniform mat4 projectionMatrix;
|
||||
uniform mat4 projmodelviewMatrix;
|
||||
uniform mat3 normalMatrix;
|
||||
|
||||
uniform vec4 lightPosition[8];
|
||||
|
||||
attribute vec4 inVertex;
|
||||
attribute vec3 inNormal;
|
||||
|
||||
varying vec3 N;
|
||||
varying vec3 P;
|
||||
varying vec4 S;
|
||||
varying vec3 L;
|
||||
|
||||
void main() {
|
||||
N = normalize(normalMatrix * inNormal);
|
||||
P = inVertex.xyz;
|
||||
gl_Position = projmodelviewMatrix * inVertex;
|
||||
L = vec3(lightPosition[0] - gl_Position);
|
||||
S = projectionMatrix * gl_Position;
|
||||
}
|
||||
Reference in New Issue
Block a user