Adding custom Material to TileMap, seems to break it?

Hey Guys, quick question for you all!

I was playing around with 2D tilemaps, and created 2 different tilemaps, one for walls, and one for plaforms.
I wanted the platforms one to reflect lights in the scene, so I created a new Material, added the Normals, and when I applied the material to the Tilemap, the tilemap seems to hide behind the “walls” tilemap.

If i disable the renderer in the walls tilemap, the platform tilemaps can be seen.

If I use any other kind of Material on the “Walls” tilemap, both tilemaps are rendered, but if one tilemap uses a random material, and another one uses the “Default-Sprites” Material (Or the Sprites shaders), then the tilemap using the random material won’t show up.

Do you guys have any idea why this might be happening?. I player around with the sorting layers, but couldn’t manage any progress

Couple of Images:

Both Tilesets with the Default Material

Adding the “Platform” material to the “Platforms” Tileset

Disabled the renderer on the “Walls” Tileset

Layers:

5948762--637172--upload_2020-6-7_0-38-3.png

Could you share what your custom shader/material looks like? Thanks!

Sure!, sorry about the late response.

5980352--642356--upload_2020-6-14_18-7-50.png

Thanks for the screenshot!

You likely have an issue with sorting which you can find out more from Unity - Manual: 2D Sorting. The default Sprite shader belongs to the Transparent Queue, while this belongs to the Opaque queue (as the rendering mode is Opaque). This means that the Tilemap with this material will be draw first, while the other Tilemap with the default Sprite shader will be drawn over the first Tilemap. Depending on how you want your Tilemaps to be ordered for rendering, this can be wrong.

You can use the Frame Debugger to see how the Tilemaps are drawn in the GameView. Hope this helps!

1 Like

I checked the Frame Debugger, and you were righ!, The Transparent Queue was drawing over the Opaque queue. I changed my material so that it would be Transparent too, which did solve the issue, but I felt that wasn’t the correct solution. I played around some with the Ordering Layers, but no dice.

I ended up solving this issue by moving my Tilemaps in the Z axis. Now, my “Walls” tilemap has position (0,0,1) while my “Patforms” tilemap is in postiion (0,0,0), and that makes it render properly. Thanks for the help!