Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

TileMaps: Applying Texture Over Multiple Tiles

Discussion in '2D' started by Lapuka, Nov 2, 2020.

  1. Lapuka

    Lapuka

    Joined:
    Jan 19, 2015
    Posts:
    4
    I want to apply a large texture over multiple tiles like this:
    (I'm using unity's Grid/TileMap system for displaying tiles)
    Basically I want to place some tiles who would have parts of one larger texture that is tilable itself, but I don't want it to repeat every tile .. aiming for something like repeating every 10 tiles or so. I think I'm overlooking something rather simple here, any help would be very useful practical or just explaining idea behind mapping texture onto tiles like that, thank you!
     
  2. raarc

    raarc

    Joined:
    Jun 15, 2020
    Posts:
    535
    unclear what you want to do as a whole...

    but looking at your bottom picture you slice the texture into the size of various tiles and place the tiles in the correct order based on x,y coordinates
     
  3. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,319
    Your problem is very similar to the one here: https://forum.unity.com/threads/apply-shader-to-tilemap-as-a-whole.963252/#post-6286052

    Solution should be the same. You can use a Position node to get UVs from a seamless texture. The tilemap's tile supplies a sprite that is the same as the shape of an individual tile (square). What's on that sprite doesn't matter: you're only using that sprite as the shape to apply. The seamless texture supplies what's drawn in that shape.

    Note: you would need a different tilemap per seamless texture because you can only have 1 material per tilemap.
     
  4. Lapuka

    Lapuka

    Joined:
    Jan 19, 2015
    Posts:
    4
    well having different tilemap per material just means I would have different tilemap per type of tile .. like 1 material for dirt tiles, one for stone etc which is perfectly fine, thank you for your answer it gives me something to try :)
     
  5. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,319
    If you can differentiate your tiles by coloring a grayscale image, that may allow you to have multiple kinds of terrain for one tilemap. This would require a grayscale seamless texture, then you can use tilemap.SetColor(cell, someColor) to color it per-tile to differentiate, for example, two varieties of stone. This obviously wouldn't work for grass vs stone though.