Search Unity

How to avoid stretched normals on modifying mesh?

Discussion in 'General Graphics' started by TheGameNewBie, Nov 29, 2020.

  1. TheGameNewBie

    TheGameNewBie

    Joined:
    Jul 27, 2017
    Posts:
    92
    I'm trying to create a terrain editor in-game and I'm using procedurally generated meshes as the terrain.
    For 'editing' the terrain, I'm doing simple modifications to the mesh such as Pushing the vertices down/up.
    But changing the vertices results in an artifact like this:
    NormalStretch.PNG
    As you can see, there seems to be stretching of some sorts.
    The mesh does not have any texture or normal map applied to it. I'm using a simple shader made in Shader Graph which uses vertex colors and the normals of the mesh are set through code using
    mesh.normals

    It seems like a UV problem, as I push the vertices of a face down the surrounding faces get stretched.
    Stretch2.PNG
    But I'm not using UVs at all.I'm using Vertex Colors and Vertex Normals.
    What can I do to avoid stretching like this?
     
  2. joshuacwilde

    joshuacwilde

    Joined:
    Feb 4, 2018
    Posts:
    731
    That's a shadow map artifact. Turn off shadows on your light and you will see