RetroArch
core_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 
8  uniform float time;
9  uniform vec2 OutputSize;
10  vec2 uv;
11  out vec4 FragColor;
12 
13  float atime;
14 
15  float rand(vec2 co)
16  {
17  return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
18  }
19 
20  float rand_float(float x)
21  {
22  return rand(vec2(x, 1.0));
23  }
24 
25  float snow(vec3 pos, vec2 uv, float o)
26  {
27  vec2 d = (pos.xy - uv);
28  float a = atan(d.y,d.x) + sin(time*1.0 + o) * 10.0;
29 
30  float dist = d.x*d.x + d.y*d.y;
31 
32  if(dist < pos.z/400.0)
33  {
34  float col = 0.0;
35  if(sin(a * 8.0) < 0.0)
36  {
37  col=1.0;
38  }
39  if(dist < pos.z/800.0)
40  {
41  col+=1.0;
42  }
43  return col * pos.z;
44  }
45 
46  return 0.0;
47  }
48 
49  float col(vec2 c)
50  {
51  float color = 0.0;
52  for (int i = 1; i < 15; i++)
53  {
54  float o = rand_float(float(i) / 3.0) * 15.0;
55  float z = rand_float(float(i) + 13.0);
56  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);
57  float y = 1.0 - mod((time * ((z + 1.0)/2.0)) + o, 2.0);
58 
59  color += snow(vec3(x,y,z), c, o);
60  }
61 
62  return color;
63  }
64 
65  void main(void)
66  {
67  uv = gl_FragCoord.xy / OutputSize.xy;
68  uv = uv * 2.0 - 1.0;
69  vec2 p = uv;
70  p.x *= OutputSize.x / OutputSize.y;
71 
72  atime = (time + 1.0) / 4.0;
73 
74  FragColor = vec4(col(p));
75  }
76 
77 );
struct passwd out
Definition: missing_libc_functions.c:51
#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_core
Definition: core_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