Created
September 28, 2017 13:01
Star
You must be signed in to star a gist
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
float k1 = 0.0; | |
float k2 = 0.0; | |
float k3 = 0.0; | |
float p1 = 0.0; | |
float p2 = 0.0; | |
const int lk = 12; | |
void mainImage( out vec4 fragColor, in vec2 fragCoord ) | |
{ | |
vec2 uv = fragCoord.xy / iResolution.xy; | |
vec2 t = uv; | |
t -= 0.5; | |
float r = sqrt(t.x * t.x + t.y * t.y); | |
float r2 = pow(r, 2.0f); | |
float f = (1.0f + r2 * k1) + (k2 * pow(r, 4.0f)) + (k3 * pow(r, 6.0f)); | |
uv = f * t + 0.5f; | |
float xy = uv.x * uv.y; | |
uv.x += 2.0f * p1 * xy + p2 * (r2 + 2.0f * pow(uv.x, 2.0f)); | |
uv.y += p1 * (r2 + 2.0f * pow(uv.y, 2.0f)) + 2.0f * p2 * xy; | |
fragColor = texture(iChannel0, uv); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment