aboutsummaryrefslogtreecommitdiff
path: root/shaders
diff options
context:
space:
mode:
Diffstat (limited to 'shaders')
-rw-r--r--shaders/snow.frag13
-rw-r--r--shaders/snow.geom26
-rw-r--r--shaders/snow.vert20
3 files changed, 59 insertions, 0 deletions
diff --git a/shaders/snow.frag b/shaders/snow.frag
new file mode 100644
index 0000000..d494633
--- /dev/null
+++ b/shaders/snow.frag
@@ -0,0 +1,13 @@
+#version 150
+#extension GL_ARB_explicit_attrib_location : enable
+#extension GL_ARB_explicit_uniform_location : enable
+
+layout(location = 0) out vec4 frag_color ;
+
+in float rad ;
+
+uniform vec4 globalAmbient ;
+
+void main() {
+ frag_color = vec4( 1.0,1.0,1.0,(9 - rad*rad)/9) * vec4(normalize(globalAmbient.xyz),globalAmbient.a) ;
+}
diff --git a/shaders/snow.geom b/shaders/snow.geom
new file mode 100644
index 0000000..116a59d
--- /dev/null
+++ b/shaders/snow.geom
@@ -0,0 +1,26 @@
+#version 150
+layout(points) in;
+layout(triangle_strip, max_vertices=28) out;
+
+out float rad ;
+
+void vertex( vec3 pos ) {
+ gl_Position = gl_in[0].gl_Position + vec4(pos,0.0) ;
+ EmitVertex() ;
+}
+
+void main( ) {
+ float r = 0.008 ;
+ float th = 0.00 ;
+ for( ; th < 6.3 ; th += 0.5 ) {
+ rad = 3 ;
+ vertex( vec3(r*sin(th),r*cos(th),0.0) ) ;
+ rad = 0.0 ;
+ vertex( vec3(0.0,0.0,0.0) ) ;
+ }
+ th = 0 ;
+ rad = 3 ;
+ vertex( vec3(r*sin(th),r*cos(th),0.0) ) ;
+ // vertex( vector[0] ) ;
+ EndPrimitive();
+}
diff --git a/shaders/snow.vert b/shaders/snow.vert
new file mode 100644
index 0000000..535c26a
--- /dev/null
+++ b/shaders/snow.vert
@@ -0,0 +1,20 @@
+#version 150
+#extension GL_ARB_explicit_attrib_location : enable
+#extension GL_ARB_explicit_uniform_location : enable
+
+layout(location = 0) in vec3 in_position ;
+layout(location = 2) in vec3 in_range ;
+
+uniform mat4 pjMatrix ;
+uniform mat4 mvMatrix ;
+
+uniform float time ;
+
+void main() {
+ float tmp = in_position.y + time ;
+ float ipart ;
+ float fpart = modf( tmp, ipart ) ;
+ float newy = in_range.y - (int(ipart) % int(in_range.y) + fpart) + in_range.x ;
+ vec3 newp = vec3( in_position.x, newy, in_position.z ) ;
+ gl_Position = pjMatrix * (mvMatrix * vec4(newp,1.0)) ;
+}