diff options
author | lhofhansl <lhofhansl@yahoo.com> | 2019-09-26 13:57:39 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-26 13:57:39 -0700 |
commit | 5fde69798c69b26b8f1cc5c3ed5b823d691599fd (patch) | |
tree | 3301e9ec0cca8f05bd81fe75fcf461ee000436ed /client | |
parent | 9e95bac75d43534614d168614624fa24048faf48 (diff) | |
download | minetest-5fde69798c69b26b8f1cc5c3ed5b823d691599fd.tar.gz minetest-5fde69798c69b26b8f1cc5c3ed5b823d691599fd.tar.bz2 minetest-5fde69798c69b26b8f1cc5c3ed5b823d691599fd.zip |
Simple shader fixes. (#8991)
1. Pass current camera offset to shader, so shader have access to the global coordinates
2. Pass animation timer to fragment shader. C++ code is already there, just wasn't declared in the shader
3. Delay animation timer wrap-around (from 100s to about 16 minutes)
Diffstat (limited to 'client')
-rw-r--r-- | client/shaders/nodes_shader/opengl_fragment.glsl | 9 | ||||
-rw-r--r-- | client/shaders/nodes_shader/opengl_vertex.glsl | 8 |
2 files changed, 17 insertions, 0 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 f1e63d5d9..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; |