Search Unity

Sky rendering over terrain with custom shader...

Discussion in 'High Definition Render Pipeline' started by jbooth, Nov 11, 2019.

  1. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    So, everything renders fine in the editor and in the camera view, but in the game view the Sky is rendering over my terrain.. And, this also happens with the default cube as well!

    Editor View:


    In game:


    The default sky appears to be rendering over both my custom shader and the default Unity cube using the default Lit shader.

    This is using 2019.2.0f1 using 6.91 of the HDRP on OSX, though the same thing happens on Windows..
     
  2. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    It appears it's not doing the depth prepass on my shader, even though it's got a pass for it and correctly tagged.

    Code (CSharp):
    1.         Pass
    2.         {
    3.             // based on HDLitPass.template
    4.             Name "DepthOnly"
    5.             Tags { "LightMode" = "DepthOnly" }
    6.        
    7.             //-------------------------------------------------------------------------------------
    8.             // Render Modes (Blend, Cull, ZTest, Stencil, etc)
    9.             //-------------------------------------------------------------------------------------
    10.            
    11.             Cull [_CullMode]
    12.        
    13.            
    14.             ZWrite On
    15.        
    16.            
    17.             // Stencil setup
    18.         Stencil
    19.         {
    20.            WriteMask [_StencilWriteMaskDepth]
    21.            Ref [_StencilRefDepth]
    22.            Comp Always
    23.            Pass Replace
    24.         }
    25.        
     
  3. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461


    Notice the depth buffer is fine in editor, but blank in game. Shouldn't they go through the same rendering pathways?
     
  4. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    So I figured out what was going on here, and it's almost by chance I figured it out. Everything in my shader was correct- exactly like the template the shader graph spit out. However, it turns out the custom inspector for the shader graph sets some data on the material which disables the motion vector pass which is only viewable in the debug inspector. So when I first started prototyping I was using a material which had a shader graph shader assigned to it at one point, and this was set on the material, and everything worked. So then I create a new material, and everything breaks.

    There's a few things I don't like about this:
    - Having a motion vector pass disabling the depth pass is counter intuitive
    - Having the motion vector pass be disabled by a material inspector or even in the material is bad.
    - It would be better if it showed you this on the material so at least you know
    - This data is separate from the shader, so leads to unexpected behavior when new shaders are assigned

    So I think the right answer here is to delete my MotionVector pass all together, so regardless of what the material says it won't disable the depth buffer pass.
     
    iamarugin and Rowlan like this.