RetroArch
core_pipeline_snow.glsl.frag.h
Go to the documentation of this file.
1 #include "shaders_common.h"
2 
3 static const char* stock_fragment_xmb_snow_core = GLSL(
4  uniform float time;
5  uniform vec2 OutputSize;
6  out vec4 FragColor;
7 
8  float baseScale = 3.5; /* [1.0 .. 10.0] */
9  float density = 0.7; /* [0.01 .. 1.0] */
10  float speed = 0.25; /* [0.1 .. 1.0] */
11 
12  float rand(vec2 co)
13  {
14  return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
15  }
16 
17  float dist_func(vec2 distv)
18  {
19  float dist = sqrt((distv.x * distv.x) + (distv.y * distv.y)) * (40.0 / baseScale);
20  dist = clamp(dist, 0.0, 1.0);
21  return cos(dist * (3.14159265358 * 0.5)) * 0.5;
22  }
23 
24  float random_dots(vec2 co)
25  {
26  float part = 1.0 / 20.0;
27  vec2 cd = floor(co / part);
28  float p = rand(cd);
29 
30  if (p > 0.005 * (density * 40.0))
31  return 0.0;
32 
33  vec2 dpos = (vec2(fract(p * 2.0) , p) + vec2(2.0, 2.0)) * 0.25;
34 
35  vec2 cellpos = fract(co / part);
36  vec2 distv = (cellpos - dpos);
37 
38  return dist_func(distv);
39  }
40 
41  float snow(vec2 pos, float time, float scale)
42  {
43  /* add wobble */
44  pos.x += cos(pos.y * 1.2 + time * 3.14159 * 2.0 + 1.0 / scale) / (8.0 / scale) * 4.0;
45  /* add gravity */
46  pos += time * scale * vec2(-0.5, 1.0) * 4.0;
47  return random_dots(pos / scale) * (scale * 0.5 + 0.5);
48  }
49 
50  void main(void)
51  {
52  float tim = time * 0.4 * speed;
53  vec2 pos = gl_FragCoord.xy / OutputSize.xx;
54  float a = 0.0;
60  a += snow(pos, tim, 1.0);
61  a += snow(pos, tim, 0.7);
62  a += snow(pos, tim, 0.6);
63  a += snow(pos, tim, 0.5);
64  a += snow(pos, tim, 0.4);
65  a += snow(pos, tim, 0.3);
66  a += snow(pos, tim, 0.25);
67  a += snow(pos, tim, 0.125);
68  a = a * min(pos.y * 4.0, 1.0);
69  FragColor = vec4(1.0, 1.0, 1.0, a);
70  }
71 
72 );
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:9939
struct passwd out
Definition: missing_libc_functions.c:51
#define floor(x)
Definition: math.h:25
#define sqrt(x)
Definition: math.h:26
#define GLSL(src)
Definition: shaders_common.h:10
#define gl_FragCoord
Definition: internal_interface.hpp:357
std::shared_ptr< Ope > dot()
Definition: peglib.h:1603
time_t time(time_t *timer)
GLenum clamp
Definition: glext.h:6856
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
#define cos(x)
Definition: math.h:21
static const char * stock_fragment_xmb_snow_core
Definition: core_pipeline_snow.glsl.frag.h:3
def cd(new_dir)
Definition: build.py:40
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6844