Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
avatar image
1
Question by fleity · May 30, 2017 at 07:17 PM · uishaderdepthdof

UI shader write to depth buffer

Hi everyone,

I have a few world space canvases which I'd like to have blurred by the post processing depth of field effect (from the post processing stack) like any other geometry. However since the default UI material does not write to the depth buffer I get some weird results. Therefore I downloaded the built-in shader made a copy of the ui-default shader and changed it's RenderType to TransparentCutout and ZWrite to on as suggested here: http://answers.unity3d.com/questions/582064/enable-sprite-depth-write.html

but that did not work. Any suggestions on what I am missing?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by fleity · Jan 14, 2020 at 01:46 AM

okay it's two and a half years since this question. nevertheless I opened up a new unity project and set out to solve the same problem again.

Obviously to use any new shader it needs to be selected in material, that goes without saying, it is the only way. Replacement shader might be a way to solve it because on could render the object again with a shader that writes depth but is then overwritten again by the transparent rendering before we get to the post processing stage when the image is blurred.

However the closest to an actual answer to my question can probably be found in this thread, although a quick five minute copy paste of that code + adding a clip(alpha - 0.001) did not result in what I needed. With clip function nothing is written to depth, without the entire quad writes to depth.

The easiest and most sane way is to get a standard shader, set it to cutout and that just works. Somewhere in the standard shader is the solution for the UI-Cutout-DepthWrite shader but just using the standard shader is probably the right way to go about this.

Comment
Add comment · Share
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
avatar image
0

Answer by JonPQ · Jan 13, 2020 at 08:54 PM

you'd need to put that shader on a material, and put that material on your ui or use camera replacement shader to render your ui objects with that shader

Comment
Add comment · Share
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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to improve shader to render UI text correctly / DOF Cam / 0 Answers

Camera layering : UI shader is cleared by second camera with Depth Only flag 1 Answer

UI masking in a jet fighter HUD 0 Answers

Intersection Highlight Shader -1 Answers

clipping issue with sprites in fixed camera scene 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