RetroArch
pipeline_snowflake.glsl.frag.h
Go to the documentation of this file.
1 /* credits to: TheTimJames
2  https://www.shadertoy.com/view/Md2GRw
3 */
4 
5 #include "shaders_common.h"
6 
7 static const char* stock_fragment_xmb_snowflake = GLSL(
8  uniform float time;
9  uniform vec2 OutputSize;
10  vec2 uv;
11 
12  float atime;
13 
14  float rand(vec2 co)
15  {
16  return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
17  }
18 
19  float rand_float(float x)
20  {
21  return rand(vec2(x, 1.0));
22  }
23 
24  float snow(vec3 pos, vec2 uv, float o)
25  {
26  vec2 d = (pos.xy - uv);
27  float a = atan(d.y,d.x) + sin(time*1.0 + o) * 10.0;
28 
29  float dist = d.x*d.x + d.y*d.y;
30 
31  if(dist < pos.z/400.0)
32  {
33  float col = 0.0;
34  if(sin(a * 8.0) < 0.0)
35  {
36  col=1.0;
37  }
38  if(dist < pos.z/800.0)
39  {
40  col+=1.0;
41  }
42  return col * pos.z;
43  }
44 
45  return 0.0;
46  }
47 
48  float col(vec2 c)
49  {
50  float color = 0.0;
51  for (int i = 1; i < 15; i++)
52  {
53  float o = rand_float(float(i) / 3.0) * 15.0;
54  float z = rand_float(float(i) + 13.0);
55  float x = 1.8 - (3.6) * (rand_float(floor((time*((z + 1.0) / 2.0) +o) / 2.0)) + sin(time * o /1000.0) / 10.0);
56  float y = 1.0 - mod((time * ((z + 1.0)/2.0)) + o, 2.0);
57 
58  color += snow(vec3(x,y,z), c, o);
59  }
60 
61  return color;
62  }
63 
64  void main(void)
65  {
66  uv = gl_FragCoord.xy / OutputSize.xy;
67  uv = uv * 2.0 - 1.0;
68  vec2 p = uv;
69  p.x *= OutputSize.x / OutputSize.y;
70 
71  atime = (time + 1.0) / 4.0;
72 
73  gl_FragColor = vec4(col(p));
74  }
75 
76 );
#define floor(x)
Definition: math.h:25
GLdouble GLdouble z
Definition: glext.h:6514
#define GLSL(src)
Definition: shaders_common.h:10
const GLubyte * c
Definition: glext.h:9812
#define gl_FragCoord
Definition: internal_interface.hpp:357
static const char * stock_fragment_xmb_snowflake
Definition: pipeline_snowflake.glsl.frag.h:7
std::shared_ptr< Ope > dot()
Definition: peglib.h:1603
GLint GLint GLint GLint GLint GLint y
Definition: glext.h:6295
time_t time(time_t *timer)
GLint GLint GLint GLint GLint x
Definition: glext.h:6295
GLfloat GLfloat p
Definition: glext.h:9809
#define sin(x)
Definition: math.h:23
int main(int argc, char *argv[])
Definition: send-presence.c:197
u32 col
Definition: gx_regdef.h:5093
GLuint color
Definition: glext.h:6883
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6844