Last active
May 22, 2021 23:03
-
-
Save orihakatt/9ef2c07ec9f2f11cbbbc67bc3a29b3c7 to your computer and use it in GitHub Desktop.
歪曲収差の実現
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
precision highp float; | |
uniform vec2 resolution; | |
const float k1=-0.0625; | |
const float k2=0.; | |
void main(){ | |
vec2 uv = (gl_FragCoord.xy * 2.0 - resolution.xy) / min(resolution.x, resolution.y); | |
// 座標系を歪ませる部分 | |
float r = length(uv); | |
uv = vec2((1.+k1*r*r + k2*r*r*r*r)*uv.x, (1.+k1*r*r + k2*r*r*r*r)*uv.y); | |
// グリッドを作成する部分 | |
uv *= 5.; | |
vec2 gv = fract(uv); | |
vec3 col = vec3(0); | |
if (gv.x > 0.98 || gv.y > 0.98)col = vec3(1,0,0); | |
gl_FragColor = vec4(col, 1.0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment