Home Technical Talk

How to avoid "separated" or "black" edges on model using a heightmap?

node
I created a heightmap for my model by two different ways: in photoshop, and with a program call Materialize, and both gave me the same results. This is my first time using heightmaps, so I'm definitely missing something. I'm trying to use it (the heightmap) in Unity with the Standard Shader, however, I've seen some videos that use heightmaps on Unity and they didn't seem to have these issues.

This is how it looks with the Standard Shader:



Changing the Heightmap value on the shader throws me this result, those black bars on the edges. Materialize offers a shader for Unity, so I tried to use it, and it gave me this results:



So yep, nothing beautiful as you can see. I've read on a post on StackOverflow that you could weld the edges to avoid this issue, and also I read on Unity Answers that sometimes you would need to flatten the edges on the heightmap.

That lead me to the conclusion that maybe this isn't a shader issue, but rather a model/texture issue.
So, what can I do to avoid this?

I used Blender 2.9 to make that prop (the brick pillar).

Replies

  • Yerus
    Offline / Send Message
    Yerus polycounter lvl 5
    Um... I'm not familiar with Unity, but in Unreal could be a lightmap issue, try to bring up lightmap res. Or could be a bad UV unwrapping for lightmaps.
  • Kanni3d
    Offline / Send Message
    Kanni3d ngon master
    @Yerus Not related to his issue at all. It's not the harsh black shading that is the outlined problem, but the fact that the displacement/height isn't contiguous across his mesh and breaks the mesh at the hard edges seen in the 2nd photo.

    if OP can post his uv's, it may help spot something, otherwise I'm leaning more towards an issue with the shader or material setup.
  • Yeudielcc
    Kanni3d said:
    @Yerus Not related to his issue at all. It's not the harsh black shading that is the outlined problem, but the fact that the displacement/height isn't contiguous across his mesh and breaks the mesh at the hard edges seen in the 2nd photo.

    if OP can post his uv's, it may help spot something, otherwise I'm leaning more towards an issue with the shader or material setup.
    They're actually simple, but now I don't know if I made them correctly...


    And this is my heightmap (I edited the edges of the image, but it didn't make any difference):

    Probably as you can see I don't know anymore what I'm doing xd
  • gnoop
    Offline / Send Message
    gnoop sublime tool
    Height maps just doesn't work over split /hard edges geometry where vertex normals points to different direction.  The displacement goes along those normals.
      It could work if you make a small bevels  all over your geo  and a single smooth group /smooth shading or whatever it may be called + face weighted /rotated normals .  i.e. no vertex normals looking different directions from the same point.  

    Another height maps issue   the displacement needs tessellation and it's usually works not that well over long triangles  realtime geo sometimes have . So models for displacement should be more or less evenly tessellated.
  • Yeudielcc
    gnoop said:
    Height maps just doesn't work over split /hard edges geometry where vertex normals points to different direction.  The displacement goes along those normals.
      It could work if you make a small bevels  all over your geo  and a single smooth group /smooth shading or whatever it may be called + face weighted /rotated normals .  i.e. no vertex normals looking different directions from the same point.  

    Another height maps issue   the displacement needs tessellation and it's usually works not that well over long triangles  realtime geo sometimes have . So models for displacement should be more or less evenly tessellated.

    As I investigated, it seems that what you've said it's definitely the way to go, but I'm a bit lost...

    So first, as you said, I made a small bevel along the edges of the original model. Now, it seems that Smooth Group/Shading does not exists as it is in Blender, but there are a few ways to achieve something similar, or I read so (I created a vertex group and the applied a modifier called Smooth). This is the post I saw on StackOverflow, I followed the second answer: https://blender.stackexchange.com/questions/4806/blenders-smoothing-groups-solution-edge-split-destroys-topology-is-there-a

    Now, before doing anything else, I exported the model and went back to Unity, and...it happened pretty much the same. So I headed back to Blender and, with faces selected, I used Face->Weight->Normalize All.

    It also didn't work, so I gotta admit that I need some more guidance...
  • gnoop
    Offline / Send Message
    gnoop sublime tool
    Just get rid of split/hard edges . make everything smooth shaded and check  if displacement works without seams in Blender itself first with displace modifier.      A game engine splits the mesh along UV seams  anyway  but theoretically  it should work ok if both vertexes on the edge have same normal .        

    it also may depend on the normal map if the shader makes actual displacement  along pixel normals  instead of vertex ones.  So  same column side texture  not unique  for other sides   may create per pixel normals mismatch on the edge   making pixel normals  on different sides looking in slightly different direction when on model ,  splitting the mesh.  

     Try it with unique unwrap  or use some special corner rounding insertion   without uv  seam  if it's the case.

    ps, I don't know if Unity shader  actually use perpixel normals  for displacement direction. Our engine use vertex ones .  Try unique unwrap and see if it makes any difference





Sign In or Register to comment.