Skip to content

Instantly share code, notes, and snippets.

@rasteron
Created September 13, 2015 05:44
Show Gist options
  • Save rasteron/d313b2c05fe9bd165e37 to your computer and use it in GitHub Desktop.
Save rasteron/d313b2c05fe9bd165e37 to your computer and use it in GitHub Desktop.
#include "Uniforms.glsl"
#include "Samplers.glsl"
#include "Transform.glsl"
#include "ScreenPos.glsl"
#ifdef COMPILEPS
uniform float cElapsedTime;
#endif
uniform sampler2D tex;
varying vec2 vScreenPos;
void VS()
{
mat4 modelMatrix = iModelMatrix;
vec3 worldPos = GetWorldPos(modelMatrix);
gl_Position = GetClipPos(worldPos);
vScreenPos = GetScreenPosPreDiv(gl_Position);
}
void PS()
{
float t = clamp(cElapsedTime / 6., 0., 1.);
vec2 coords = vScreenPos.st;
vec2 dir = coords - vec2(.5);
float dist = distance(coords, vec2(.5));
vec2 offset = dir * (sin(dist * 80. - cElapsedTime*15.) + .5) / 30.;
vec2 texCoord = coords + offset;
vec4 diffuse = texture2D(sDiffMap, texCoord);
vec4 mixin = texture2D(tex, texCoord);
gl_FragColor = mixin * t + diffuse * (1. - t);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment