Search Unity

[Solved] Basemap showing instead of emission map on double-sided procedurally generated mesh

Discussion in 'General Graphics' started by DroidifyDevs, Mar 25, 2020.

  1. DroidifyDevs

    DroidifyDevs

    Joined:
    Jun 24, 2015
    Posts:
    1,724
    I'm working on a procedural road generation system and currently I'm dealing with a very weird bug:



    And here is the shader:
    upload_2020-3-25_12-6-55.png

    What I do know is causing the bug to appear is my code that doubles-sides the triangles in the mesh. What I do is simply make a triangle going through the vertices clockwise, and then make one going counter-clockwise. But this results in this bug, most apparent when changing the points on the X axis.

    I need the mesh to be double-sided so that I make make loops and stuff in the road without backface culling being an issue. Simply doing that in the standard shader makes the lighting weird, so that's why I'm doubling the triangles in my code.

    What could potentially be causing the basemap to appear on certain triangles instead of the emission?
     
    Last edited: Mar 25, 2020
  2. DroidifyDevs

    DroidifyDevs

    Joined:
    Jun 24, 2015
    Posts:
    1,724
    I've been able to fix this by simply not calling mesh.RecalculateNormals() in my code and it looks like what I'd expect. While I'm not sure what exactly is wrong with it, it looks like I will have to define my own normals for my script.