controling the colours of sprites that overlay one another

i think this might be possible to do the following with surfaces but im sofar struggling to figure out where to begin reading how to, im not asking anyone to do this for me, i just want to learn if its possible in GMS.

i have two different circles, red and blue. When red and blue overlap i want to change their colours, apply textures, or change the visibility, ideally all at the same time.

visibly to the player, the red and blue become the yellow and green on the sprite, i want the red circle to not be visible except when it intersects (green), as for the blue circle i want it to just go about its normal business as the yellow circle, either having a texture emerge when intersect or a solid one.

can anyone please point me in the way to begin learning how to change colours or add overlays onto other sprites that are only visible within the boundries of a second sprite?

thank you
 

Attachments

samspade

Member
You'd have to use shaders or blend modes. If you want to apply textures or change colors to unrelated ones, that should probably be a shader. If you want to affect visibility only or change colors to a related one (e.g. derive a new color from the existing color) you could use blend modes.

Shaders are a complicated topic, and without knowing exactly what you want I don't know enough to tell you were to start, but I don't think you can do better in GM than watching these:

https://www.youtube.com/channel/UC7fkptPD1FHQyDc9Fnm9S_A

Blendmodes are straight forward once you understand them, but conceptually intuitive. I think this is the best GM primer on it: https://www.gmlscripts.com/forums/viewtopic.php?id=1644

Once you understand them a little more, reading about them online in general is a good next step. Starting with non-GM is also possible, but I found it easier to go the other way.
 
@samspade

basicly imagine the lens of truth from ocarina of time, something is invisible unless it is seen within the lens, and then only the part inside the lens is visible, not the entire image, so the lens is one colour while the object within will be shown as another.

so you have one invisible object that only becomes visible when it intersects with another and the other will change colour only at the point of intersection, while the non intersected part will stay a different colour.

could this be accompished with blending and, if so, how would one identify all pixels that are intersecting so only those would be coloured in on a given object?

i think i remember a tutorial, i want to say on the gms blog, involving adding a blood splatter effect to a wounded npc, but it only appear on their body, so i am all but sure its possible but i dont have a clue where to look.

thank you.
 

NightFrost

Member
Yes blend modes could do that. You prepare a surface and draw the lens onto it. Then you set a blend mode for the invisible object draw, so that only those pixels where alpha is not zero receive the draw. I forget which combination of blend keywords did this though.
 
Top