Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@rasteron
Last active February 24, 2016 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rasteron/323354d0e7152e3cd905 to your computer and use it in GitHub Desktop.
Save rasteron/323354d0e7152e3cd905 to your computer and use it in GitHub Desktop.
#include "Uniforms.glsl"
#include "Samplers.glsl"
#include "Transform.glsl"
#include "ScreenPos.glsl"
#include "Lighting.glsl"
varying vec2 vScreenPos;
uniform float vx_offset;
void VS()
{
mat4 modelMatrix = iModelMatrix;
vec3 worldPos = GetWorldPos(modelMatrix);
gl_Position = GetClipPos(worldPos);
vScreenPos = GetScreenPosPreDiv(gl_Position);
}
void PS()
{
vec2 uv = vScreenPos.xy;
vec3 tc = vec3(1.0, 0.0, 0.0);
vec3 pixcol = texture2D(sDiffMap, uv).rgb;
vec3 colors[3];
colors[0] = vec3(0.,0.,1.);
colors[1] = vec3(1.,1.,0.);
colors[2] = vec3(1.,0.,0.);
float lum = (pixcol.r+pixcol.g+pixcol.b)/3.;
int ix = (lum < 0.5)? 0:1;
tc = mix(colors[ix],colors[ix+1],(lum-float(ix)*0.5)/0.5);
gl_FragColor = vec4(tc, 1.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment