GML Paletted Sprite Shadows

S

Sir_Rysik

Guest
Sprite-0001.png
Hey everyone,

I'm running into a problem in my game's design. The game itself is in a 2.5D perspective (Similar to Pokémon.) I wanted shadows to be under certain sprites but instead of doing do the cheap method of having a black shadow at 50% opacity I want the shadows to be directly influenced by my color palette. If you look at the example picture you can see that when the shadow is on top of something each color is brought down by one color in the palette (Making it darker.)

How would achieving this effect be possible?

I've never used shaders before so if a solution is possible without using them then I would be glad to try it out. Otherwise I wouldn't mind trying to figure out how to use them.

I had the idea of having all of the shadows in each sprite be a certain shade of Purple at 100/255 opacity. Then I would run some sort of shader that takes the (transparent purple color + whatever color is under it = New shadow color)

Thanks in advance!
 

Corey

Member
Hi. There are three components to think about with colors in GMS: Hue, Saturation, and Value (Luminosity). Each of these define a color and transparency that GMS reads while the game is running. For instance, you can make your own color by using the GML make_colour_hsv(hue, sat, val) and set it to where if your player that has the purple shadow to change it's shadow color by using the new color that you created. It's also possible to change these values while in game. Keep in mind that the shadow is imaginary and should be created as an object with a sprite to follow the player if the color is going to change, or it'll change the color of both the player and the shadow. The dimensions of the shadow play a part here too. GMS can do position checking to find out where the player is, and what it's standing on.

For starters, I suggest you take a look at Colors in the GMS manual and do some testing of your own to see what you can come up.
 
Top