Search Unity

Feature Request URP, Depth write, z-write, consistent problem of semitransparent objects

Discussion in 'Universal Render Pipeline' started by Alfonmc, Aug 1, 2020.

?

I would need a zwrite - depth write - whatever is going on.. to solve semitransparent objects

  1. Yes, I need it, still don't understand

    42 vote(s)
    95.5%
  2. Why, It is easy... here a solution

    2 vote(s)
    4.5%
  1. Alfonmc

    Alfonmc

    Joined:
    Dec 20, 2016
    Posts:
    4
    So, I have tried in so many ways to solve problems for semi transparent shaders, normally everything was solved in Standard by creating a copy of this shader with Zwrite on.. simple as that. It would be nice if Unity team just creates a version of a shader called - Semitransparent UPR lit, that let us create instead of wasting time to find out a solution, or some tutorial, wich I would be so *** happy to do it myself.

    I get it.. technically is not cheap, but sometimes you need to do some fade in fade out at your company, like we needed to do on some Augmented reality.. there we "solved" it by writing on Z, still on 2019.3

    A lot of time to understand how Render queue works

    I am an artist and I've been trying to solve some of this technical art issues for some time, but everything points to this document..
    https://docs.unity3d.com/Manual/SL-CullAndDepth.html
    "Shader ... Shader "Transparent/Diffuse ZWrite" { Properties { " at the link

    Question:

    Is this suppossed to work in URP? Because it is not.. we are at this point where we think shaders are kind of black magic... and I guess that is why you created ShaderGraph.. but still. I need a consistent solution, and I have been working with Unity everyday, since five years now...

    We are trying to make an addressable of objects of a small scene, but with water, and this water does not work, of course. So I need to figure out what is going on, why it does not work, why.. it does not work when I am calling the addressable but then when I open the material, it magically pops and start to work well. I guess thats a BUG

    Please HELP!

    I promise I would make a video explaining this... if its really sorted out. It would save me time to explain to the rest of artist who work with me why the hedgehog happens.
     

    Attached Files:

  2. AydinDeveloper

    AydinDeveloper

    Joined:
    Sep 8, 2017
    Posts:
    92
    When you switch to Debug mode, ZWrite can be set to 1 on Lit shader. This setting should definitely be added to Universal.ShaderGUI.LitShader.

    upload_2020-8-4_15-13-42.png
     
    DhiaSendi, wifitofu and Alfonmc like this.
  3. AydinDeveloper

    AydinDeveloper

    Joined:
    Sep 8, 2017
    Posts:
    92
    This shader will solve your transparent Zwrite problem for at least URP / Lit.

    Edit : Unity 2020.1 URP 8.2 Lit shader.
     

    Attached Files:

    Last edited: Aug 4, 2020
    WAB0TECH, DhiaSendi, Sthuarty and 6 others like this.
  4. Alfonmc

    Alfonmc

    Joined:
    Dec 20, 2016
    Posts:
    4
    Yes! Thats what we did last time on a project to solve it, I managed to tell my team about it, but then, something strange happenned, like, each time we clicked on the material it popped back into Zwrite = 0 so I guess it was a bug on the Unity version we were working with.

    This shader solves it! Exactly what I was looking for. I wish I knew a bit more about shaders, I was the whole weekend trying to understand Unity shaders, I found a video, but when I looked on URP shaders and it looked far too more complicated than the previous pipeline. Ill check how it's done comparing to the URP template

    Thank you Aydin! Thank you so much! you rule!
     
    rocketpadmedia likes this.
  5. AydinDeveloper

    AydinDeveloper

    Joined:
    Sep 8, 2017
    Posts:
    92
    Glad I could help :)
    actually it would be better to add _ZWrite setting to the shader Editor. At the moment, more shaders will be compiled.

    My changes to the URP / Lit Shader
    Replacing "ZWrite [_ZWrite]" in line 74 with "ZWrite On".
    Line 121 #include "Packages / com.unity.render-pipelines.universal / Shaders / LitInput.hlsl"
    Line 122 #include "Packages / com.unity.render-pipelines.universal / Shaders / LitForwardPass.hlsl"
     
  6. wifitofu

    wifitofu

    Joined:
    May 18, 2021
    Posts:
    6
    Aydin you're a legend, thank you
     
  7. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    518
    Thanks for sharing. Tried it on URP 12 but get this error:
    Code (CSharp):
    1. Shader error in 'Universal Render Pipeline/ZWriteLit': 'UniversalFragmentMeta': input parameter 'metaInput' missing semantics at /Users/Romaha/Documents/Projects/2021/CatoScience/Library/PackageCache/com.unity.render-pipelines.universal@12.1.3/ShaderLibrary/UniversalMetaPass.hlsl(37) (on metal)
    2. Compiling Fragment program
    3. Platform defines: SHADER_API_MOBILE UNITY_ENABLE_REFLECTION_BUFFERS UNITY_LIGHTMAP_DLDR_ENCODING UNITY_NO_DXT5nm UNITY_NO_RGBM UNITY_NO_SCREENSPACE_SHADOWS UNITY_PASS_META UNITY_PBS_USE_BRDF2
    4. Disabled keywords: SHADER_API_GLES30 UNITY_ASTC_NORMALMAP_ENCODING UNITY_COLORSPACE_GAMMA UNITY_ENABLE_DETAIL_NORMALMAP UNITY_ENABLE_NATIVE_SHADOW_LOOKUPS UNITY_FRAMEBUFFER_FETCH_AVAILABLE UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_LIGHTMAP_FULL_HDR UNITY_LIGHTMAP_RGBM_ENCODING UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_FULL_STANDARD_SHADER UNITY_PBS_USE_BRDF1 UNITY_PBS_USE_BRDF3 UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_SPECCUBE_BLENDING UNITY_SPECCUBE_BOX_PROJECTION UNITY_UNIFIED_SHADER_PRECISION_MODEL UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_VIRTUAL_TEXTURING _ALPHATEST_ON _EMISSION _METALLICSPECGLOSSMAP _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A _SPECGLOSSMAP _SPECULAR_SETUP
    5.  
    Is there a way to solver it?
     
    AydinDeveloper likes this.
  8. AydinDeveloper

    AydinDeveloper

    Joined:
    Sep 8, 2017
    Posts:
    92
    I don't remember if it was added in URP 12. Added option to force depth write of shaders generated in shader graph.

    upload_2022-1-26_14-39-22.png
     
    DhiaSendi and THE2FUN like this.
  9. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    518
    Added option to where? Initially you shared the shader, not shader graph. We can't use it and adjust to URP 12 in Shader Graph editor as you show in this reply
     
  10. THE2FUN

    THE2FUN

    Joined:
    Aug 25, 2015
    Posts:
    63
    It's added to shader graph but in debug mode if you changed 0 to 1 in my unity (2022.2.15) turns back to 0
     
    matheus_inmotionvr likes this.
  11. matheus_inmotionvr

    matheus_inmotionvr

    Joined:
    Oct 3, 2018
    Posts:
    63
    Same here. Does anyone have any idea why?