+1 vote

Working in 2D here, I have a shader that converts a sprite into grayscale, but I was wondering if there was a way to change the sprite's color before converting to grayscale via shader (so that way the color is reflected in the grayscale).

Using modulate changes the color no matter the material/shader, so is there another way to do this? Thank you in advance!

Figured it out on my own! For reference, if anyone else wants to do this as well, here is what I ended up doing:

shader_type canvas_item;
uniform vec4 tint_color : hint_color;

void fragment() {
    COLOR = tint_color * texture(TEXTURE, UV);
    float avg = (COLOR.r + COLOR.g + COLOR.b) / 3.0;
    COLOR.rgb = vec3(avg);
Godot version 3.3.3
in Engine by (22 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.