From 7f74422ffd84dc0b5401b599c82f0d105629a38e Mon Sep 17 00:00:00 2001 From: harrand Date: Thu, 12 Oct 2023 00:57:42 +0100 Subject: [PATCH] [mesh_renderer/animation_renderer] now discard fragments with an alpha value lower than 0.1. this is not a documented feature, is generally evil, but red nightmare needs it now :) --- src/tz/ren/shaders/animation.fragment.tzsl | 10 +++++++++- src/tz/ren/shaders/mesh.fragment.tzsl | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/tz/ren/shaders/animation.fragment.tzsl b/src/tz/ren/shaders/animation.fragment.tzsl index e1678c97c1..47fe92631b 100644 --- a/src/tz/ren/shaders/animation.fragment.tzsl +++ b/src/tz/ren/shaders/animation.fragment.tzsl @@ -34,7 +34,15 @@ void main() else { // note: base colour is guaranteed to be sRGB. we need to tonemap here ideally, but we don't right now. - out::colour.xyz = texture(res::textures[base_colour.texture_id], in::texcoord[0]).xyz * base_colour.colour_tint; + // note2: we discard fragments with alpha values lower than 0.1. + // this is not a documented feature, and should be disabled by default. TODO: less shit + vec4 col = texture(res::textures[base_colour.texture_id], in::texcoord[0]); + if(col.w < 0.1f) + { + discard; + return; + } + out::colour.xyz = col.xyz * base_colour.colour_tint; } texture_locator metallic_roughness = in::textures[1]; if(metallic_roughness.texture_id != BADU) diff --git a/src/tz/ren/shaders/mesh.fragment.tzsl b/src/tz/ren/shaders/mesh.fragment.tzsl index 7990de11ee..24a6d344c8 100644 --- a/src/tz/ren/shaders/mesh.fragment.tzsl +++ b/src/tz/ren/shaders/mesh.fragment.tzsl @@ -34,7 +34,15 @@ void main() else { // note: base colour is guaranteed to be sRGB. we need to tonemap here ideally, but we don't right now. - out::colour.xyz = texture(res::textures[base_colour.texture_id], in::texcoord[0]).xyz * base_colour.colour_tint; + // note2: we discard fragments with alpha values lower than 0.1. + // this is not a documented feature, and should be disabled by default. TODO: less shit + vec4 col = texture(res::textures[base_colour.texture_id], in::texcoord[0]); + if(col.w < 0.1f) + { + discard; + return; + } + out::colour.xyz = col.xyz * base_colour.colour_tint; } texture_locator metallic_roughness = in::textures[1]; if(metallic_roughness.texture_id != BADU)