fix shader

This commit is contained in:
griffi-gh 2024-05-02 01:24:27 +02:00
parent 62c3c2105e
commit 6cde878a50

View file

@ -10,21 +10,17 @@ out vec4 color;
uniform sampler2DArray tex; uniform sampler2DArray tex;
uniform bool discard_alpha; uniform bool discard_alpha;
// vec4 alpha_drop(vec4 b, vec4 a) {
// if ((a.w < 1.) || (b.w < 1.)) {
// return vec4(b.xyz, 0.);
// }
// return a;
// }
void main() { void main() {
// base color from texture // base color from texture
color = texture(tex, vec3(v_uv, v_tex_index)); color = texture(tex, vec3(v_uv, v_tex_index));
// discard transparent pixels
if (color.w < (discard_alpha ? 0.01 : 0.5)) discard; // discard fully transparent pixels
if (discard_alpha ? (color.w < 0.5) : (color.w == 0.)) discard;
//basic "lighting" //basic "lighting"
float light = abs(v_normal.x) + .8 * abs(v_normal.y) + .6 * abs(v_normal.z); float light = abs(v_normal.x) + .8 * abs(v_normal.y) + .6 * abs(v_normal.z);
color *= vec4(vec3(light), 1.); color *= vec4(vec3(light), 1.);
//discard alpha //discard alpha
if (discard_alpha) color.w = 1.; if (discard_alpha) color.w = 1.;
} }