2010-04-04 21:57:58 -04:00
|
|
|
! Copyright (C) 2010 Erik Charlebois.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2010-04-04 23:52:09 -04:00
|
|
|
USING: gpu.render gpu.shaders gpu.util ;
|
2010-04-04 21:57:58 -04:00
|
|
|
IN: gpu.effects.step
|
|
|
|
|
|
|
|
GLSL-SHADER: step-fragment-shader fragment-shader
|
|
|
|
const vec4 luminance = vec4(0.3, 0.59, 0.11, 0.0);
|
|
|
|
uniform sampler2D texture;
|
|
|
|
uniform sampler2D ramp;
|
|
|
|
varying vec2 texcoord;
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
vec4 col = texture2D(texture, texcoord);
|
|
|
|
float l = dot(col, luminance);
|
|
|
|
gl_FragColor = texture2D(ramp, vec2(l, 0.0));
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
UNIFORM-TUPLE: step-uniforms
|
|
|
|
{ "texture" texture-uniform f }
|
|
|
|
{ "ramp" texture-uniform f } ;
|
|
|
|
|
|
|
|
GLSL-PROGRAM: step-program window-vertex-shader step-fragment-shader window-vertex-format ;
|