From 05994100ea9e8bf4076fc7d2eee5828778bd6d51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Garc=C3=ADa=20Li=C3=B1=C3=A1n?= Date: Wed, 18 Aug 2021 12:27:03 +0200 Subject: [PATCH] HDR: Better handling of model-combined for backwards compatibility --- Effects/model-combined.eff | 17 ++++++++++++++++- Shaders/HDR/geometry-combined.frag | 10 ++++++++-- Shaders/HDR/geometry.frag | 3 ++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Effects/model-combined.eff b/Effects/model-combined.eff index 8b70c8fb1..6f3b3174e 100644 --- a/Effects/model-combined.eff +++ b/Effects/model-combined.eff @@ -16,7 +16,12 @@ please see Docs/README.model-combined.eff for documentation 0 1.0 - null-normalmap + Aircraft/Generic/Effects/null_bumpspec.png + 2d + linear-mipmap-linear + clamp + clamp + normalized 0 @@ -1330,6 +1335,16 @@ please see Docs/README.model-combined.eff for documentation sampler-2d 1 + + normalmap_enabled + int + normalmap-enabled + + + normalmap_tiling + float + normalmap-tiling + diff --git a/Shaders/HDR/geometry-combined.frag b/Shaders/HDR/geometry-combined.frag index c31685745..a9ff63f8a 100644 --- a/Shaders/HDR/geometry-combined.frag +++ b/Shaders/HDR/geometry-combined.frag @@ -9,18 +9,24 @@ in mat3 TBN; uniform sampler2D color_tex; uniform sampler2D normal_tex; +uniform int normalmap_enabled; +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() { - gbuffer0.rgb = pow(texture(color_tex, texCoord).rgb, vec3(2.2)); // Gamma correction + gbuffer0.rgb = decodeSRGB(texture(color_tex, texCoord).rgb); gbuffer0.a = 1.0; - vec3 normal = texture(normal_tex, texCoord).rgb * 2.0 - 1.0; + vec3 normal = vec3(0.5, 0.5, 1.0); + if (normalmap_enabled > 0) { + normal = texture(normal_tex, texCoord * normalmap_tiling).rgb * 2.0 - 1.0; + } normal = normalize(TBN * normal); gbuffer1 = encodeNormal(normal); diff --git a/Shaders/HDR/geometry.frag b/Shaders/HDR/geometry.frag index a051ae953..9ec86494f 100644 --- a/Shaders/HDR/geometry.frag +++ b/Shaders/HDR/geometry.frag @@ -13,10 +13,11 @@ const float DEFAULT_METALNESS = 0.0; const float DEFAULT_ROUGHNESS = 0.8; vec2 encodeNormal(vec3 n); +vec3 decodeSRGB(vec3 screenRGB); void main() { - gbuffer0.rgb = pow(texture(color_tex, texCoord).rgb, vec3(2.2)); // Gamma correction + gbuffer0.rgb = decodeSRGB(texture(color_tex, texCoord).rgb); gbuffer0.a = 1.0; gbuffer1 = encodeNormal(normalVS); gbuffer2 = vec4(DEFAULT_METALNESS,