Search Unity

How to render front and back the same? (Render Face = both)

Discussion in 'Universal Render Pipeline' started by DennisWardAltair, Apr 6, 2020.

  1. DennisWardAltair

    DennisWardAltair

    Joined:
    Apr 4, 2019
    Posts:
    27
    I have a generated mesh from a CAE analysis result I'm rendering that is made up of sheet metal that I'd like to render both back and front faces the same (as I have done with OpenGL in the past by enabling two-sided lighting and disabling backface culling).

    I was hopeful that specifying "Render Face = both" would do the trick, but the appearance of the back face is darker and not what I expected. My goal is to have both the front and back faces render the same.

    I'm using URP/Lit mesh material, and the images below show the model with Render Face set to both, front, then back. I am hoping that I can somehow find the setting that will allow me to show all polygons as seen in the front image, regardless of their facing direction.

    Thanks, Dennis

    Here's the screenshots:

    Both:


    Front:


    Back:
     
  2. alexxUID

    alexxUID

    Joined:
    Jan 14, 2020
    Posts:
    48
    Have you found a solution for this in URP?
    It seems to me HDRP does is correctly but not URP.
     
  3. DennisWardAltair

    DennisWardAltair

    Joined:
    Apr 4, 2019
    Posts:
    27
    I ended up writing a shader to flip back-facing normals in URP. I made a FFNormal subgraph:

    ffnormal.png

    I used it in my shader as follows:

    surface.png

    If you find a better way, please let me know!

    Thanks, Dennis
     
    alexxUID likes this.
  4. alexxUID

    alexxUID

    Joined:
    Jan 14, 2020
    Posts:
    48
    Sorry for the late reply - had no notification on.
    Thanks for that, that is at least some help although does not solve all my problems, since I need a transparent object as well and not just a hard surface.
    I am really confused how this is a problem at all. Is it so uncommon to use double sided stuff? Or are we doing something completely wrong?

    Thanks again,

    Alex
     
  5. DennisWardAltair

    DennisWardAltair

    Joined:
    Apr 4, 2019
    Posts:
    27
    No problem. I was able to also do alpha, but used a variation of this shader (Surface="transparent") and set the alpha value. Other than that, the graph was pretty much the same.
     
  6. se

    se

    Joined:
    May 20, 2013
    Posts:
    46
    Can someone help me fix this for the "SimpleLit" shader adapting the shader code. My attempt so far is to split the "ForwardLit" pass inside
    SimpleLit.shader
    into 2 passes: "ForwardLitFront" with
    Cull Back
    and "ForwardLitBack" with
    Cull Front
    . For the back pass I then set
    #pragma vertex LitPassVertexSimpleFlipNormal
    . I copied
    LitPassVertexSimple
    inside
    SimpleLitForwardPass.hlsl
    as
    LitPassVertexSimpleFlipNormal
    and added
    input.normalOS = -input.normalOS;
    at the top.

    The result is unfortunately that the backface isn't rendered at all now. But it does seem to work in principle. If I remove the front pass the backface is rendered and lit properly. What am I missing so that both passes work at the same time?
     
  7. se

    se

    Joined:
    May 20, 2013
    Posts:
    46