From df096b4b4e15ac150fd582baa0521eacdf8d86e8 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 2 Feb 2016 08:23:02 +0100 Subject: examples: fix indentation --- examples/checkers.frag | 32 +++++++++---------- examples/polygon.frag | 46 +++++++++++++-------------- examples/snail.frag | 34 ++++++++++---------- examples/square-in-circle.frag | 62 ++++++++++++++++++------------------ examples/square-in-square.frag | 72 +++++++++++++++++++++--------------------- examples/square-ring.frag | 34 ++++++++++---------- examples/square-ring2.frag | 44 +++++++++++++------------- examples/squares.frag | 38 +++++++++++----------- examples/supersnail.frag | 32 +++++++++---------- examples/symmetry.frag | 34 ++++++++++---------- examples/torus.frag | 34 ++++++++++---------- 11 files changed, 231 insertions(+), 231 deletions(-) (limited to 'examples') diff --git a/examples/checkers.frag b/examples/checkers.frag index c9b56ff..a561842 100644 --- a/examples/checkers.frag +++ b/examples/checkers.frag @@ -11,29 +11,29 @@ const float PI = 3.14159265358979323846; mat2 rot(float a) { - return mat2( - cos(a), -sin(a), - sin(a), cos(a) - ); + return mat2( + cos(a), -sin(a), + sin(a), cos(a) + ); } void main(void) { - vec2 m = res/2; - float s = min(m.x, m.y); - vec2 p = (gl_FragCoord.xy - m) / s; + vec2 m = res/2; + float s = min(m.x, m.y); + vec2 p = (gl_FragCoord.xy - m) / s; - float repeat = 8.0; - float time_mod = mod(time / 200, repeat); - float w = 20 * pow(2, time_mod); + float repeat = 8.0; + float time_mod = mod(time / 200, repeat); + float w = 20 * pow(2, time_mod); - float f = time_mod / repeat; - vec2 pr = p * rot(f * PI/2); + float f = time_mod / repeat; + vec2 pr = p * rot(f * PI/2); - float tp = mod(floor(log2(abs(pr.x/w)) + floor(log2(abs(pr.y/w)))), 2); + float tp = mod(floor(log2(abs(pr.x/w)) + floor(log2(abs(pr.y/w)))), 2); - float darken = min(min(abs(pr.x), abs(pr.y)) / 0.01, 1.0); + float darken = min(min(abs(pr.x), abs(pr.y)) / 0.01, 1.0); - float scene = tp * darken; + float scene = tp * darken; - fragColor = vec4(vec3(1, 1, 1) * scene, 1); + fragColor = vec4(vec3(1, 1, 1) * scene, 1); } diff --git a/examples/polygon.frag b/examples/polygon.frag index 20d5cdc..a018865 100644 --- a/examples/polygon.frag +++ b/examples/polygon.frag @@ -11,44 +11,44 @@ const float PI = 3.14159265358979323846; mat2 rot(float a) { - return mat2( - cos(a), -sin(a), - sin(a), cos(a) - ); + return mat2( + cos(a), -sin(a), + sin(a), cos(a) + ); } float poly(float n, vec2 m, float r, float rt, vec2 p) { - vec2 diff = (m - p) * rot(rt); - float d = length(diff); - float alpha = PI / n; - float gamma = mod(abs(atan(diff.x, diff.y)), alpha*2); + vec2 diff = (m - p) * rot(rt); + float d = length(diff); + float alpha = PI / n; + float gamma = mod(abs(atan(diff.x, diff.y)), alpha*2); - if (gamma > alpha) - gamma -= 2*alpha; + if (gamma > alpha) + gamma -= 2*alpha; - float r2 = r * cos(alpha) / cos(gamma); + float r2 = r * cos(alpha) / cos(gamma); - return clamp((r2 - d)*sharpness, 0.0, 1.0); + return clamp((r2 - d)*sharpness, 0.0, 1.0); } float poly_d(float n, vec2 m, float r, float rt, vec2 p) { - return poly(n, m, r, rt, p) - poly(n, m, r - 1/sharpness, rt, p); + return poly(n, m, r, rt, p) - poly(n, m, r - 1/sharpness, rt, p); } void main(void) { - vec2 m = res/2; - float s = min(m.x, m.y); - vec2 p = (gl_FragCoord.xy - m) / s; + vec2 m = res/2; + float s = min(m.x, m.y); + vec2 p = (gl_FragCoord.xy - m) / s; - float scene = 0; + float scene = 0; - float c; + float c; - c = poly_d(5 - 3*cos(time/1000), vec2(0, 0), 0.5, PI * time/1000, p); - scene = abs(scene - c); + c = poly_d(5 - 3*cos(time/1000), vec2(0, 0), 0.5, PI * time/1000, p); + scene = abs(scene - c); - c = poly_d(5 - 3*cos(time/1000), vec2(0, 0), 0.5, -PI * time/1000, p); - scene = abs(scene - c); + c = poly_d(5 - 3*cos(time/1000), vec2(0, 0), 0.5, -PI * time/1000, p); + scene = abs(scene - c); - fragColor = vec4(vec3(1, 1, 1) * scene, 1); + fragColor = vec4(vec3(1, 1, 1) * scene, 1); } diff --git a/examples/snail.frag b/examples/snail.frag index 491c53a..5513d34 100644 --- a/examples/snail.frag +++ b/examples/snail.frag @@ -8,34 +8,34 @@ uniform float time; const float sharpness = 300; mat2 rot(float a) { - return mat2( - cos(a), -sin(a), - sin(a), cos(a) - ); + return mat2( + cos(a), -sin(a), + sin(a), cos(a) + ); } float circle(vec2 m, float r, vec2 p) { - vec2 diff = m - p; - float d = sqrt(dot(diff, diff)); + vec2 diff = m - p; + float d = sqrt(dot(diff, diff)); - return clamp((r - d)*sharpness, 0.0, 1.0); + return clamp((r - d)*sharpness, 0.0, 1.0); } float circle_d(vec2 m, float r, vec2 p) { - return circle(m, r, p) - circle(m, r - 1/sharpness, p); + return circle(m, r, p) - circle(m, r - 1/sharpness, p); } void main(void) { - vec2 m = res/2; - float s = min(m.x, m.y); - vec2 p = (gl_FragCoord.xy - m) / s; + vec2 m = res/2; + float s = min(m.x, m.y); + vec2 p = (gl_FragCoord.xy - m) / s; - float scene = 0; + float scene = 0; - for (int i = 1; i <= 50; i++) { - float c = circle_d(vec2(0.5, 0) * rot(time/500/i), 0.1 + 0.005*i, p); - scene = abs(scene - c); - } + for (int i = 1; i <= 50; i++) { + float c = circle_d(vec2(0.5, 0) * rot(time/500/i), 0.1 + 0.005*i, p); + scene = abs(scene - c); + } - fragColor = vec4(vec3(1, 1, 1) * scene, 1); + fragColor = vec4(vec3(1, 1, 1) * scene, 1); } diff --git a/examples/square-in-circle.frag b/examples/square-in-circle.frag index ad6c615..731eca6 100644 --- a/examples/square-in-circle.frag +++ b/examples/square-in-circle.frag @@ -11,56 +11,56 @@ const float PI = 3.14159265358979323846; mat2 rot(float a) { - return mat2( - cos(a), -sin(a), - sin(a), cos(a) - ); + return mat2( + cos(a), -sin(a), + sin(a), cos(a) + ); } float circle(vec2 m, float r, vec2 p) { - vec2 diff = m - p; - float d = sqrt(dot(diff, diff)); + vec2 diff = m - p; + float d = sqrt(dot(diff, diff)); - return clamp((r - d)*sharpness, 0.0, 1.0); + return clamp((r - d)*sharpness, 0.0, 1.0); } float circle_d(vec2 m, float r, vec2 p) { - return circle(m, r, p) - circle(m, r - 1/sharpness, p); + return circle(m, r, p) - circle(m, r - 1/sharpness, p); } float square(vec2 m, float a, float r, vec2 p) { - vec2 diff = abs((m - p) * rot(r)); - float d = max(diff.x, diff.y); + vec2 diff = abs((m - p) * rot(r)); + float d = max(diff.x, diff.y); - return clamp((a - d)*sharpness, 0.0, 1.0); + return clamp((a - d)*sharpness, 0.0, 1.0); } void main(void) { - vec2 m = res/2; - float s = min(m.x, m.y); - vec2 p = (gl_FragCoord.xy - m) / s; + vec2 m = res/2; + float s = min(m.x, m.y); + vec2 p = (gl_FragCoord.xy - m) / s; - float scene = 0; + float scene = 0; - int n = 20; - float b = 1; - float alpha = 0; - for (int i = 0; i < n; i++) { - float c; + int n = 20; + float b = 1; + float alpha = 0; + for (int i = 0; i < n; i++) { + float c; - c = circle_d(vec2(0, 0), b, p); - scene = abs(scene - c); + c = circle_d(vec2(0, 0), b, p); + scene = abs(scene - c); - float delta = mod(time/5000, PI/2); - alpha = mod(alpha + delta, PI/2); - b /= sqrt(2); + float delta = mod(time/5000, PI/2); + alpha = mod(alpha + delta, PI/2); + b /= sqrt(2); - c = square(vec2(0, 0), b, alpha, p); - scene = abs(scene - c); + c = square(vec2(0, 0), b, alpha, p); + scene = abs(scene - c); - c = square(vec2(0, 0), b, -alpha, p); - scene = abs(scene - c); - } + c = square(vec2(0, 0), b, -alpha, p); + scene = abs(scene - c); + } - fragColor = vec4(vec3(1, 1, 1) * scene, 1); + fragColor = vec4(vec3(1, 1, 1) * scene, 1); } diff --git a/examples/square-in-square.frag b/examples/square-in-square.frag index cc00388..07343d8 100644 --- a/examples/square-in-square.frag +++ b/examples/square-in-square.frag @@ -11,64 +11,64 @@ const float PI = 3.14159265358979323846; mat2 rot(float a) { - return mat2( - cos(a), -sin(a), - sin(a), cos(a) - ); + return mat2( + cos(a), -sin(a), + sin(a), cos(a) + ); } float circle(vec2 m, float r, vec2 p) { - vec2 diff = m - p; - float d = sqrt(dot(diff, diff)); + vec2 diff = m - p; + float d = sqrt(dot(diff, diff)); - return clamp((r - d)*sharpness, 0.0, 1.0); + return clamp((r - d)*sharpness, 0.0, 1.0); } float circle_d(vec2 m, float r, vec2 p) { - return circle(m, r, p) - circle(m, r - 1/sharpness, p); + return circle(m, r, p) - circle(m, r - 1/sharpness, p); } float square(vec2 m, float a, float r, vec2 p) { - vec2 diff = abs((m - p) * rot(r)); - float d = max(diff.x, diff.y); + vec2 diff = abs((m - p) * rot(r)); + float d = max(diff.x, diff.y); - return clamp((a - d)*sharpness, 0.0, 1.0); + return clamp((a - d)*sharpness, 0.0, 1.0); } float square_d(vec2 m, float a, float r, vec2 p) { - return square(m, a, r, p) - square(m, a - 1/sharpness, r, p); + return square(m, a, r, p) - square(m, a - 1/sharpness, r, p); } void main(void) { - vec2 m = res/2; - float s = min(m.x, m.y); - vec2 p = (gl_FragCoord.xy - m) / s; + vec2 m = res/2; + float s = min(m.x, m.y); + vec2 p = (gl_FragCoord.xy - m) / s; - float scene = 0; + float scene = 0; - int n = 20; - float b = 1; - float alpha = 0; - for (int i = 0; i < n; i++) { - float delta = mod(time/5000, PI/2); - alpha = mod(alpha + delta, PI/2); - b /= (sin(delta) + cos(delta)); + int n = 20; + float b = 1; + float alpha = 0; + for (int i = 0; i < n; i++) { + float delta = mod(time/5000, PI/2); + alpha = mod(alpha + delta, PI/2); + b /= (sin(delta) + cos(delta)); - float c = square(vec2(0, 0), b, alpha, p); - scene = abs(scene - c); - } + float c = square(vec2(0, 0), b, alpha, p); + scene = abs(scene - c); + } - b = 1; - alpha = 0; - for (int i = 0; i < n; i++) { - float delta = mod(-time/5000, PI/2); - alpha = mod(alpha + delta, PI/2); - b /= (sin(delta) + cos(delta)); + b = 1; + alpha = 0; + for (int i = 0; i < n; i++) { + float delta = mod(-time/5000, PI/2); + alpha = mod(alpha + delta, PI/2); + b /= (sin(delta) + cos(delta)); - float c = square(vec2(0, 0), b, alpha, p); - scene = abs(scene - c); - } + float c = square(vec2(0, 0), b, alpha, p); + scene = abs(scene - c); + } - fragColor = vec4(vec3(1, 1, 1) * scene, 1); + fragColor = vec4(vec3(1, 1, 1) * scene, 1); } diff --git a/examples/square-ring.frag b/examples/square-ring.frag index 1ef1c2c..300d4ef 100644 --- a/examples/square-ring.frag +++ b/examples/square-ring.frag @@ -11,31 +11,31 @@ const float PI = 3.14159265358979323846; mat2 rot(float a) { - return mat2( - cos(a), -sin(a), - sin(a), cos(a) - ); + return mat2( + cos(a), -sin(a), + sin(a), cos(a) + ); } float square(vec2 m, float a, float r, vec2 p) { - vec2 diff = abs((m - p) * rot(r)); - float d = max(diff.x, diff.y); + vec2 diff = abs((m - p) * rot(r)); + float d = max(diff.x, diff.y); - return clamp((a - d)*sharpness, 0.0, 1.0); + return clamp((a - d)*sharpness, 0.0, 1.0); } void main(void) { - vec2 m = res/2; - float s = min(m.x, m.y); - vec2 p = (gl_FragCoord.xy - m) / s; + vec2 m = res/2; + float s = min(m.x, m.y); + vec2 p = (gl_FragCoord.xy - m) / s; - float scene = 0; + float scene = 0; - int n = 10; - for (int i = 1; i <= n; i++) { - float c = square(vec2(0, 0), 0.5, PI/2*i/n - time/500, p); - scene = abs(scene - c); - } + int n = 10; + for (int i = 1; i <= n; i++) { + float c = square(vec2(0, 0), 0.5, PI/2*i/n - time/500, p); + scene = abs(scene - c); + } - fragColor = vec4(vec3(1, 1, 1) * scene, 1); + fragColor = vec4(vec3(1, 1, 1) * scene, 1); } diff --git a/examples/square-ring2.frag b/examples/square-ring2.frag index e90b633..26310a7 100644 --- a/examples/square-ring2.frag +++ b/examples/square-ring2.frag @@ -11,37 +11,37 @@ const float PI = 3.14159265358979323846; mat2 rot(float a) { - return mat2( - cos(a), -sin(a), - sin(a), cos(a) - ); + return mat2( + cos(a), -sin(a), + sin(a), cos(a) + ); } float square(vec2 m, float a, float r, vec2 p) { - vec2 diff = abs((m - p) * rot(r)); - float d = max(diff.x, diff.y); + vec2 diff = abs((m - p) * rot(r)); + float d = max(diff.x, diff.y); - return clamp((a - d)*sharpness, 0.0, 1.0); + return clamp((a - d)*sharpness, 0.0, 1.0); } void main(void) { - vec2 m = res/2; - float s = min(m.x, m.y); - vec2 p = (gl_FragCoord.xy - m) / s; + vec2 m = res/2; + float s = min(m.x, m.y); + vec2 p = (gl_FragCoord.xy - m) / s; - float scene = 0; + float scene = 0; - int n = 5; - for (int i = 1; i <= n; i++) { - float c = square(vec2(0, 0), 0.5, PI/2*i/n - time/3000, p); - scene = abs(scene - c); - } + int n = 5; + for (int i = 1; i <= n; i++) { + float c = square(vec2(0, 0), 0.5, PI/2*i/n - time/3000, p); + scene = abs(scene - c); + } - n = 5; - for (int i = 1; i <= n; i++) { - float c = square(vec2(0, 0), 0.5, PI/2*i/n + time/3000, p); - scene = abs(scene - c); - } + n = 5; + for (int i = 1; i <= n; i++) { + float c = square(vec2(0, 0), 0.5, PI/2*i/n + time/3000, p); + scene = abs(scene - c); + } - fragColor = vec4(vec3(1, 1, 1) * scene, 1); + fragColor = vec4(vec3(1, 1, 1) * scene, 1); } diff --git a/examples/squares.frag b/examples/squares.frag index fd5dc94..574f220 100644 --- a/examples/squares.frag +++ b/examples/squares.frag @@ -8,35 +8,35 @@ uniform float time; const float sharpness = 500; mat2 rot(float a) { - return mat2( - cos(a), -sin(a), - sin(a), cos(a) - ); + return mat2( + cos(a), -sin(a), + sin(a), cos(a) + ); } float square(vec2 m, float a, float r, vec2 p) { - vec2 diff = abs((m - p) * rot(r)); - float d = max(diff.x, diff.y); + vec2 diff = abs((m - p) * rot(r)); + float d = max(diff.x, diff.y); - return clamp((a - d)*sharpness, 0.0, 1.0); + return clamp((a - d)*sharpness, 0.0, 1.0); } void main(void) { - vec2 m = res/2; - float s = min(m.x, m.y); - vec2 p = (gl_FragCoord.xy - m) / s; + vec2 m = res/2; + float s = min(m.x, m.y); + vec2 p = (gl_FragCoord.xy - m) / s; - float a = atan(p.x, p.y); + float a = atan(p.x, p.y); - float x = mod(p.x, 0.1); - float y = mod(p.y, 0.1); + float x = mod(p.x, 0.1); + float y = mod(p.y, 0.1); - float scene = 0; + float scene = 0; - for (int i = 1; i <= 50; i++) { - float c = square(vec2(0.5, 0) * rot(time/500/i), 0.1 + 0.005*i, time/500/i + time/(100*i), p); - scene = abs(scene - c); - } + for (int i = 1; i <= 50; i++) { + float c = square(vec2(0.5, 0) * rot(time/500/i), 0.1 + 0.005*i, time/500/i + time/(100*i), p); + scene = abs(scene - c); + } - fragColor = vec4(vec3(1, 1, 1) * scene, 1); + fragColor = vec4(vec3(1, 1, 1) * scene, 1); } diff --git a/examples/supersnail.frag b/examples/supersnail.frag index 154652a..dd0f77c 100644 --- a/examples/supersnail.frag +++ b/examples/supersnail.frag @@ -8,30 +8,30 @@ uniform float time; const float sharpness = 300; mat2 rot(float a) { - return mat2( - cos(a), -sin(a), - sin(a), cos(a) - ); + return mat2( + cos(a), -sin(a), + sin(a), cos(a) + ); } float circle(vec2 m, float r, vec2 p) { - vec2 diff = m - p; - float d = sqrt(dot(diff, diff)); + vec2 diff = m - p; + float d = sqrt(dot(diff, diff)); - return clamp((r - d)*sharpness, 0.0, 1.0); + return clamp((r - d)*sharpness, 0.0, 1.0); } void main(void) { - vec2 m = res/2; - float s = min(m.x, m.y); - vec2 p = (gl_FragCoord.xy - m) / s; + vec2 m = res/2; + float s = min(m.x, m.y); + vec2 p = (gl_FragCoord.xy - m) / s; - float scene = 0; + float scene = 0; - for (int i = 1; i <= 100; i++) { - float c = circle(vec2(0.5, 0) * rot(time/200/i), 0.1 + 0.002*i, p); - scene = abs(scene - c); - } + for (int i = 1; i <= 100; i++) { + float c = circle(vec2(0.5, 0) * rot(time/200/i), 0.1 + 0.002*i, p); + scene = abs(scene - c); + } - fragColor = vec4(vec3(1, 1, 1) * scene, 1); + fragColor = vec4(vec3(1, 1, 1) * scene, 1); } diff --git a/examples/symmetry.frag b/examples/symmetry.frag index 0fb9cd1..7a3fb18 100644 --- a/examples/symmetry.frag +++ b/examples/symmetry.frag @@ -11,31 +11,31 @@ const float PI = 3.14159265358979323846; mat2 rot(float a) { - return mat2( - cos(a), -sin(a), - sin(a), cos(a) - ); + return mat2( + cos(a), -sin(a), + sin(a), cos(a) + ); } float square(vec2 m, float a, float r, vec2 p) { - vec2 diff = abs((m - p) * rot(r)); - float d = max(diff.x, diff.y); + vec2 diff = abs((m - p) * rot(r)); + float d = max(diff.x, diff.y); - return clamp((a - d)*sharpness, 0.0, 1.0); + return clamp((a - d)*sharpness, 0.0, 1.0); } void main(void) { - vec2 m = res/2; - float s = min(m.x, m.y); - vec2 p = (gl_FragCoord.xy - m) / s; + vec2 m = res/2; + float s = min(m.x, m.y); + vec2 p = (gl_FragCoord.xy - m) / s; - float scene = 0; + float scene = 0; - int n = 24; - for (int i = 0; i < n; i++) { - float c = square(vec2(0.5, 0) * rot(PI/2*(4.0*i/n)) * vec2(1, 1), 0.3, PI/2*(24.0*i/n - time/800), p); - scene = abs(scene - c); - } + int n = 24; + for (int i = 0; i < n; i++) { + float c = square(vec2(0.5, 0) * rot(PI/2*(4.0*i/n)) * vec2(1, 1), 0.3, PI/2*(24.0*i/n - time/800), p); + scene = abs(scene - c); + } - fragColor = vec4(vec3(1, 1, 1) * scene, 1); + fragColor = vec4(vec3(1, 1, 1) * scene, 1); } diff --git a/examples/torus.frag b/examples/torus.frag index 9758e1d..06f6987 100644 --- a/examples/torus.frag +++ b/examples/torus.frag @@ -11,31 +11,31 @@ const float PI = 3.14159265358979323846; mat2 rot(float a) { - return mat2( - cos(a), -sin(a), - sin(a), cos(a) - ); + return mat2( + cos(a), -sin(a), + sin(a), cos(a) + ); } float square(vec2 m, float a, float r, vec2 p) { - vec2 diff = abs((m - p) * rot(r)); - float d = max(diff.x, diff.y); + vec2 diff = abs((m - p) * rot(r)); + float d = max(diff.x, diff.y); - return clamp((a - d)*sharpness, 0.0, 1.0); + return clamp((a - d)*sharpness, 0.0, 1.0); } void main(void) { - vec2 m = res/2; - float s = min(m.x, m.y); - vec2 p = (gl_FragCoord.xy - m) / s; + vec2 m = res/2; + float s = min(m.x, m.y); + vec2 p = (gl_FragCoord.xy - m) / s; - float scene = 0; + float scene = 0; - int n = 48; - for (int i = 1; i <= n; i++) { - float c = square(vec2(0.5, 0) * rot(PI/2*(time/8000 + 4.0*i/n)) * vec2(1, 0.5), 0.1, PI/2*(24.0*i/n - time/800), p); - scene = abs(scene - c); - } + int n = 48; + for (int i = 1; i <= n; i++) { + float c = square(vec2(0.5, 0) * rot(PI/2*(time/8000 + 4.0*i/n)) * vec2(1, 0.5), 0.1, PI/2*(24.0*i/n - time/800), p); + scene = abs(scene - c); + } - fragColor = vec4(vec3(1, 1, 1) * scene, 1); + fragColor = vec4(vec3(1, 1, 1) * scene, 1); } -- cgit v1.2.3