Some kind of stencil mask inside of widgets?

Hi,

I am an artist and currently working on a pixel art game and I want to create a shadow for widgets. These shadows should have a specific color out of my color palette depending on which color they are cast on.

Here is an example image of what the shadows should look like:

It’s basically one shade to the left of my color palette from the color the shadow is casted on.

I’m using one master 3D widget that contains all of my widgets. I got a retainer box material that creates the shadows for the objects with a specific pixel offset (but I could also just use a specific color that I don’t use in my game and use that as a mask for my shadow).

I thought that I would need some kind of stencil mask and a LUT function to convert my colors. I tried several things with retainer boxes, but couldn’t get it to work. My problem is that I need an extra pass for the shadows, something like scene color and a stencil mask.

Has anyone a suggestion how to create this effect?