9f39644199
- The G-Buffer layout has been redesigned to be 96 bits per pixel. There are 24 unused bits that can be used for extra material parameters later (like clearcoat). - Add better debug views for the G-Buffer. - Use octahedron normal encoding. This yields the same results as the previous method but uses 16 bits less. - Use rg11fb10f for the environment mapping cubemaps. - Tweak the shadow mapping parameters and add a colored debug mode. - Only render shadow maps for objects that inherit from model-default.eff or model-pbr.eff instead of having a fallback Effect. Now transparent objects should be ignored (if they are marked as such with model-transparent or similar). - Remove the separate occlusion texture. Now the PBR Effect expects a single texture where R=occlusion, G=roughness and B=metallic.
42 lines
1.1 KiB
GLSL
42 lines
1.1 KiB
GLSL
#version 330 core
|
|
|
|
layout(location = 0) out vec4 outGBuffer0;
|
|
layout(location = 1) out vec4 outGBuffer1;
|
|
layout(location = 2) out vec4 outGBuffer2;
|
|
|
|
in vec2 texCoord;
|
|
in mat3 TBN;
|
|
|
|
uniform sampler2D color_tex;
|
|
uniform sampler2D normal_tex;
|
|
uniform int normalmap_enabled;
|
|
uniform int normalmap_dds;
|
|
uniform float normalmap_tiling;
|
|
|
|
const float DEFAULT_COMBINED_METALNESS = 0.0;
|
|
const float DEFAULT_COMBINED_ROUGHNESS = 0.1;
|
|
|
|
vec2 encodeNormal(vec3 n);
|
|
vec3 decodeSRGB(vec3 screenRGB);
|
|
|
|
void main()
|
|
{
|
|
vec3 color = decodeSRGB(texture(color_tex, texCoord).rgb);
|
|
|
|
vec3 normal = vec3(0.0, 0.0, 1.0);
|
|
if (normalmap_enabled > 0) {
|
|
normal = texture(normal_tex, texCoord * normalmap_tiling).rgb * 2.0 - 1.0;
|
|
// DDS has flipped normals
|
|
if (normalmap_dds > 0)
|
|
normal = -normal;
|
|
}
|
|
normal = normalize(TBN * normal);
|
|
|
|
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;
|
|
}
|