Skip to content

Commit

Permalink
shaders: Remove some left-over fixed-pipeline stuff, slight cleanup.
Browse files Browse the repository at this point in the history
gl_TextureMatrix[0] seemed to be just the identity matrix.

Made gl_Position write-only in the vertex shaders.

Used float literals instead of int literals where appropriate.

Removed unused terrain.vert and water.vert.
  • Loading branch information
Cyp committed Mar 11, 2017
1 parent e32f2d6 commit b260bc8
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 61 deletions.
4 changes: 2 additions & 2 deletions data/base/shaders/button.vert
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
uniform mat4 ModelViewProjectionMatrix;

attribute vec4 vertex;
attribute vec4 vertexTexCoord;
attribute vec2 vertexTexCoord;

varying vec2 texCoord;

void main()
{
// Pass texture coordinates to fragment shader
texCoord = (gl_TextureMatrix[0] * vertexTexCoord).xy;
texCoord = vertexTexCoord;

// Translate every vertex according to the Model, View and Projection matrices
gl_Position = ModelViewProjectionMatrix * vertex;
Expand Down
7 changes: 4 additions & 3 deletions data/base/shaders/decals.vert
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ varying float vertexDistance;

void main()
{
gl_Position = ModelViewProjectionMatrix * vertex;
vec4 position = ModelViewProjectionMatrix * vertex;
gl_Position = position;
uv_tex = vertexTexCoord;
vec4 uv_lightmap_tmp = lightTextureMatrix * vec4(dot(paramxlight, vertex), dot(paramylight, vertex), 0., 1.);
vec4 uv_lightmap_tmp = lightTextureMatrix * vec4(dot(paramxlight, vertex), dot(paramylight, vertex), 0.0, 1.0);
uv_lightmap = uv_lightmap_tmp.xy / uv_lightmap_tmp.w;
vertexDistance = gl_Position.z;
vertexDistance = position.z;
}
4 changes: 2 additions & 2 deletions data/base/shaders/gfx.vert
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
uniform mat4 posMatrix;

in vec4 vertex;
in vec4 vertexTexCoord;
in vec2 vertexTexCoord;
in vec4 vertexColor;

out vec2 uv;
Expand All @@ -12,7 +12,7 @@ out vec4 color;
void main()
{
// Pass texture coordinates to fragment shader
uv = vertexTexCoord.xy;
uv = vertexTexCoord;

gl_Position = posMatrix * vertex;
color = vertexColor;
Expand Down
4 changes: 2 additions & 2 deletions data/base/shaders/nolight.vert
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
uniform mat4 ModelViewProjectionMatrix;

attribute vec4 vertex;
attribute vec4 vertexTexCoord;
attribute vec2 vertexTexCoord;

varying vec2 texCoord;

void main()
{
// Pass texture coordinates to fragment shader
texCoord = (gl_TextureMatrix[0] * vertexTexCoord).xy;
texCoord = vertexTexCoord;

// Translate every vertex according to the Model, View and Projection matrices
gl_Position = ModelViewProjectionMatrix * vertex;
Expand Down
16 changes: 8 additions & 8 deletions data/base/shaders/rect.vert
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ out vec2 uv;

vec4 getPos(int id)
{
if (id == 0) return vec4(0, 1, 0, 1);
if (id == 1) return vec4(0, 0, 0, 1);
if (id == 2) return vec4(1, 1, 0, 1);
if (id == 3) return vec4(1, 0, 0, 1);
if (id == 0) return vec4(0.0, 1.0, 0.0, 1.0);
if (id == 1) return vec4(0.0, 0.0, 0.0, 1.0);
if (id == 2) return vec4(1.0, 1.0, 0.0, 1.0);
if (id == 3) return vec4(1.0, 0.0, 0.0, 1.0);
}

vec2 getTC(int id)
{
if (id == 0) return vec2(0., 1.);
if (id == 1) return vec2(0., 0.);
if (id == 2) return vec2(1., 1.);
if (id == 3) return vec2(1., 0.);
if (id == 0) return vec2(0.0, 1.0);
if (id == 1) return vec2(0.0, 0.0);
if (id == 2) return vec2(1.0, 1.0);
if (id == 3) return vec2(1.0, 0.0);
}

void main()
Expand Down
11 changes: 6 additions & 5 deletions data/base/shaders/tcmask.vert
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ uniform vec4 lightPosition;

attribute vec4 vertex;
attribute vec3 vertexNormal;
attribute vec4 vertexTexCoord;
attribute vec2 vertexTexCoord;

varying float vertexDistance;
varying vec3 normal, lightDir, eyeVec;
Expand All @@ -22,10 +22,10 @@ void main()
vec4 position = vertex;

// Pass texture coordinates to fragment shader
texCoord = vertexTexCoord.xy;
texCoord = vertexTexCoord;

// Lighting -- we pass these to the fragment shader
normal = (NormalMatrix * vec4(vertexNormal, 0)).xyz;
normal = (NormalMatrix * vec4(vertexNormal, 0.0)).xyz;
lightDir = lightPosition.xyz - vVertex;
eyeVec = -vVertex;

Expand All @@ -36,8 +36,9 @@ void main()
}

// Translate every vertex according to the Model View and Projection Matrix
gl_Position = ModelViewProjectionMatrix * position;
vec4 gposition = ModelViewProjectionMatrix * position;
gl_Position = gposition;

// Remember vertex distance
vertexDistance = gl_Position.z;
vertexDistance = gposition.z;
}
20 changes: 0 additions & 20 deletions data/base/shaders/terrain.vert

This file was deleted.

5 changes: 3 additions & 2 deletions data/base/shaders/terrain_water.vert
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ varying float vertexDistance;
void main()
{
color = vertexColor;
gl_Position = ModelViewProjectionMatrix * vertex;
vec4 position = ModelViewProjectionMatrix * vertex;
gl_Position = position;
vec4 uv1_tmp = textureMatrix1 * vec4(dot(paramx1, vertex), dot(paramy1, vertex), 0., 1.);
uv1 = uv1_tmp.xy / uv1_tmp.w;
vec4 uv2_tmp = textureMatrix2 * vec4(dot(paramx2, vertex), dot(paramy2, vertex), 0., 1.);
uv2 = uv2_tmp.xy / uv2_tmp.w;
vertexDistance = gl_Position.z;
vertexDistance = position.z;
}
17 changes: 0 additions & 17 deletions data/base/shaders/water.vert

This file was deleted.

0 comments on commit b260bc8

Please sign in to comment.