grayscale
Converts a color value (vec3/vec4) into its corresponding grayscale (luminance) value (float), effectively removing color information to retain only brightness.
Core Advantages
Replaces the complex, error-prone, and less readable manual luminance calculation `dot(color.rgb, vec3(0.299, 0.587, 0.114))` with a simple function call `grayscale(color)`, significantly improving code conciseness and maintainability.
Common Uses
Creating black and white film or photo effects.
Acting as a factor for a `mix` node to achieve a smooth transition from color to black and white, dynamically controlling saturation.
Using the luminance information of a texture as a mask to blend two different textures or effects.
Controlling emission intensity based on texture brightness, such as making windows in a city nightscape texture glow.
How to adjust
This node has no adjustable parameters itself. Its effect is entirely determined by the input color. A common way to adjust it is to use a `mix` node to blend the original color with its grayscale version, using a `uniform` variable (e.g., `fadeAmount`) to control the blend ratio, thus achieving a smooth transition from full color to full grayscale.
Code Examples
1const finalColor = mix( originalColor, vec3( grayscale( originalColor ) ), desaturationAmount );