Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Procedural mesh materials problem.

Discussion in 'General Graphics' started by sgower, Aug 27, 2019.

  1. sgower

    sgower

    Joined:
    Mar 9, 2015
    Posts:
    316
    Hi, I'm create an extrusion brush that will let users sculpt by extruding a shape (square, hexagon etc).
    So I'm generating the mesh procedurally. When I apply an image, some materials look fine, but some seem to be applied in an unrealistic manner. Below shows an extruded square, and the path bends. Along the bend portion, the metallic material looks pretty bad, with the reflections. Does anyone have any idea about how to make this look better?


    upload_2019-8-26_20-4-30.png

    Here's a wood material that looks a lot better.
    upload_2019-8-26_20-9-17.png
     
  2. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,613
    How are generating the UVs?
     
  3. sgower

    sgower

    Joined:
    Mar 9, 2015
    Posts:
    316
    hi kdgalla, thanks. I'm was using some code I got from online to generate the UVs, so I don't remember the details. But I played with this some more, and it looks like in between each of the sections where the texture gets out of alignment, I was generating a very small, unnecessary, additional segment in the extrusion. I'm not sure why this would screw up the material application, but when I removed these extra segments, the mesh is looking a lot better.

    Now I'm trying to figure out how to get the meshes to be faceted, and not smoothed automatically. I believe the only way to do this is for each triangle to vertices that aren't shares by the adjoining triangles. So you to double (triple?) the number of vertices just to get a low-poly faceted kind of look.
     
  4. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,613
    Pretty much. I've also heard of shaders that could get the faceted look too. I don't know how they work, though. They May just have a vertex function that does what you describe.
     
  5. sgower

    sgower

    Joined:
    Mar 9, 2015
    Posts:
    316
    Thanks. Yes I've tried one of those shaders, but it didn't work very well for me. My meshes have lots of square sections (each made with 2 triangles),and was I was seeing is that the color/brightness of each triangle was different. So a single flat surface (The square) didn't have the flat, and same color that I was hoping for.