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.

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

    29 vote(s)
    96.7%
  2. Why, It is easy... here a solution

    1 vote(s)
    3.3%
  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:
    82
    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
     
    wifitofu and Alfonmc like this.
  3. AydinDeveloper

    AydinDeveloper

    Joined:
    Sep 8, 2017
    Posts:
    82
    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
  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:
    82
    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"
     
    Newtori, wifitofu and rocketpadmedia like this.
  6. wifitofu

    wifitofu

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

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    438
    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:
    82
    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
     
  9. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    438
    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