Apply shadow layer to spritesheet?

I’m building up my spritesheet from multiple layers, and everything is working great to this point. For example,
The base layer has the main image, including jerseys and pants
I let them choose which shoulder layer to apply (including “none”)
Same with choosing a pants striped layer

To top it off, I also let them swap colors on each layer (set the jersey to a color, etc), and this is all good.

Oh, and important - I’m doing this pixel by pixel. When adding a shoulders layer, for example, if the shoulder layer has a non-transparent pixel, it replaces what’s in the base layer.

However, the artist who gave me the master Photoshop file also included a nice “shadow” layer which is various shades of gray that I can apply to add more of a 3D look. In photoshop, I simply add the layer and set its opacity. I have something that sort of works, but I don’t really know the math involved.

I want to dynamically use this final spritesheet that I’m building, for my sprites, and also save it to disk (which I’m now doing), so I’d rather not have to have two separate sheets (one for the sprite and one for the overlay) unless that’s the only way to do it.

Is this a multiplication? Right now, I’m trying to do a subtraction.

Have three layers of textures to compose a player(player can be inherited from Node and should have three sprite components/objects namingly

  1. base Layer(Jersey & pants)
  2. The shadow layer
  3. shoulder layer should be on top of any other layer which needs to cast a shadow on any base object.

Now you can have all the sprites in a single spritesheet or can have three spritesheets composing each layer sprites, Above layering structure gives you freedom to hot swipe textures at will and manage each layer/sprite opacity at run time and independently, no need to worry about blending mathmatics.

Thanks, I’m basically doing that, and have the math working for the multiple layers (base, shoulders, pants stripes), but unsure on how to apply the shadow mathematically. I know how to do it as a separate layer, but I’m hoping to not have to load two images per sprite - that would work, though, so I may do that.

You don’t need to, the renderer will take care of it itself as default blend function of sprites will be called while doing depth testing(Test it by putting two semitransparent different colored sprites on top of each other).

One sprite can support one Texture2D instance there is no way it can support two different texture at the same time(actually it can hackish stuff follows…
if you write a shader(or run z-depth test on both the textures) to take two textures and blend them using default blend params and save the result in a cocos::Image instance and then initiate a fresh Texture2D instance with this image data and then use this new texture in your sprite instance but that seems to be a overkill isn’t it? )