Search Unity

Find vertices and triangles on the surface of a mesh

Discussion in 'General Graphics' started by Erlend1, Jan 11, 2020.

  1. Erlend1

    Erlend1

    Joined:
    Dec 18, 2019
    Posts:
    22
    Hello, I'd like to know which vertices and triangles are visible on the surface/outside of a mesh. This can easily be seen when using depthculling in a shader, such as in the picture below:

    mesh1-DepthCulling-.jpg

    In a single low-poly model, most if not all vertices are used for surfacing faces, but when meshes are combined, excessive vertices and triangles appear within the new mesh:

    mesh2-noDepthCulling-.jpg

    Many vertices and triangles are essentially inside the mesh and invisible, and should be safe to remove. Is there a feasible way to find these in unity?

    Depthculling of the merged meshes: (How does the shader determine which vertices & triangles to be culled and which ones to show?)
    mesh2-DepthCulling-.jpg

    1. I tried to use bounds, but as I understand it it's basically a large box encompassing the whole object, which don't really refer to particular vertices.
    2. I read about raycasting, but don't they require bounds as well?
    3. As for depthculling in shaders, is it possible to do such a check in the editor and not in a shader?
    4. I read about getting positions via camera (more specifically camera.WorldToViewportPoint) and check whether certain values are over 0, but I don't see how it can work.

    I'm quite stuck at the moment, so any new ideas and suggestions would be highly appreciated!
     
    Last edited: Jan 12, 2020
  2. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    2,076
    @Erlend1
    Are you trying to combine the two mushrooms, like in the second pic, but without the unwanted vertices and faces in unity? Or are you trying to combine them, in a 3d modeling software?

    If so:
    One good thing to do, is combine both mushrooms in a 3d modeling software, like 3ds max or blender etc. Then remove unwanted faces and vertices, weld vertices together. Then, import the object into Unity.

    Or, cut out and remove faces from both of the mushrooms, and then weld the vertices from both mushrooms together, to make them into a single object. Then import it into Unity.

    Or, in 3ds max or blender, just create a 3d model, that looks like two mushrooms combined. Then import the object into unity.
     
    Last edited: Jan 12, 2020
  3. Erlend1

    Erlend1

    Joined:
    Dec 18, 2019
    Posts:
    22
    Oh, sorry, I forgot to clarify that I try to combine meshes in unity! Not necessarily mushrooms (just using one for testing), but for example for generating randomized terrain.