Search Unity

Dynamic texture below meshes

Discussion in 'Editor & General Support' started by Fjonan, Jun 16, 2013.

  1. Fjonan

    Fjonan

    Joined:
    Jun 16, 2013
    Posts:
    5
    Hello, I am pretty new to Unity and I am currently developing a strategic game. Now if you take a look at this mockup you see that our artist put these lines below the hexagon-island.

    I am looking for a way to create those, dynamically of course since the islands can have any shape you can build with hexagons.

    I was unsuccessful so far to even just find something similar. I tried applying a plane-mesh to every tile that overlay each other but I think that is a very messy approach and in addition does not allow me the black outline.

    Another idea was to figure out a way to detect the island as one piece and apply some kind of "outline" to it that looks like this.

    Maybe someone here knows a better way or even something that has already been done. Much appreciated!
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Are you referring to the grid, or something else?

    --Eric
     
  3. Gibbonator

    Gibbonator

    Joined:
    Jul 27, 2012
    Posts:
    204
    One way to do it would be to create a 2D signed distance function based on the centre points of the hexes (possibly with a bit of randomness thrown in). You can then create outlines at different distances in the SDF by using marching squares or triangles to create a line list. You could then smooth the line list by using the line end points as control points for a Catmull-Rom spline. None of this is Unity specific but you'll probably need to do a fair bit of research if you're not familiar with these techniques.

    http://en.wikipedia.org/wiki/Marching_squares
    http://en.wikipedia.org/wiki/Cubic_Hermite_spline
    http://en.wikipedia.org/wiki/Signed_distance_function

    Edit: If you wanted to do this as a shader effect you could probably render the SDF into a render texture and use an edge detection shader for the outlines.

    Edit 2: In fact you wouldn't even need to use a fancy edge detection shader. You could just map a 1D ramp texture directly onto the SDF. That would give you as many outlines of whatever thicknesses you needed.
     
    Last edited: Jun 16, 2013
  4. Fjonan

    Fjonan

    Joined:
    Jun 16, 2013
    Posts:
    5
    @ Eric: I am referring to the roundish line around the island (3 steps even) and how I would create those.

    @ Gibbonator: Wow, that sounds complicated but looks like a possible solution. I will dig into that!

    I was also thinking maybe I can use the a terrain for that, since it is capable of multiple textures?
     
  5. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,448
    You could try that blurring idea also.

    - take image of the tilemap
    - blur it enough,
    - then use that as a texture (with transparency) on a plane
    - add texturing/shader..
    - do some "cutoff" checking to find/draw the outline..

    not sure if it would work well though : )

    (screenshot from photoshop)
     

    Attached Files: