Search Unity

custom mesh normal calculation

Discussion in 'Scripting' started by gaiastellar, Apr 16, 2019.

  1. gaiastellar

    gaiastellar

    Joined:
    Nov 8, 2013
    Posts:
    57
    hi all,

    ive got a mesh which is a basic flat plane of 64 x 64 vertices, which i apply noise to , to get a terrain tile. recalculate normals works fine, but for reasons to long to explain here, i want the normals calculation to completely ignore the out row of vertices and triangles and behaves as if it were perfoming the normals calculation on the inner 62 x 62 grid only.

    can anyone think of an easy way this might be done without having to write a complete custom normals calculation script from scratch, which would be a whole new kettle of fish for me?

    i was wondering along the lines of - if the normals and triangles are stored in there own arrays associated with the mesh, perhaps the relavant vertices and triangles could be omitted from these arrays?

    any thoughts please?

    many thanks

    paul/ uk
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,742
    Normals are stored in their own array in the Mesh. You can always go pull the normals back out of the Mesh AFTER the .RecalculateNormals() call and do whatever you want with only the ones around the edges, leaving the interior 62x62 unmodified, then put them back into the .normals property.

    You would just need to know in advance which vertices were those outer ones, perhaps by storing their indices when you put them in the vertex array in the first place.
     
    LiterallyJeff likes this.