summaryrefslogtreecommitdiff
path: root/client/shaders/leaves_shader/opengl_vertex.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'client/shaders/leaves_shader/opengl_vertex.glsl')
-rw-r--r--client/shaders/leaves_shader/opengl_vertex.glsl21
1 files changed, 13 insertions, 8 deletions
diff --git a/client/shaders/leaves_shader/opengl_vertex.glsl b/client/shaders/leaves_shader/opengl_vertex.glsl
index 3702b1b50..30ad00b82 100644
--- a/client/shaders/leaves_shader/opengl_vertex.glsl
+++ b/client/shaders/leaves_shader/opengl_vertex.glsl
@@ -1,13 +1,20 @@
uniform mat4 mWorldViewProj;
uniform mat4 mInvWorld;
uniform mat4 mTransWorld;
+uniform mat4 mWorld;
+
uniform float dayNightRatio;
uniform float animationTimer;
uniform vec3 eyePosition;
varying vec3 vPosition;
+varying vec3 worldPosition;
+
varying vec3 eyeVec;
+varying vec3 lightVec;
+
+const float BS = 10.0;
#ifdef ENABLE_WAVING_LEAVES
float smoothCurve( float x ) {
@@ -27,7 +34,7 @@ void main(void)
#ifdef ENABLE_WAVING_LEAVES
vec4 pos = gl_Vertex;
- vec4 pos2 = mTransWorld*gl_Vertex;
+ vec4 pos2 = mWorld*gl_Vertex;
pos.x += (smoothTriangleWave(animationTimer*10.0 + pos2.x * 0.01 + pos2.z * 0.01) * 2.0 - 1.0) * 0.4;
pos.y += (smoothTriangleWave(animationTimer*15.0 + pos2.x * -0.01 + pos2.z * -0.01) * 2.0 - 1.0) * 0.2;
pos.z += (smoothTriangleWave(animationTimer*10.0 + pos2.x * -0.01 + pos2.z * -0.01) * 2.0 - 1.0) * 0.4;
@@ -36,10 +43,13 @@ void main(void)
gl_Position = mWorldViewProj * gl_Vertex;
#endif
- vPosition = (mWorldViewProj * gl_Vertex).xyz;
+ vPosition = gl_Position.xyz;
+ worldPosition = (mWorld * gl_Vertex).xyz;
+ vec3 sunPosition = vec3 (0.0, eyePosition.y * BS + 900.0, 0.0);
+ lightVec = sunPosition - worldPosition;
eyeVec = (gl_ModelViewMatrix * gl_Vertex).xyz;
-
+
vec4 color;
//color = vec4(1.0, 1.0, 1.0, 1.0);
@@ -75,13 +85,8 @@ void main(void)
color = color * color; // SRGB -> Linear
if(gl_Normal.y <= 0.5)
color *= 0.6;
- //color *= 0.7;
color = sqrt(color); // Linear -> SRGB
-
color.a = gl_Color.a;
gl_FrontColor = gl_BackColor = color;
-
- gl_TexCoord[0] = gl_MultiTexCoord0;
-
}