Skip to content

Commit

Permalink
Rename vertex and fragment shaders to generic GLSL extension
Browse files Browse the repository at this point in the history
  • Loading branch information
scarletcafe committed Sep 9, 2019
1 parent 23d2081 commit 3fdb5eb
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 44 deletions.
40 changes: 0 additions & 40 deletions eldstar_server/resources/shaders/mesh.vs

This file was deleted.

File renamed without changes.
40 changes: 40 additions & 0 deletions eldstar_server/resources/shaders/mesh_vs.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#version 330 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec3 aNormal;
layout (location = 2) in vec4 aColor;

out vec3 fPos;
out vec3 fNormal;
out vec4 fColor;

uniform mat4 camera;
uniform mat4 model;
uniform vec4 globalColor;
uniform int colorMode;


void main()
{
vec3 normal_head = vec3(model * vec4(aNormal, 1.0));
vec3 normal_tail = vec3(model * vec4(0.0, 0.0, 0.0, 1.0));
vec3 normal = normal_head - normal_tail;
vec4 pos = model * vec4(aPos, 1.0);

fPos = vec3(pos);
fNormal = normal;

vec4 outColor = aColor * globalColor;

if (colorMode == 0)
fColor = outColor;
else if (colorMode == 1 || colorMode == 2) {
if (normal.y > 0.01)
fColor = vec4(0.25, 0.25, 1.0, outColor.w);
else if (normal.y < -0.01)
fColor = vec4(1.0, 0.25, 0.25, outColor.w);
else
fColor = vec4(0.25, 1.0, 0.25, outColor.w);
}

gl_Position = camera * pos;
}
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions eldstar_server/src/resources.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ class resource_manager {
opensans(&freetype, loaders::file("resources/fonts/OpenSans.ttf"), 20),

text({
loaders::shader(GL_VERTEX_SHADER, loaders::file("resources/shaders/text.vs")),
loaders::shader(GL_FRAGMENT_SHADER, loaders::file("resources/shaders/text.fs"))
loaders::shader(GL_VERTEX_SHADER, loaders::file("resources/shaders/text_vs.glsl")),
loaders::shader(GL_FRAGMENT_SHADER, loaders::file("resources/shaders/text_fs.glsl"))
}),
mesh({
loaders::shader(GL_VERTEX_SHADER, loaders::file("resources/shaders/mesh.vs")),
loaders::shader(GL_FRAGMENT_SHADER, loaders::file("resources/shaders/mesh.fs"))
loaders::shader(GL_VERTEX_SHADER, loaders::file("resources/shaders/mesh_vs.glsl")),
loaders::shader(GL_FRAGMENT_SHADER, loaders::file("resources/shaders/mesh_fs.glsl"))
}),

camera(loaders::file("resources/models/camera.stl")),
Expand Down

0 comments on commit 3fdb5eb

Please sign in to comment.