Skip to content

Instantly share code, notes, and snippets.

@darrinhenein
Created March 6, 2014 15:33
Show Gist options
  • Save darrinhenein/9392277 to your computer and use it in GitHub Desktop.
Save darrinhenein/9392277 to your computer and use it in GitHub Desktop.
RGB Split Shader
form sampler2D CC_Texture0;
varying vec2 v_texCoord;
uniform float u_displacement;
void main( ) {
vec4 color = texture2D( CC_Texture0, v_texCoord );
vec2 DisplacementScroll = vec2(u_displacement, -u_displacement);
vec2 texCoord2 = v_texCoord + DisplacementScroll;
DisplacementScroll = vec2(-u_displacement, u_displacement);
vec2 texCoord3 = v_texCoord - DisplacementScroll;
vec4 color1 = texture2D(CC_Texture0, v_texCoord);
vec4 color2 = texture2D(CC_Texture0, texCoord2);
vec4 color3 = texture2D(CC_Texture0, texCoord3);
gl_FragColor = vec4(color1.r,color2.g,color3.b,1.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment