Unity shaders - blend edges of tile textures stored in an atlas

by user92748   Last Updated January 24, 2018 14:13 PM

I'm creating a tile based game. The tiles can have different textures. All the textures are loaded at startup and dynamically packed in a texture atlas (this is done to make modding easier). Each tile stores the UVs of it's texture.

Here is an example from the game, in which the terrain is mostly made up of "grass" tiles, and there are also "stone" and "dirt" tiles in the center:

tiles example

As you can see, the edges between different tile types are "hard". I want to make them "soft", so the tiles would blend into each other.

It was suggested to me to create special "edge tile" textures and use them for the edge tiles, but I would rather avoid that because it would require creating an edge tile texture for every 2 possible tile combinations (perhaps more for corners), and would massively bloat up the texture atlas.

Therefore I thought this should be done using a shader. I'm not too familiar with shaders though. I've created simple shaders that make grass sway and such, but I have no idea how to approach this problem. For starters, I'm not even sure how to "tell" the shader what are the UVs in the surrounding tiles (I need the UVs to sample the texture from the Atlas)?

Any help would be appreciated.

Thank you.



Related Questions



Seamless tiling with TexturePacker and Marmalade/IwGX

Updated September 12, 2017 13:13 PM

Multiple textures/texture atlas

Updated February 11, 2017 14:05 PM