Modulate Before Light

Before Light Modulate – Alters the color of the object before the light pass, preserving luminosity. The standard Modulate setting will change the color of the object and the light after the light has been applied.


cybereality on Reddit – Provided the super helpful solution for Before Light Modulate.

Shader code
shader_type canvas_item;

uniform vec4 before_light_modulate : hint_color = vec4(1.0,1.0,1.0,1.0);

void fragment() {
	vec4 texture_color = texture(TEXTURE, UV);
		COLOR = texture_color;
	} else {
		COLOR = texture_color * before_light_modulate;
2d, Color, light, modulate
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

More from MightyMochiGames

Toon Shading for 2D Sprites v1

2D Cel / Toon Shader v2 +Plus

2D Rim Light

Related shaders

UCBC’s Stylized Light with Light Masking

2D Light Z-Depth

2D Rim Light

Notify of

1 Comment
Newest Most Voted
Inline Feedbacks
View all comments
6 months ago

Here is a working Godot 4 version:

shader_type canvas_item;
varying vec4 modulate;

void vertex()
    modulate = COLOR;

void fragment()
    vec4 color = texture(TEXTURE, UV);
    COLOR = color * modulate;

void light()
    vec4 color = texture(TEXTURE, UV);
    LIGHT = vec4(color.rgb * LIGHT_COLOR.rgb * LIGHT_ENERGY, LIGHT_COLOR.a);

Last edited 6 months ago by Anixias