Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by benjmitch · Dec 21, 2021 at 09:17 PM · shaderrenderqueuedeferred renderingrender order

URP deferred rendering: can I force ZWrite On for transparent render queue?

I'm rendering a spherical ocean with various other geometry around, a terrain and some objects. I've implemented the ocean rendering using three materials, each with a Shader Graph shader I've authored, as follows.

The OceanSurfaceUnderside is in queue 2900, is semi-transparent, and provides the appearance of the underside of the water.

The OceanVolume is in queue 2901, is semi-transparent, and provides a simple fog based on the depth buffer (for the actual target of each pixel's viewline) but primarily using the known geometry of the spherical ocean to determine the underwater path length and thereby the fog density.

The OceanSurfaceTopside is in queue 2902, is semi-transparent, and provides the appearance of the topside of the water.

These three elements work nicely together, and I'm happy with them. Yay. It's required that the volume shader is interleaved, in its render order, between the other two - that's intrinsic to the function, and a consequence of the spherical ocean.

Now, I also apply fog to the whole thing using the Lighting dialog (so, I guess, a post-processing step). This keys off the depth buffer. Trouble is, my materials at 2900-2902 are not writing the depth buffer, so they don't get fogged correctly.

So, I thought, I'd change "Depth Write" to "Force Enabled" in each of the two surface shaders. That way, I'd have the depth buffer set correctly, and fog would work. But changing this setting does nothing.

After much searching, I saw a hint that render queue value might matter too, and I moved these three materials to 2490-2492. Voila, the fog now renders correctly, if I disable the volume shader. But, it appears that the interposed OceanVolume material also writes the z-buffer now, even though I have set its "Depth Write" to "Force Disabled", and that screws up more than just the fog.

So, my question is, is it possible - in URP, using deferred rendering, Unity 2021.2 - to have materials at queue <= 2500 not write Z, and/or materials at queue > 2500 that do write Z? Because on this evidence, it seems not, but I can't find any documentation to this effect.


Whilst searching, I've noted that the documentation seems pretty sparse around render queues, render order, and how they play out on different configurations. Am I missing something? Many posts talk about "the render queues" and specify the known ones such as 2000, 2450, etc, and a few posts mention going +1 or -1 to force the rendering order. Does this force the rendering order? Are all operations of a shader in queue 2900 always performed before any operations of a shader in queue 2901? Because my volume shader seems to - I'm far from sure - write the z-buffer before my first shader, OceanSurfaceUnderside, writes anything. I don't know how to debug this, so I'd much appreciate a steer towards the documentation, or debug tools, I might be searching for. More generally, where do I look for an understanding of what gets done in what order, specifically in the URP but I guess in Unity more generally. Like, when does the fog in the Lighting dialog get computed? Where would I look to find that out?

With thanks for any help.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

237 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Rendering object as background. 1 Answer

Unpacking Normal Buffer in Post Processing Shader (HDRP) 0 Answers

Shader passes being run in wrong order? 2 Answers

Transparent water shader and problems with render queue 0 Answers

Outline shader: should be seen through some object but not when other object is between first object and shaded. 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges