Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
6
Question by Arelius · Nov 23, 2013 at 09:10 PM · spritedepth-bufferspritemanager

Enable sprite depth write.

I'm using the new Unity 2D sprite functionality, it seems that in doing so, none of the sprites write any values to the zbuffer. Is there a simple way to enable zwrite?

Additionally, is there any way to find the source for say the shader behind the Sprites-Default shader?

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

1 Reply

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

Answer by Arelius · Nov 24, 2013 at 12:25 AM

I figured this out by downloading the built-in shaders from http://download.unity3d.com/download_unity/builtin_shaders-4.3.0.zip making a duplicate of sprites-default.shader called sprites-zwrite. And within the shader changing the lines:

 "RenderType"="Transparent"

and

 ZWrite Off

to

 "RenderType"="TransparentCutout"

and

 ZWrite On

Then using that new shader in all of my sprites.

Comment
Add comment · Show 4 · 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 renfei · Apr 01, 2015 at 04:41 PM 0
Share

thanks guy!! it helped me!!

avatar image LUPShow · Oct 02, 2015 at 01:41 PM 2
Share

Hi! i am trying the same thing in Unity 5.1.3. Did exactly what you described, but the sprite is still not writing into z-buffer. I need it for DOF effect to work on my sprites in the scene...

someone got such problems as well?

avatar image G3al LUPShow · Feb 03, 2016 at 11:49 AM 1
Share

Hi there, I was having the same issue lately, just recently started messing around with the CG stuff so if someone finds I wrote something wrong/ incorrect feel free to correct me. In Unity5 the Depth buffer is rendered in a separate pass before any geometry, meaning that if you use the default sprite with ZWrite On that won't work for some reason I believe connected with how sprites are handled. If it does work and you manage to write a shader to do it, it will write the whole quad of the sprite into the depth buffer, simply because the way of sprite rendering is done via the alpha blending. On the other hand a the cutout shader discards pixels. I mixed the default sprite shader and the cutout, and everything works just fine. After a few tests, something really strange was happening, but when I used: Fallback "Transparent/Cutout/VertexLit" With that put on the end and a the mixture of cutout and sprite shader, all seem to work just fine. If anyone has an explanation why it would be awesome. I took a look at the vertexlit shader, and I can't really understand whats being so important from it to make the sprites render to the depth buffer...

avatar image Kirbychwan G3al · Apr 23, 2017 at 12:38 AM 0
Share

Thread necromancy, but would you happen to have a copy of that shader handy?

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

20 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

Related Questions

SpriteManager 2 pixel perfect blurry and stretched 2 Answers

Animating a Character Sprite Sheet. 1 Answer

iOS SpriteManager 2 issue with backgrounds 1 Answer

Isometric camera with Spritemanager 2 Answers

How do I use the PlayAnim function in SpriteManager 2? 1 Answer


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