• 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!

How do I turn image_blend off ?

L

lemonhead

Guest
Newbie question:

Can any of you knowledgeable GMS2 users tell me how I can revert and object's sprite back to it's original palette after utilizing an image blend? I am thinking there must be a simple command to toggle image_blend off that am missing, but just not finding it in the docs. Thanks
 
L

lemonhead

Guest
@nacho_chicken thanks. So if I wanted to flash my oPlayer white when he is making collisions with enemies would I just need to have a white version of the sprite image and swap it briefly during contact with the collision object? Is there no way I can achieve this white flash of the player effect with image_blend?
 

Mike

nobody important
GMC Elder
No, you'd need a shader to "saturate" a sprite with white (using a simple "mix" lerping function). Chances are there is a shader on the marketplace already for this.
 
L

lemonhead

Guest
No, you'd need a shader to "saturate" a sprite with white (using a simple "mix" lerping function). Chances are there is a shader on the marketplace already for this.
Mike, Thanks! That didn't even cross my mind! Brilliant idea :and a great learning opportunity for me. Thanks again.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Actually... You DON'T need a shader at all! There is a very quick and easy hack that will do this using gpu_set_fog(). Simply set the fog when you want it to flash white and disable it again when you don't...
Code:
if flash
{
gpu_set_fog(true, c_white, 0, 1);
draw_self();
gpu_set_fog(false, c_black, 0, 1);
}
Just use that in your timer code and you don't need a shader and the effect is the exact same. ;)
 

GMWolf

aka fel666
Pretty sure gpu_set_fog is not per draw call and breaks the batch just as well.
A shader is probably preferable IMO and a great learning opportunity.
 

Mike

nobody important
GMC Elder
Also wondering if that fog thing still works cross platform, as Android and HTML5 have engine level shaders to render sprites, and fog is probably not part of that.... You'd have to try it.

Yes, fog - or any render state, would break the batch. It's also worth saying a shader would give you far more control, letting you "flash" things using a curve if you wanted, while fog is a little hit or miss to get the effect you're after - unless it's literally on/off.

I wonder if you could do a negative colour blend on a black sprite......... Mmmm....
 

GMWolf

aka fel666
Also wondering if that fog thing still works cross platform, as Android and HTML5 have engine level shaders to render sprites, and fog is probably not part of that.... You'd have to try it.

Yes, fog - or any render state, would break the batch. It's also worth saying a shader would give you far more control, letting you "flash" things using a curve if you wanted, while fog is a little hit or miss to get the effect you're after - unless it's literally on/off.

I wonder if you could do a negative colour blend on a black sprite......... Mmmm....
Pretty sure the colour blend comes in as a vertex attribute, so I don't think you could have it be negative.
Really these days it would be better to put all of these in a buffer and have use a draw index to index into the buffer.
Smaller vertices, less bandwidth, more control, fewer batch breaks, more performance.
Supported by all hardware from the past 10+ years.
 

Mike

nobody important
GMC Elder
It does, but there is a 1-colour screen blend mode, which "should" negate it.

basically, set the vertex colours to 0 - making the sprite black, then make the blend mode 1-colour (or something), then perhaps you could use this to invert the colour. Not sure... just thinking aloud....
 

GMWolf

aka fel666
It does, but there is a 1-colour screen blend mode, which "should" negate it.

basically, set the vertex colours to 0 - making the sprite black, then make the blend mode 1-colour (or something), then perhaps you could use this to invert the colour. Not sure... just thinking aloud....
Oh I see what you mean yeah. Blend modes could do it. But again, breaks the batch.
 

Yal

šŸ§ *penguin noises*
GMC Elder
while fog is a little hit or miss to get the effect you're after - unless it's literally on/off.
Drawing with image_alpha lets you put a partially-transparent, fully fog-faded sprite on top of a normal sprite (or vice versa) so you can solve partial fade that way... I've been doing it for years. Shaders definitely give more control, though, even if they're tougher to get into.
 
L

lemonhead

Guest
Thanks to everyone for your friendly and knowledgable input. I am beginning to really love this forum. I think I need to learn the basics before I dig too deep into topics like shaders. I have read the Xor's tutorial on shaders and watched a few videos. Most of it is honestly above my head. I have decided to stick with a basic solution for now and focus on the fundamentals. At least this way I will have a higher chance of continued progress. Again thanks to all of you!!
 
Top