summaryrefslogtreecommitdiff
path: root/client/shaders/object_shader/opengl_vertex.glsl
diff options
context:
space:
mode:
authorVitaliy <numzer0@yandex.ru>2020-10-25 20:01:03 +0300
committerGitHub <noreply@github.com>2020-10-25 18:01:03 +0100
commit707c8c1e95d8db2d84909e7957b4dc9138e05599 (patch)
tree84604fc1868c7b8ca8e977d5dd0485498500cdfe /client/shaders/object_shader/opengl_vertex.glsl
parent33b2c5f5b1c565171296f26395d803b08f4575e9 (diff)
downloadminetest-707c8c1e95d8db2d84909e7957b4dc9138e05599.tar.gz
minetest-707c8c1e95d8db2d84909e7957b4dc9138e05599.tar.bz2
minetest-707c8c1e95d8db2d84909e7957b4dc9138e05599.zip
Shaders for Android (GLES 2) (#10506)
Shader support for OpenGL ES 2 devices (Android) Co-authored-by: sfan5 <sfan5@live.de>
Diffstat (limited to 'client/shaders/object_shader/opengl_vertex.glsl')
-rw-r--r--client/shaders/object_shader/opengl_vertex.glsl25
1 files changed, 13 insertions, 12 deletions
diff --git a/client/shaders/object_shader/opengl_vertex.glsl b/client/shaders/object_shader/opengl_vertex.glsl
index f8c1cd932..e44984dc8 100644
--- a/client/shaders/object_shader/opengl_vertex.glsl
+++ b/client/shaders/object_shader/opengl_vertex.glsl
@@ -1,4 +1,3 @@
-uniform mat4 mWorldViewProj;
uniform mat4 mWorld;
uniform vec3 eyePosition;
@@ -7,6 +6,8 @@ uniform float animationTimer;
varying vec3 vNormal;
varying vec3 vPosition;
varying vec3 worldPosition;
+varying lowp vec4 varColor;
+varying mediump vec2 varTexCoord;
varying vec3 eyeVec;
varying float vIDiff;
@@ -18,31 +19,31 @@ float directional_ambient(vec3 normal)
{
vec3 v = normal * normal;
- if (normal.y < 0)
- return dot(v, vec3(0.670820f, 0.447213f, 0.836660f));
+ if (normal.y < 0.0)
+ return dot(v, vec3(0.670820, 0.447213, 0.836660));
- return dot(v, vec3(0.670820f, 1.000000f, 0.836660f));
+ return dot(v, vec3(0.670820, 1.000000, 0.836660));
}
void main(void)
{
- gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
- gl_Position = mWorldViewProj * gl_Vertex;
+ varTexCoord = (mTexture * inTexCoord0).st;
+ gl_Position = mWorldViewProj * inVertexPosition;
vPosition = gl_Position.xyz;
- vNormal = gl_Normal;
- worldPosition = (mWorld * gl_Vertex).xyz;
- eyeVec = -(gl_ModelViewMatrix * gl_Vertex).xyz;
+ vNormal = inVertexNormal;
+ worldPosition = (mWorld * inVertexPosition).xyz;
+ eyeVec = -(mWorldView * inVertexPosition).xyz;
#if (MATERIAL_TYPE == TILE_MATERIAL_PLAIN) || (MATERIAL_TYPE == TILE_MATERIAL_PLAIN_ALPHA)
vIDiff = 1.0;
#else
// This is intentional comparison with zero without any margin.
// If normal is not equal to zero exactly, then we assume it's a valid, just not normalized vector
- vIDiff = length(gl_Normal) == 0.0
+ vIDiff = length(inVertexNormal) == 0.0
? 1.0
- : directional_ambient(normalize(gl_Normal));
+ : directional_ambient(normalize(inVertexNormal));
#endif
- gl_FrontColor = gl_BackColor = gl_Color;
+ varColor = inVertexColor;
}