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

Question Trying to make bump edge from normal vector

Discussion in 'Shader Graph' started by CosmosBear, Apr 18, 2019.

  1. CosmosBear

    CosmosBear

    Joined:
    Aug 2, 2012
    Posts:
    67
    Hello,
    I've been working for some time on a dynamic snow shader with a edge bump mixed with the normal map (where the snow and the rock blend on the exemple images)


    1.jpg
    Here without the edge bump

    2.jpg

    The problem is probably how I "get" this edge bump, it seem to create glitches at the border of the islands UVs from the meshes.

    3.jpg

    This is the graph:
    Here is how I made the snow cover, I'll try to explain it step by step:
    1. Intensity of the noise of the edge using the rock normal map
    2. Direction of the snow (vector 3)
    3 The dot product is optionnal, to use round numbers for snow direction
    4. For "snow depth", it multipily the snow direction value, easier to control with a slider
    5. This is to get a more gradient or sharp snow edge
    6. Finally all this is kind of used as a snow cover mask

    5.jpg

    Then I send it to get mixed with the other maps: Base color, AO, Metallic, Smoothness and Normal Map. Since the issue is from the normal, i will not show the other parts of the graph:
    1. This is the snow normal map
    2. This part is probably totally wrong and seem to be the cause of the glitches I get, using the Normal from Height node I use the snow cover mask and convert it to normal, it kind of works well except for those glitches.
    3.The intensity of the mix
    4. This is where the snow normal map and the snow cover normal mix
    5. This is where the Rock normal map get mixed with the previous mix, using the snow cover as a mask and sent to the lit master

    6.jpg

    So yeah, I'm still pretty noob with all that blending and normal vector stuff, if anyone could help me out it would be greatly appreciated.

    Thanks
     
  2. NeatWolf

    NeatWolf

    Joined:
    Sep 27, 2013
    Posts:
    924
    Hi there,
    I'm far from being a senior shader programmer, but I believe most of the time the mapping coords for the "coatings" are in world space to avoid that, among other things (I'm thinking about triplanar mapping)
    Do the seams seem to be bound to the UV mapping? What if you use a simple planar projection (from above) in your 3D software to generate the UVMaps? do you still get the seams?
    I may be saying some nonsense, I know, just trying to give my 1 cent :p
     
  3. CosmosBear

    CosmosBear

    Joined:
    Aug 2, 2012
    Posts:
    67
    Hi, sorry for the reply delay,

    Indeed you are right with a planar uvMaps I don't get the seams. It's like if the mask was bound to the Uv0, I just can't figure out how to use a different UV for the mask or even use a triplanar mapping for the mask (the snow textures are triplanar maped but not the mask if it makes any sense?).

    I'm not sure how to use triplanar mapping to "generate" a mask, is it even possible?

    I think the main problem come from when I convert this mask in normal with the Normal From Height node. The result probably gives something wich makes not much sense when blended with the others normals (wich gives the deformation near the edge of the UVs),

    So here are 2 "solution" or rather some way to get across the problem.

    1- I use the uv0 for the mask only. Every mesh need a planar Uv, no cut. Base color map, mask map and normal map use UV channel 1.
    2- I simply not crank up to 100 the normal strenght of the normal from height map. At value 1 there is no normal deformation.