2D Toolkit Forum

2D Toolkit => Support => Topic started by: prokopst on October 07, 2014, 08:37:19 pm

Title: Problem with blending of multiple images (Tilemap with two layers and Sprite)
Post by: prokopst on October 07, 2014, 08:37:19 pm
As unikronsoftware suggested in "Tilemap draw order by y-axis (http://2dtoolkit.com/forum/index.php/topic,4500.0.html)" I "created" my own shader (it is basically "copy & paste and adapt" job with default shader to use alpha testing). Now I have different issue, images are not blended correctly. Ground part (z=0 + y offset) is blended into box with goods (z=-1 + y offset[1]) and then this one is blended with character (z=-1 + y offset[2]). I expect this is feature of pivot and shader thingy sorting in unity.

GIF for better illustration, notice character's legs during movement in north west (top left) direction:
(http://yde4jq.bl3301.livefilestore.com/y2pXUzlYPQxvUmG7FXf9Mc3VMxow4gJi7NSf11RSjsJUAIXK_qEbA8mCES_Oi8uscwfpgn17K1jyCv6_7ss1JONiRZJkUjy4frAhMwUUZqlG84/multiple_sprites_transparency_problem.gif?psid=1&authkey=ABQVzCnHqtTJg_w)
(link to the image (https://onedrive.live.com/redir?resid=7D9A2DDCD2458629!7147&authkey=!AIwPP3pJD5Z0Pk4&v=3&ithint=photo%2cgif))

I'll try to limit partition size to 1 as described in the topic mentioned above (BTW actually the lowest possible value is 4 even if I specify 1, so I need to remove this limitation), but I guess it will hurt performance...

Does anyone have any idea to solve this issue without partitioning by y coordinate (i.e. by rows)?

[1] z offset is set to 1 for this layer in Tilemap settings, so I assume it's z=-1
[2] z coordinate is changing for character with some script component:
Code: [Select]
z = 0.01 * y - 1;
Title: Re: Problem with blending of multiple images (Tilemap with two layers and Sprite)
Post by: prokopst on October 08, 2014, 01:49:35 pm
I found quite easily how to remove partitioning limitation in tk2dTileMapEditor.cs:620
Code: (tk2dTileMapEditor.cs:620) [Select]
partitionSizeY = Mathf.Clamp(EditorGUILayout.IntField("PartitionSizeY", partitionSizeY), 4, 32);
and as expected the problem is gone with PartitionSizeY=1.
Title: Re: Problem with blending of multiple images (Tilemap with two layers and Sprite)
Post by: unikronsoftware on October 08, 2014, 10:11:59 pm
Partition size = 1 will work but it is inefficient for large tilemaps. By all means use it if it works for you :)