Is there a way to change image filter?

Shirted-VanesShirted-Vanes Posts: 13Member

I have colored textures in my game and I want to switch all of them to black-white.
The easiest way is to create two versions of texture files: with color and without it. And then in dependence of mode this textures switch.
But can I change like... color filter of viewport? Like it does Photoshop, for example.


Tags :

Answers

  • TwistedTwiglegTwistedTwigleg Posts: 1,927Admin

    Maybe the CanvasModulate (documentation) node? I have not used it with a Viewport myself, but it seems like it would be the ideal node for the job.

  • SIsilicon28SIsilicon28 Posts: 115Member
    edited October 2019

    You can add a custom shader to a ColorRect node for a postprocessing effect. In the case of black n' white, the shader code would look like this.

    shader_type canvas_item;
    render_mode unshaded;
    
    void fragment() {
        COLOR = texture(SCREEN_TEXTURE, SCREEN_UV);
    
        float luminance = dot(COLOR.rgb, vec3(0.3, 0.59, 0.11));
    
        COLOR.rgb = vec3(luminance);
    }
    

    To vary the strength of the effect, just change the alpha of the ColorRect's colour. :)

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file