Wiki

Clone wiki

Mono:UI / Shaders / m_SRtoAlpha

INTRODUCED: v0.1.0
LAST UPDATED: v0.1.1

m_SRtoAlpha

This Shader uses the red channel as an alpha channel. Because of Game Maker's blending restrictions it's very difficult to override the alpha channel of the surface that's being drawn to. Since some Mono:UI features do need this, this Shader provides a workaround.
The colour parameter then indicates the colour that the image should be drawn in. The original colour if the image is ignored entirely.

Usage

surface_set_target( surface );
    draw_set_colour( c_black );
    draw_rectangle( 0, 0, 10, 10, false );
    draw_set_colour( c_white );
    draw_circle(5, 5, 5, false );
surface_reset_target();

shader_set( m_SRtoAlpha );
    var
        _c = c_blue,
        _u = shader_get_uniform( m_SRtoAlpha, "colour" );
    shader_set_uniform_f(
        _u,
        color_get_red( _c ),
        color_get_green( _c ),
        color_get_blue( _c )
    );
    draw_surface( surface, 0, 0 );
shader_reset();

// Result: A square with a circle cut out of it in c_blue. 

Parameters

Shader Type Name Description
Fragment
vec3 colour The colour to draw in.

Updated