diff options
Diffstat (limited to 'client/shaders')
-rw-r--r-- | client/shaders/nodes_shader/opengl_fragment.glsl | 9 | ||||
-rw-r--r-- | client/shaders/nodes_shader/opengl_vertex.glsl | 10 |
2 files changed, 18 insertions, 1 deletions
diff --git a/client/shaders/nodes_shader/opengl_fragment.glsl b/client/shaders/nodes_shader/opengl_fragment.glsl index 7c5b9b613..19e6c2d86 100644 --- a/client/shaders/nodes_shader/opengl_fragment.glsl +++ b/client/shaders/nodes_shader/opengl_fragment.glsl @@ -6,7 +6,16 @@ uniform vec4 skyBgColor; uniform float fogDistance; uniform vec3 eyePosition; +// The cameraOffset is the current center of the visible world. +uniform vec3 cameraOffset; +uniform float animationTimer; + varying vec3 vPosition; +// World position in the visible world (i.e. relative to the cameraOffset.) +// This can be used for many shader effects without loss of precision. +// If the absolute position is required it can be calculated with +// cameraOffset + worldPosition (for large coordinates the limits of float +// precision must be considered). varying vec3 worldPosition; varying float area_enable_parallax; diff --git a/client/shaders/nodes_shader/opengl_vertex.glsl b/client/shaders/nodes_shader/opengl_vertex.glsl index 54b569c5e..bbf7b1d65 100644 --- a/client/shaders/nodes_shader/opengl_vertex.glsl +++ b/client/shaders/nodes_shader/opengl_vertex.glsl @@ -4,9 +4,17 @@ uniform mat4 mWorld; // Color of the light emitted by the sun. uniform vec3 dayLight; uniform vec3 eyePosition; + +// The cameraOffset is the current center of the visible world. +uniform vec3 cameraOffset; uniform float animationTimer; varying vec3 vPosition; +// World position in the visible world (i.e. relative to the cameraOffset.) +// This can be used for many shader effects without loss of precision. +// If the absolute position is required it can be calculated with +// cameraOffset + worldPosition (for large coordinates the limits of float +// precision must be considered). varying vec3 worldPosition; varying vec3 eyeVec; @@ -68,7 +76,7 @@ float disp_z; #endif -#if (MATERIAL_TYPE == TILE_MATERIAL_LIQUID_TRANSPARENT || MATERIAL_TYPE == TILE_MATERIAL_LIQUID_OPAQUE) && ENABLE_WAVING_WATER +#if (MATERIAL_TYPE == TILE_MATERIAL_WAVING_LIQUID_TRANSPARENT || MATERIAL_TYPE == TILE_MATERIAL_WAVING_LIQUID_OPAQUE || MATERIAL_TYPE == TILE_MATERIAL_WAVING_LIQUID_BASIC) && ENABLE_WAVING_WATER vec4 pos = gl_Vertex; pos.y -= 2.0; float posYbuf = (pos.z / WATER_WAVE_LENGTH + animationTimer * WATER_WAVE_SPEED * WATER_WAVE_LENGTH); |