Hello Guest

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - andy

Pages: [1]
1
Support / Re: Tilemap draw order by y-axis
« on: February 20, 2013, 07:43:40 am »
Using an alpha test shader fixed the transparency sorting problem. Thanks :)
Also can I add a request for an auto tile system, something similar to the one in TiDE or Rotorz, think it'll be a big selling point for the tilemap editor.

2
Support / Re: Tilemap draw order by y-axis
« on: February 19, 2013, 01:35:00 pm »
Sorry I think I asked the question incorrectly, the top-left sort order is fine.

Here's the scenario (top-down view, x,y co-ordinate system is top-left) :
1) Fence tile is at 0,1 on tilemap and player sprite (not a tile on the tile map) is at the equivalent location of 0,0.5 on the tile map.   The player sprite is drawn behind the fence.
2) Fence is at tile 0,1 and player is at the equivalent location of  0,1.5 on the tile map. The  player is drawn in front of the fence.

If I weren't doing this through unity I'd sort all tiles and sprites by their y co-ordinate and layer, and then render them in that order.

The only way I could think about re-creating this process using the tilemap was by having each row of tiles in the tilemap have a specific z value, and this z value increases
as you go down the y-axis. The player sprite would have have it's z-value changed depending upon it's y-axis location.
However looks like the tile map only increments the z value of the chunks created( somewhere around line 306 of TileMapBuilderUtil). 

So...I tried adding calculated z values for tile vertices created in RenderMeshBuilder.BuildForChunk  i.e. float z = -((layer.numRows * layer.divY - 1) - (baseY + y)) * someZDepthFactor;
and got the ordering working somewhat. However there was some inconsistency in draw order between transparent objects at the same z value (e.g. player sprite and
fence tile). A search on the interwebs revealed that objects with transparency shaders sort by object pivots, and multiple transparent objects that have been
meshed together and have one pivot don't sort well. I changed the materials shaders to use SolidVertexColor and it did seem to fix the problem...albeit with no transparency.

I don't know if that made any sense, but is there an easier solution you can think of?


 

3
Support / Tilemap draw order by y-axis
« on: February 18, 2013, 03:34:33 pm »
Hi,

I'm writing a tiled-based top down game and I need to fix up the draw order of the tiles in the tilemap such that tiles with higher y values, up the top of the screen, are drawn first, effectively
z-ordering by the y-axis.  Would there be any easy way to do this with the Tilemap?
 
I was going to hack around in the code and set z values to the sprites based on y tile-position of the tile but then realised the sprites are grouped into chunks.

Pages: [1]