2021-04-10 09:14:16 +00:00
|
|
|
#version 330 core
|
|
|
|
|
2021-08-26 20:51:46 +00:00
|
|
|
layout(location = 0) out vec4 outGBuffer0;
|
|
|
|
layout(location = 1) out vec4 outGBuffer1;
|
|
|
|
layout(location = 2) out vec4 outGBuffer2;
|
2021-04-10 09:14:16 +00:00
|
|
|
|
|
|
|
in vec2 texCoord;
|
|
|
|
in mat3 TBN;
|
|
|
|
|
|
|
|
uniform sampler2D color_tex;
|
|
|
|
uniform sampler2D normal_tex;
|
2021-08-18 10:27:03 +00:00
|
|
|
uniform int normalmap_enabled;
|
2021-08-19 16:20:37 +00:00
|
|
|
uniform int normalmap_dds;
|
2021-08-18 10:27:03 +00:00
|
|
|
uniform float normalmap_tiling;
|
2021-04-10 09:14:16 +00:00
|
|
|
|
|
|
|
const float DEFAULT_COMBINED_METALNESS = 0.0;
|
2021-08-25 13:16:38 +00:00
|
|
|
const float DEFAULT_COMBINED_ROUGHNESS = 0.1;
|
2021-04-10 09:14:16 +00:00
|
|
|
|
|
|
|
vec2 encodeNormal(vec3 n);
|
2021-08-18 10:27:03 +00:00
|
|
|
vec3 decodeSRGB(vec3 screenRGB);
|
2021-04-10 09:14:16 +00:00
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2021-08-26 20:51:46 +00:00
|
|
|
vec3 color = decodeSRGB(texture(color_tex, texCoord).rgb);
|
2021-04-10 09:14:16 +00:00
|
|
|
|
2021-08-25 13:16:38 +00:00
|
|
|
vec3 normal = vec3(0.0, 0.0, 1.0);
|
2021-08-18 10:27:03 +00:00
|
|
|
if (normalmap_enabled > 0) {
|
|
|
|
normal = texture(normal_tex, texCoord * normalmap_tiling).rgb * 2.0 - 1.0;
|
2021-08-19 16:20:37 +00:00
|
|
|
// DDS has flipped normals
|
|
|
|
if (normalmap_dds > 0)
|
|
|
|
normal = -normal;
|
2021-08-18 10:27:03 +00:00
|
|
|
}
|
2021-04-10 09:14:16 +00:00
|
|
|
normal = normalize(TBN * normal);
|
|
|
|
|
2021-08-26 20:51:46 +00:00
|
|
|
outGBuffer0.rg = encodeNormal(normal);
|
|
|
|
outGBuffer0.b = DEFAULT_COMBINED_ROUGHNESS;
|
|
|
|
outGBuffer0.a = 1.0;
|
|
|
|
outGBuffer1.rgb = color;
|
|
|
|
outGBuffer1.a = DEFAULT_COMBINED_METALNESS;
|
|
|
|
outGBuffer2.rgb = vec3(0.0);
|
|
|
|
outGBuffer2.a = 1.0;
|
2021-04-10 09:14:16 +00:00
|
|
|
}
|