• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker 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.
 
J

Jordan Robinson

Guest
Also if you are adding 128 to a floating point value, you would need to add it as 128.0 otherwise it is an integer
 
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