diff options
Diffstat (limited to 'shaders')
-rw-r--r-- | shaders/moon.vert | 8 | ||||
-rw-r--r-- | shaders/normal.vert | 9 | ||||
-rw-r--r-- | shaders/satelites.frag | 23 | ||||
-rw-r--r-- | shaders/satelites.geom | 31 | ||||
-rw-r--r-- | shaders/satelites.vert | 41 | ||||
-rw-r--r-- | shaders/space.vert | 3 |
6 files changed, 108 insertions, 7 deletions
diff --git a/shaders/moon.vert b/shaders/moon.vert index 2e6a928..c8dface 100644 --- a/shaders/moon.vert +++ b/shaders/moon.vert @@ -1,7 +1,9 @@ #version 150 -in vec3 in_position ; -in vec3 in_normal ; -in vec2 in_texMapping ; +#extension GL_ARB_explicit_attrib_location : enable + +layout(location = 0) in vec3 in_position ; +layout(location = 1) in vec3 in_normal ; +layout(location = 3) in vec2 in_texMapping ; uniform mat4 mvMat ; uniform mat4 pMat ; diff --git a/shaders/normal.vert b/shaders/normal.vert index 34ddce3..bfe9080 100644 --- a/shaders/normal.vert +++ b/shaders/normal.vert @@ -1,7 +1,10 @@ #version 150 -in vec3 in_position ; -in vec3 in_normal ; -in vec2 in_texMapping ; +#extension GL_ARB_explicit_attrib_location : enable + +layout(location = 0) in vec3 in_position ; +layout(location = 1) in vec3 in_normal ; +// # 2 is color +layout(location = 3) in vec2 in_texMapping ; uniform mat4 pMat ; uniform mat4 mvMat ; diff --git a/shaders/satelites.frag b/shaders/satelites.frag new file mode 100644 index 0000000..a605025 --- /dev/null +++ b/shaders/satelites.frag @@ -0,0 +1,23 @@ +#version 150 + +out vec4 frag_color ; + +uniform vec3 light ; +uniform sampler2D noiseTexture ; + +// normal == position ; +in vec4 position ; +in vec3 normal ; +in vec2 texMapping ; + +in float rad ; +in vec3 mNormal ; +in vec4 origPos_ ; + +void main() { + float intensity = dot( normalize(vec3(position) - light), normalize(mNormal) ); + frag_color = vec4( + mix(vec3(texture2D(noiseTexture,origPos_.xy))*intensity, + vec3(1.0), 0.90) + ,0.1/pow(rad,1.7)) ; +} diff --git a/shaders/satelites.geom b/shaders/satelites.geom new file mode 100644 index 0000000..7e3d747 --- /dev/null +++ b/shaders/satelites.geom @@ -0,0 +1,31 @@ +#version 150 +layout(points) in; +layout(triangle_strip, max_vertices=28) out; + +out float rad ; +out vec3 mNormal ; + +uniform mat4 mvMatrix ; +in vec4 origPos[] ; +out vec4 origPos_ ; + +void vertex( vec3 pos ) { + gl_Position = gl_in[0].gl_Position + vec4(pos,0.0) ; + origPos_ = origPos[0] ; + EmitVertex() ; +} + +void main( ) { + mNormal = -inverse(transpose(mat3(mvMatrix))) * vec3(0,0,1.0) ; + float r = 0.005 ; + float th = 0.00 ; + for( ; th < 6.3 ; th += 0.5 ) { + rad = 2 ; + vertex( vec3(r*sin(th),r*cos(th),0.0) ) ; + rad = 0.0 ; + vertex( vec3(0.0,0.0,0.0) ) ; + } + rad = 2 ; + vertex( vec3(r*sin(0.0),r*cos(0.0),0.0) ) ; + EndPrimitive(); +} diff --git a/shaders/satelites.vert b/shaders/satelites.vert new file mode 100644 index 0000000..a95055b --- /dev/null +++ b/shaders/satelites.vert @@ -0,0 +1,41 @@ +#version 150 +#extension GL_ARB_explicit_attrib_location : enable + +layout(location = 0) in vec3 in_position ; +layout(location = 3) in vec2 in_texMapping ; + +uniform sampler2D noiseTexture ; + +uniform mat4 mvMatrix ; +uniform mat4 pMatrix ; +uniform float time ; +uniform vec3 light ; + +out vec4 position ; +out vec3 normal ; +out vec2 texMapping ; +out vec4 origPos ; + +void main() { + vec4 u = texture2D( noiseTexture, in_texMapping ) ; + texMapping = in_texMapping ; + + float r = pow(0.1,in_position.x)+1.2 ; + float th = in_position.y - ((u.x+1.0) * time/(sqrt(r) * 50.0)) + u.z * 360; + float ph = 2*(in_position.z - 0.5) ;// pow(in_position.z-0.2,0.5) + ; + ph *= pow( abs(ph), 2.0 ) * sin( time / (sqrt(r) * 50)); + + vec4 real_position = vec4( + -r * sin(th) * cos(ph), + r * sin(ph), + r * cos(th) * cos(ph), + 1.0 ) ; + origPos = real_position ; + + vec4 tmp = mvMatrix * real_position ; + position = tmp ; + normal = inverse(transpose(mat3(mvMatrix))) * vec3(tmp) ; + tmp = pMatrix * tmp; + gl_PointSize = texture2D(noiseTexture,in_texMapping+vec2(.1,.1)).a * 4.0 / length(vec3(tmp)) ; + gl_Position = tmp ; +} diff --git a/shaders/space.vert b/shaders/space.vert index fdfec59..579963d 100644 --- a/shaders/space.vert +++ b/shaders/space.vert @@ -1,5 +1,6 @@ #version 150 -in vec3 in_position ; +#extension GL_ARB_explicit_attrib_location : enable +layout(location = 0) in vec3 in_position ; out vec2 texMap ; void main() { |