Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Draw grid on Terrain

Discussion in 'Scripting' started by mrCharli3, Oct 12, 2019.

  1. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    981
    I have been trying for days to find any suitable docs that could help me draw a simple grid (1x1) on terrain, mesh, or a layer.

    How can I achieve this in 3d? My own scenario is that I am making a city builder, my base is terrain, and I would like to draw a simple 1x1 grid with white lines on top of the terrain.

    If no answer, any advice or links to docs would help!
     
  2. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    You could maybe try some image effect, similar to what Keijiro etc. have shown:

    https://github.com/keijiro/DepthInverseProjection

    Construct code in shader that renders a procedural grid, then reconstruct the world space position from depth like shown in Keijiro's effect and draw the grid on the terrain. I think it should work. Although I'm not sure how you would mask certain things to not have the grid and so on. Requires some thought.
     
  3. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,476
  4. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    981