• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Dec 9th, 2019 145 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
3.
5. // useful params moved to uniforms
7.
8. uniform float M_PI = 3.1415926535897932384626433832795;
9. uniform float cell_size = 35.523;
10. uniform float wave_radius = 69.420;
11. uniform vec2 moving_speed = vec2(0, -10);
12. uniform float wave_speed = 1;
13. uniform float sparse = 2.9;
14.
15. float wave(vec2 pixel, float t) {
17.     vec2 delta = pixel;
18.     float delta_squared = delta.x*delta.x + delta.y*delta.y;
19.     float val = M_PI/2.0*delta_squared/rad_squared + t/2.;
20.     return pow(sin(val + cos(pixel.y)), sparse);
21. }
22.
23. // hex bullshit, pls ignore [1]
24. vec3 axial_to_cube(vec2 hex) {
25.     float x = hex.x;
26.     float z = hex.y;
27.     float y = -x-z;
28.     return vec3(x,y,z);
29. }
30. vec2 cube_to_axial(vec3 cube) {
31.     return vec2(cube.x, cube.z);
32. }
33. vec3 cube_round(vec3 cube) {
34.     float rx = round(cube.x);
35.     float ry = round(cube.y);
36.     float rz = round(cube.z);
37.     float x_diff = abs(rx - cube.x);
38.     float y_diff = abs(ry - cube.y);
39.     float z_diff = abs(rz - cube.z);
40.     if (x_diff > y_diff && x_diff > z_diff)
41.         rx = -ry-rz;
42.     else if (y_diff > z_diff)
43.         ry = -rx-rz;
44.     else
45.         rz = -rx-ry;
46.     return vec3(rx, ry, rz);
47. }
48. vec2 hex_round(vec2 hex) {
49.     return cube_to_axial(cube_round(axial_to_cube(hex)));
50. }
51. vec2 pixel_to_axial(vec2 pixel, float size) {
52.     float q = (2./3. * pixel.x) / size;
53.     float r = (-1./3. * pixel.x + sqrt(3.)/3. * pixel.y) / size;
54.     return vec2(q,r);
55. }
56. vec2 axial_to_pixel(vec2 hex, float size) {
57.     float x = size * 3./2. * hex.x;
58.     float y = size * (sqrt(3.)/2. * hex.x + sqrt(3.) * hex.y);
59.     return vec2(x,y);
60. }
61. vec2 hex_center(vec2 pixel, float size) {
62.     vec2 center = axial_to_pixel(hex_round(pixel_to_axial(pixel, size)), size);
63.     return center;
64. }
65.
66. void fragment()
67. {
68.     vec2 pixel_size = SCREEN_PIXEL_SIZE;
69.     vec2 pixel = FRAGCOORD.xy;
70.
71.     pixel += TIME * moving_speed;
72.
73.     vec2 center = hex_center(pixel, cell_size);
74.
75.     float wave_value = wave(center, TIME * wave_speed);
76.     COLOR = vec4(vec3(wave_value), wave_value);
77.
78.     if (length(center - pixel) > wave_value/0.02) {
80.     }
81. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top