Created
November 21, 2017 17:34
-
-
Save alijaya/b6530b4a82b6e264b661e92665faeb49 to your computer and use it in GitHub Desktop.
Natron Wave GLSL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define TAU 6.2831853072 | |
uniform vec2 origin = vec2(0.0, 0.0); | |
uniform float direction = 0.0; | |
uniform float amplitude = 10.0; | |
uniform float length = 10.0; | |
uniform float evolution = 0.0; | |
vec2 distanceDirection(vec2 pos) { | |
float angle = direction * TAU; | |
vec2 normal = vec2(cos(angle), sin(angle)); | |
vec2 relative = pos - origin; | |
return vec2(dot(normal, relative), angle + TAU / 4); | |
} | |
vec2 generateShift(vec2 pos) { | |
vec2 dd = distanceDirection(pos); | |
float shift = amplitude * sin(dd.x / length - evolution * TAU); | |
return vec2(shift * cos(dd.y), shift * sin(dd.y)); | |
} | |
void mainImage( out vec4 fragColor, in vec2 fragCoord ) { | |
vec2 shift = generateShift(fragCoord.xy / iRenderScale) * iRenderScale; | |
fragColor = texture2D( iChannel0, (fragCoord.xy + shift) / iResolution.xy); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define TAU 6.2831853072 | |
uniform vec2 origin = vec2(0.0, 0.0); | |
uniform float amplitude = 10.0; | |
uniform float length = 10.0; | |
uniform float evolution = 0.0; | |
vec2 distanceDirection(vec2 pos) { | |
vec2 relative = pos - origin; | |
float distance = length(relative); | |
float angle = atan(relative.y, relative.x); | |
return vec2(distance, angle + TAU / 4); | |
} | |
vec2 generateShift(vec2 pos) { | |
vec2 dd = distanceDirection(pos); | |
float shift = amplitude * sin(dd.x / length - evolution * TAU); | |
return vec2(shift * cos(dd.y), shift * sin(dd.y)); | |
} | |
void mainImage( out vec4 fragColor, in vec2 fragCoord ) { | |
vec2 shift = generateShift(fragCoord.xy / iRenderScale) * iRenderScale; | |
fragColor = texture2D( iChannel0, (fragCoord.xy + shift) / iResolution.xy); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment