Search Unity

Question Cross Section Backface - Shader Graph HDRP

Discussion in 'Shader Graph' started by Gohan4199, Mar 17, 2023.

  1. Gohan4199

    Gohan4199

    Joined:
    Mar 17, 2023
    Posts:
    6
    Hi

    I'm trying to create a simple lit cross section shader in shader graph within HDRP.

    How can I edit the shader graph to prevent the backfaces from receiving light?

    I would like the cross section to resemble a solid unlit colour. e.g. a solid red colour in the image below.

    I'm using the default HDRP scene.

    Any help would be really appreciated!

    upload_2023-3-17_12-42-42.png

    upload_2023-3-17_12-44-5.png
     
  2. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    704
    A hack would be to :
    - Change the surface mode to specular color
    - In the cross section backfaces :
    - Set base color to black
    - Smoothness 0
    - Specular color black
    - Ambiant Occlusion 0
    - Use the emission output for the flat color
     
    Gohan4199 likes this.
  3. Gohan4199

    Gohan4199

    Joined:
    Mar 17, 2023
    Posts:
    6
    Thank you for the help. This worked great! See the red cube below.

    I'm having a slight problem when trying to implement this same hack but with the front faces having a texture and the backfaces appear unlit. I've added a normal texture only on the front faces but the backfaces seem to show a dark colour where the faces join.

    Is there a way to prevent these dark areas on the back faces when using a normal texture?

    upload_2023-3-19_11-5-18.png
     
  4. Gohan4199

    Gohan4199

    Joined:
    Mar 17, 2023
    Posts:
    6
    Actually I think I may have fixed it - I've included a Normal Vector node with Tangent Space for the backfaces.

    upload_2023-3-19_11-8-22.png
     
    Remy_Unity likes this.
  5. Gohan4199

    Gohan4199

    Joined:
    Mar 17, 2023
    Posts:
    6
    How could I add a dithered effect to the remaining part of the cross section?

    I've tried using dither with the alpha value however this applies the dither to the entire model.
     
  6. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    704
    Like ... dither the top front faces ?
    It should be possible by applying the dither only on front face IF they are on top of the cutting plane.