Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Resolved Shader Graph Normal from Noise not Working on Procedurally Generated 3D Terrain

Discussion in 'Editor & General Support' started by ripefruits22, Feb 19, 2022.

  1. ripefruits22

    ripefruits22

    Joined:
    Nov 26, 2021
    Posts:
    17
    I've been playing around with Marching Cubes for a game and I had gotten the algorithm working, so I decided to make a shader in shader graph for it that colours the terrain based on its normals, and also creates a toon shading effect. So far it's worked perfectly, but there is one problem, the terrain is almost perfectly smooth so I get some pretty bad colour banding and the reflections don't look realistic at all:
    ShaderOnTerrain.JPG
    So I tried to fix this by implementing some normal noise into the mix to to break up the colour bands and smooth reflections, but I just can't seem to get the normal noise to actually apply to the terrain, I've tried just using the normal blend node and the triplanar node to do it, but it doesn't seem to work. I've applied it to Terrain and other objects and it works perfectly well as seen below, but it just doesn't seem to want to apply to my proc gen terrain. ReflectionsOnAPlane.JPG

    Here's the shaders normal calculations:
    ShaderNormalsCalc.JPG
    Colouring by Normals:
    ColouringByNormals.JPG
    and the lighting calculations:
    LightingCalc.JPG
     
  2. ripefruits22

    ripefruits22

    Joined:
    Nov 26, 2021
    Posts:
    17
    In case anyone else is having this problem, the solution I came up with was to add a 3D noise node(https://github.com/JimmyCushnie/Noisy-Nodes) and use the already existing normals from height node to turn that into a normal map, then do a normal blend between the normal vector and the 3d noise normals. I'm fairly certain the reason that 2D noise didn't work was because the terrain didn't have any seams, or any way for the texture to be unwrapped into a plane and then wrapped back into one, so it couldn't be applied.

    Completed Terrain:
    upload_2022-2-25_17-48-3.jpeg

    upload_2022-2-25_17-48-9.jpeg
     
    Last edited: Feb 25, 2022