Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Mask a mesh with another

Discussion in 'General Graphics' started by Fuzzypup, Oct 10, 2018.

  1. Fuzzypup

    Fuzzypup

    Joined:
    Aug 13, 2013
    Posts:
    190
    I have a 2d wargame I am constructing using a tile based system on a hex grid.
    Each hex grid is given UV coordinates of which part of its image to show.

    The picture is a side view of the game paused in the editor in 3d showing at an angle the 3 mesh layers. Terrain is on top of land which is on top of ocean.

    In the example I am showing 3 mesh layers

    Bottom Mesh Z = 0 (farthest from camera) - Ocean layer - this is only ocean 1 single tile mesh
    Middle Mesh Z = -1 - Land layer this shows just the land itself. Where there is no land it is transparent with nothing. This is on top of the ocean layer so when viewed you see land on top of ocean.
    Top Mesh Z = -2 - Terrain layer - And this is where I want to mask against the Land layer.

    Instead of constructing this massive image of 300 different ways to show terrain to match up with the land layer I would like to use the land layer's NOTHING part to mask part of the terrain layer. So I can put a full forest hex in the same location of the land hex and it only shows forest where there is land and masks the rest of the terrain.

    Is this even possible? I've been looking for an answer for 2 hours and can't find one.
     

    Attached Files:

    • help.png
      help.png
      File size:
      276.4 KB
      Views:
      881
  2. Fuzzypup

    Fuzzypup

    Joined:
    Aug 13, 2013
    Posts:
    190
    Here is the 2d view of what I want done.
     

    Attached Files:

  3. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    703
  4. Fuzzypup

    Fuzzypup

    Joined:
    Aug 13, 2013
    Posts:
    190
    I have very little experience with shaders as I only work with 2d games. I will have to research how to use this. But I only need an alpha mask. The tile mesh is land and nothing where there is no land. The terrain can use the full tile. So I want to mask the terrain to the nothing on the tile mesh.

    I can do that with this?

    The tile and terrain are 2 different meshes

    There are 7 stacked meshes to form the map.
     
    Last edited: Oct 17, 2018