RetroArch
snowflake_sm4.hlsl.h
Go to the documentation of this file.
1 
2 #define SRC(...) #__VA_ARGS__
3 SRC(
4 struct UBO
5 {
6  float4x4 modelViewProj;
7  float2 OutputSize;
8  float time;
9 };
10 uniform UBO global;
11 
12 float4 VSMain(float4 position : POSITION, float2 texcoord : TEXCOORD0) : SV_POSITION
13 {
14  return mul(global.modelViewProj, position);
15 }
16 
17 
18 static const float atime = (global.time + 1.0) / 4.0;
19 
20 float rand(float2 co)
21 {
22  return frac(sin(dot(co.xy, float2(12.9898, 78.233))) * 43758.5453);
23 }
24 
25 float rand_float(float x)
26 {
27  return rand(float2(x, 1.0));
28 }
29 
30 float snow(float3 pos, float2 uv, float o)
31 {
32  float2 d = (pos.xy - uv);
33  float a = atan(d.y / d.x) + sin(atime*1.0 + o) * 10.0;
34 
35  float dist = d.x*d.x + d.y*d.y;
36 
37  if(dist < pos.z/400.0)
38  {
39  float col = 0.0;
40  if(sin(a * 8.0) < 0.0)
41  {
42  col=1.0;
43  }
44  if(dist < pos.z/800.0)
45  {
46  col+=1.0;
47  }
48  return col * pos.z;
49  }
50 
51  return 0.0;
52 }
53 
54 float col(float2 c)
55 {
56  float color = 0.0;
57  for (int i = 1; i < 15; i++)
58  {
59  float o = rand_float(float(i) / 3.0) * 15.0;
60  float z = rand_float(float(i) + 13.0);
61  float x = 1.8 - (3.6) * (rand_float(floor((global.time*((z + 1.0) / 2.0) +o) / 2.0)) + sin(global.time * o /1000.0) / 10.0);
62  float y = 1.0 - fmod((global.time * ((z + 1.0)/2.0)) + o, 2.0);
63 
64  color += snow(float3(x,y,z), c, o);
65  }
66 
67  return color;
68 }
69 
70 float4 PSMain(float4 position : SV_POSITION) : SV_TARGET
71 {
72  float2 uv = position.xy / global.OutputSize.xy;
73  uv = uv * 2.0 - 1.0;
74  float2 p = uv;
75  p.x *= global.OutputSize.x / global.OutputSize.y;
76  p.y =- p.y;
77 
78  float c = col(p);
79  return float4(c,c,c,c);
80 };
81 )
#define SRC(...)
Definition: snowflake_sm4.hlsl.h:2
#define floor(x)
Definition: math.h:25
GLdouble GLdouble z
Definition: glext.h:6514
const GLubyte * c
Definition: glext.h:9812
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
u32 col
Definition: gx_regdef.h:5093
GLuint color
Definition: glext.h:6883
Definition: retroarch.h:240
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6844