Skip to content

Commit

Permalink
🍓 Alpha cutoff
Browse files Browse the repository at this point in the history
  • Loading branch information
benc-uk committed Mar 4, 2024
1 parent f4d6326 commit 5ff5d36
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion shaders/billboard/glsl.frag
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ struct Material {
sampler2D specularTex;
sampler2D normalTex;
bool hasNormalTex;
float alphaCutoff;
};

// From vertex shader
Expand All @@ -37,11 +38,15 @@ void main() {

// Magic to make transparent sprites work, without blending
// Somehow this also works with the shadow map render pass, which is a bonus
if (texel.a < 0.75) {
if (texel.a < u_mat.alphaCutoff) {
discard;
}

vec3 colour = texel.rgb * u_mat.diffuse * v_lighting;
float e = u_mat.emissive.r + u_mat.emissive.g + u_mat.emissive.b;
if (e > 0.0) {
colour = texel.rgb * u_mat.emissive;
}

// Gamma correction, as GL_FRAMEBUFFER_SRGB is not supported on WebGL
colour = pow(colour, vec3(1.0 / u_gamma));
Expand Down

0 comments on commit 5ff5d36

Please sign in to comment.