Hello, I’m messing with the newly released Tilemap in 2017.2. I want to add additional per-tile data that can be read through a custom shader. From what I can see by default the Tilemap uses the default sprite shader. It’s also possible to set per-tile-instance colors via Tilemap.SetColor, which tells me there must be some kind of instancing going on under the hood.
Is there some way I can set custom shader properties for an individual tile in the tilemap through the TilemapRenderer? If there is no instancing going on is it possible to set data directly to the underlying mesh?
I’ve tried using the “traditional” gpu instancing methods that you would use with DrawMeshInstanced and DrawMeshInstancedIndirect - retrieving the property block from the tile map renderer, pushing const buffer and compute buffer arrays to it and setting it back to the tile map renderer but it didn’t seem do anything.
To give a more specific example of what I want - I want to be able to set secondary color data per tile that I can read through the shader. Maybe there’s a more obvious way I can do this that I’m not thinking of?
Unfortunately that’s only useful for the scripting side of things. As I said in my post I need to add per-instance data that can be read from the shader, whether through a shader property, through the underlying mesh, or some means I’m unaware of.
For the benefit of future googlers: On further testing it looks like there isn’t any instancing going on. I can only guess but it seems like any color change you see via Tilemap.SetColor are embedded into the underlying mesh, and are read in the shader through the vertex colors.
It would be nice to have access to the underlying mesh at least, but after experiencing Unity’s attempt to provide “convenient” access to their uGUI meshes with their so called “Vertex Helper” maybe it’s best left alone.