From d0e38703467b9c4c1a8003b286516297d9ab2ce9 Mon Sep 17 00:00:00 2001 From: Rod Kay Date: Mon, 23 Sep 2024 17:08:36 +1000 Subject: [PATCH] opengl.texturing: Update shader 'frag.snippet' to allow models with multiple textures to selectively apply/unapply individual textures. --- .../assets/shader/texturing-frag.snippet | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/3-mid/opengl/assets/shader/texturing-frag.snippet b/3-mid/opengl/assets/shader/texturing-frag.snippet index ad26965..e972c64 100644 --- a/3-mid/opengl/assets/shader/texturing-frag.snippet +++ b/3-mid/opengl/assets/shader/texturing-frag.snippet @@ -1,26 +1,33 @@ uniform int texture_Count; -uniform sampler2D Textures [16]; -uniform float Fade [16]; +uniform sampler2D Textures [16]; +uniform float Fade [16]; +uniform bool texture_Applies [16]; + vec4 apply_Texturing (vec2 Coords) { vec4 Color = vec4 (0); + for (int i = 0; i < texture_Count; ++i) { - Color.rgb += texture (Textures [i], Coords).rgb - * texture (Textures [i], Coords).a - * (1.0 - Fade [i]); + if (texture_Applies [i]) + { + Color.rgb += texture (Textures [i], Coords).rgb + * texture (Textures [i], Coords).a + * (1.0 - Fade [i]); -// Color.a += texture (Textures [i], Coords).a * (1.0 - Fade [1]); +// Color.a += texture (Textures [i], Coords).a * (1.0 - Fade [1]); - Color.a = max (Color.a, - texture (Textures [i],Coords).a * (1.0 - Fade [i])); + Color.a = max (Color.a, + texture (Textures [i],Coords).a * (1.0 - Fade [i])); -// Color.a = max (Color.a, -// texture (Textures [i],Coords).a); +// Color.a = max (Color.a, +// texture (Textures [i],Coords).a); + } } + return Color; }