How can I use a render script to make one Tilemap layer get its alpha from another layer?

Hi there! :blush:

Is it possible to set up a Tilemap layer so that it uses the alpha (transparency) from another layer—either above or below it—at the same tile position, by editing the render_script? If so, how would I go about doing that?

Here’s what I’m working with:
I’ve combined three textures—two RGB and one greyscale—into a single rgba image for the tilesource. I have three Tilemap layers: Top, Middle, and Bottom. The Middle layer contains greyscale tiles that I want to use as alpha masks. My goal is for the Top layer to get its alpha values from the Middle layer at the same tile positions.

I’d really appreciate any help or guidance you can give. Thanks a lot!

The tilemap layers are drawn one by one z-sorted with other components such as sprites. The tilemaps are drawn using the tilemap.material.

I think your best bet is to split your tilemap layers into multiple tilemaps (top.tilemap, middle.tilemap and bottom.tilemap), and draw the middle.tilemap (the mask) to a render target. Next you use this render target as an input when you draw top.tilemap. You need a custom render script and custom versions of your tilemap materials.

3 Likes