GMS 2 Light shader

N

NNNIKKI

Guest
I wanted to make a shader for hovering over buttons, which made them lighter.

v_vColour = vec4(in_Colour.r + 128, in_Colour.g + 128, in_Colour.b + 128, in_Colour.a);

For some reason I can't use "+"-es.
WHY?!?!!?
 

Paskaler

Member
The RGB values might be floating point numbers here. If it is so, the range goes from 0.0f to 1.0f, maybe try putting 0.5f instead. The 'f' might not be needed, so try putting numbers in without it, too.
 
N

NNNIKKI

Guest
I replaced 128 with 128.0 and it works.

Edit: Actually, what was black stayed black, but I solved the problem by replacing all black with R1 G1 B1.
 
Last edited by a moderator:

samspade

Member
I replaced 128 with 128.0 and it works.
Sounds like you solved this, but another easy way to 'highlight' a sprite, is to simply draw it over itself at reduced alpha with additive blendmode. Probably slower than a shader though. Example:

Code:
draw_self();
if (selected) {
    gpu_set_blendmode(bm_add);
    draw_sprite_ext(sprite_index, image_index, x, y, image_xscale, image_yscale, image_angle, image_blend, image_alpha * 0.5);
    gpu_set_blendmode(bm_normal);
}
 
Top