2019-02-04 18:32:08 +01:00
|
|
|
#version 430 core
|
|
|
|
|
|
|
|
in layout(location = 0) vec3 position;
|
2019-03-17 15:17:44 +01:00
|
|
|
in layout(location = 1) vec3 normal;
|
2019-03-14 12:43:41 +01:00
|
|
|
in layout(location = 2) vec2 UV;
|
2019-03-18 11:48:11 +01:00
|
|
|
in layout(location = 3) vec4 color;
|
|
|
|
in layout(location = 4) vec3 tangent;
|
|
|
|
in layout(location = 5) vec3 bitangent;
|
2019-02-04 18:32:08 +01:00
|
|
|
|
2019-03-19 20:11:52 +01:00
|
|
|
layout(binding = 0) uniform sampler2D diffuseTexture;
|
|
|
|
layout(binding = 1) uniform sampler2D normalTexture;
|
2019-03-16 20:12:35 +01:00
|
|
|
layout(binding = 2) uniform sampler2D displacementTexture;
|
2019-03-19 20:15:13 +01:00
|
|
|
layout(binding = 3) uniform sampler2D reflectionTexture;
|
2019-03-16 20:12:35 +01:00
|
|
|
uniform float displacementCoefficient;
|
|
|
|
|
2019-03-15 16:26:31 +01:00
|
|
|
uniform mat4 MVP;
|
|
|
|
uniform mat4 MV;
|
|
|
|
uniform mat4 MVnormal;
|
2019-03-17 15:17:44 +01:00
|
|
|
|
2019-03-19 20:11:52 +01:00
|
|
|
// material
|
2019-03-17 15:17:44 +01:00
|
|
|
uniform vec2 uvOffset;
|
2019-03-19 20:11:52 +01:00
|
|
|
uniform float opacity;
|
|
|
|
uniform float shininess;
|
|
|
|
uniform vec3 diffuse_color;
|
|
|
|
uniform vec3 specular_color;
|
|
|
|
uniform vec3 emissive_color;
|
2019-03-17 15:17:44 +01:00
|
|
|
|
2019-03-14 12:43:41 +01:00
|
|
|
uniform bool isIlluminated;
|
|
|
|
uniform bool isTextured;
|
2019-03-19 20:11:52 +01:00
|
|
|
uniform bool isVertexColored;
|
2019-03-14 12:43:41 +01:00
|
|
|
uniform bool isNormalMapped;
|
2019-03-17 15:17:44 +01:00
|
|
|
uniform bool isDisplacementMapped;
|
2019-03-19 20:11:52 +01:00
|
|
|
uniform bool isReflectionMapped;
|
2019-03-17 15:17:44 +01:00
|
|
|
uniform bool isInverted;
|
2019-02-04 18:32:08 +01:00
|
|
|
|
2019-03-16 20:12:35 +01:00
|
|
|
out layout(location = 0) vec3 vertex_out;
|
|
|
|
out layout(location = 1) vec3 normal_out;
|
2019-03-14 12:43:41 +01:00
|
|
|
out layout(location = 2) vec2 uv_out;
|
2019-03-18 11:48:11 +01:00
|
|
|
out layout(location = 3) vec4 color_out;
|
|
|
|
out layout(location = 4) vec3 tangent_out;
|
|
|
|
out layout(location = 5) vec3 bitangent_out;
|
2019-02-04 18:32:08 +01:00
|
|
|
|
2019-03-14 12:43:41 +01:00
|
|
|
void main() {
|
2019-03-17 15:17:44 +01:00
|
|
|
vec3 displacement = vec3(0.0);
|
2019-03-19 20:11:52 +01:00
|
|
|
if (isDisplacementMapped) {
|
2019-03-17 15:17:44 +01:00
|
|
|
float o = texture(displacementTexture, UV + uvOffset).r * 2.0 - 1.0;
|
|
|
|
float u = (texture(displacementTexture, UV + uvOffset + vec2(0.001, 0.0)).r*2.0-1.0 - o) / 0.004;
|
|
|
|
float v = (texture(displacementTexture, UV + uvOffset + vec2(0.0, 0.001)).r*2.0-1.0 - o) / 0.004;
|
|
|
|
|
|
|
|
displacement = normal * displacementCoefficient * o;
|
|
|
|
}
|
|
|
|
|
|
|
|
normal_out = normalize(vec3(MVnormal * vec4(normal, 1.0f)));
|
|
|
|
vertex_out = vec3(MV * vec4(position+displacement, 1.0f));
|
|
|
|
uv_out = UV + uvOffset;
|
|
|
|
gl_Position = MVP * vec4(position+displacement, 1.0f);
|
2019-03-14 12:43:41 +01:00
|
|
|
|
2019-03-18 11:48:11 +01:00
|
|
|
color_out = color;
|
|
|
|
|
2019-03-17 15:17:44 +01:00
|
|
|
tangent_out = normalize(vec3(MVnormal * vec4(tangent, 1.0f)));
|
|
|
|
bitangent_out = normalize(vec3(MVnormal * vec4(bitangent, 1.0f)));
|
2019-02-04 18:32:08 +01:00
|
|
|
}
|