diff options
author | paramat <mat.gregory@virginmedia.com> | 2016-03-25 17:50:26 +0000 |
---|---|---|
committer | paramat <mat.gregory@virginmedia.com> | 2016-03-30 01:53:22 +0100 |
commit | 597c1d73da38ab299eb440a3429fce04da10cf05 (patch) | |
tree | f9cc7b99cd7eae60a3edd99e57c6b5e0d9907093 /client | |
parent | 630f453da402c7b6f0af9ea32aa8b127ce2e4629 (diff) | |
download | minetest-597c1d73da38ab299eb440a3429fce04da10cf05.tar.gz minetest-597c1d73da38ab299eb440a3429fce04da10cf05.tar.bz2 minetest-597c1d73da38ab299eb440a3429fce04da10cf05.zip |
Nodes shader: Decrease amplitude of waving leaves and plants
Fix initialisation of variable 'disp'
Fix a few minor code style issues
Add independent X motion combining 2 prime frequencies
Diffstat (limited to 'client')
-rw-r--r-- | client/shaders/nodes_shader/opengl_vertex.glsl | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/client/shaders/nodes_shader/opengl_vertex.glsl b/client/shaders/nodes_shader/opengl_vertex.glsl index ff271d0e1..28c5f197e 100644 --- a/client/shaders/nodes_shader/opengl_vertex.glsl +++ b/client/shaders/nodes_shader/opengl_vertex.glsl @@ -15,7 +15,6 @@ varying vec3 lightVec; varying vec3 tsEyeVec; varying vec3 tsLightVec; varying float area_enable_parallax; -varying float disp; const float e = 2.718281828459; const float BS = 10.0; @@ -55,12 +54,16 @@ void main(void) #endif +float disp_x; +float disp_z; #if (MATERIAL_TYPE == TILE_MATERIAL_WAVING_LEAVES && ENABLE_WAVING_LEAVES) || (MATERIAL_TYPE == TILE_MATERIAL_WAVING_PLANTS && ENABLE_WAVING_PLANTS) vec4 pos2 = mWorld * gl_Vertex; float tOffset = (pos2.x + pos2.y) * 0.001 + pos2.z * 0.002; - disp = (smoothTriangleWave(animationTimer * 31.0 + tOffset) + + disp_x = (smoothTriangleWave(animationTimer * 23.0 + tOffset) + + smoothTriangleWave(animationTimer * 11.0 + tOffset)) * 0.4; + disp_z = (smoothTriangleWave(animationTimer * 31.0 + tOffset) + smoothTriangleWave(animationTimer * 29.0 + tOffset) + - smoothTriangleWave(animationTimer * 13.0 + tOffset)) - 0.9; + smoothTriangleWave(animationTimer * 13.0 + tOffset)) * 0.5; #endif @@ -72,14 +75,15 @@ void main(void) gl_Position = mWorldViewProj * pos; #elif MATERIAL_TYPE == TILE_MATERIAL_WAVING_LEAVES && ENABLE_WAVING_LEAVES vec4 pos = gl_Vertex; - pos.x += disp * 0.1; - pos.y += disp * 0.1; - pos.z += disp; + pos.x += disp_x; + pos.y += disp_z * 0.1; + pos.z += disp_z; gl_Position = mWorldViewProj * pos; #elif MATERIAL_TYPE == TILE_MATERIAL_WAVING_PLANTS && ENABLE_WAVING_PLANTS vec4 pos = gl_Vertex; if (gl_TexCoord[0].y < 0.05) { - pos.z += disp; + pos.x += disp_x; + pos.z += disp_z; } gl_Position = mWorldViewProj * pos; #else @@ -91,7 +95,7 @@ void main(void) worldPosition = (mWorld * gl_Vertex).xyz; // Don't generate heightmaps when too far from the eye - float dist = distance (vec3(0.0, 0.0 ,0.0), vPosition); + float dist = distance (vec3(0.0, 0.0, 0.0), vPosition); if (dist > 150.0) { area_enable_parallax = 0.0; } @@ -132,16 +136,16 @@ void main(void) // Emphase blue a bit in darker places // See C++ implementation in mapblock_mesh.cpp finalColorBlend() - b += max(0.0, (1.0 - abs(b - 0.13)/0.17) * 0.025); + b += max(0.0, (1.0 - abs(b - 0.13) / 0.17) * 0.025); // Artificial light is yellow-ish // See C++ implementation in mapblock_mesh.cpp finalColorBlend() - rg += max(0.0, (1.0 - abs(rg - 0.85)/0.15) * 0.065); + rg += max(0.0, (1.0 - abs(rg - 0.85) / 0.15) * 0.065); color.r = rg; color.g = rg; color.b = b; color.a = gl_Color.a; - gl_FrontColor = gl_BackColor = clamp(color,0.0,1.0); + gl_FrontColor = gl_BackColor = clamp(color, 0.0, 1.0); } |