Adding the shader examples

This commit is contained in:
Casey Reas
2012-08-31 17:13:27 +00:00
parent 8b1e862c35
commit 86d96c363d
25 changed files with 1128 additions and 0 deletions

View 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);
}

View 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;
}