bvec4
Converts a four-dimensional vector (like an RGBA color) into a boolean vector (`bvec4`) component-wise, where 0 becomes `false` and any non-zero value becomes `true`.
Core Advantages
Encapsulates the most tedious manual boolean conversion (four components) into a single node, providing a powerful, unified way to perform logical checks on both color and alpha (RGBA), which is key for advanced blending and effects.
Common Uses
Implementing conditional transparency or fragment discard (e.g., dissolve, energy shield effects)
As a mask for the `mix` function to perform full RGBA channel-wise mixing
Analyzing material data packed into texture channels (e.g., metallic, roughness)
How to adjust
This node's effect is entirely determined by its input `vec4`. To create dynamic effects, modify the input before the conversion. For example, procedurally control the input color's alpha channel using a `uniform` (like `dissolveFactor`) and a noise texture to achieve a common dissolve effect.
Code Examples
1// Get a boolean mask from a texture, including the alpha channel
2const mask = texture(myTexture, uv()).bvec4();
3
4// Discard the pixel if the original alpha was 0 (mask.w will be false)
5// This is an efficient way to achieve hard-edged transparency
6discard( equal( mask.w, false ) );