Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Layer Masking
#4
(03-09-2025, 08:57 AM)megamarc Wrote: In your case, what you want is:

1. A regular layer with the checkerboard
2. Regular sprites for the piece shadows
3. A high priority layer with the the black, outside part of the checkerboard that will cover only the shadows that lie outside of the board
4. High priority sprites for the chess pieces, that won't be covered by the outside black background.

Check the funcions TLN_SetLayerPriority and TLN_EnableSpriteFlag with FLAG_PRIORITY

With this approach you will have the shadows always below the chess pieces and hidden outside of the board, but the pieces themselves will stand out outside of the board.

Your suggestion does sound like it would work with the current setup. However, the black background is only temporary. Once additional background layers are added, wouldn’t those new background layers also need a cutout in the shape of the checkered board? If that’s the case, it sounds like another use case for layer masking, where the background layers could use the checkered board as a mask or cutout.

There’s also another issue: the checkered board pattern is not a static image; it’s part of a larger spritesheet designed to create the illusion of 3D rotations:
[Image: 13-ri1s-TBl4aIL-9k9LF6OURAiYJAGSE=w1000?authuser=0]

I had another solution in mind if layer masks were not available. Let me know if this makes sense: Since all of the shadows are relatively simple ellipse shapes, I was thinking of using math to manually draw them onto a bitmap and then test against the checkered board to determine whether a pixel should be drawn or not.

This approach may start to fall apart for different visual effects I’m considering, but it might be good enough for now.


(03-09-2025, 09:59 AM)System64 Wrote: Oh you made this with Tilengine? This is very impressive!

Thank you!
Reply


Messages In This Thread
Layer Masking - by sputnikus - 03-09-2025, 04:59 AM
RE: Layer Masking - by megamarc - 03-09-2025, 08:57 AM
RE: Layer Masking - by System64 - 03-09-2025, 09:59 AM
RE: Layer Masking - by sputnikus - 03-09-2025, 11:21 PM
RE: Layer Masking - by System64 - 03-10-2025, 02:52 AM
RE: Layer Masking - by megamarc - 03-11-2025, 05:29 AM
RE: Layer Masking - by sputnikus - 03-11-2025, 07:50 AM
RE: Layer Masking - by megamarc - 03-13-2025, 04:53 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)