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 /
avatar image
0
Question by DanielGL · Jan 07, 2021 at 09:35 PM · renderingshadersspritesrenderer2.5d

Problem to solve Z-Fighting with Offset shader, how can I do it works?

So, I have a 2.5d game with 2d sprites in a 3d world, that sprites are divided in two parts, color and line. The color and line stays in the same position, because of that they starts z-fighting. I tried build a shader to set an offset to the line renderer, to make her stay always in front of color renderer, and it works in the majority times, but depending of the position of the color sprite, that renderer is completly hided by the line sprite...alt text

I'm a newby making shaders, so I create my shader with shader graph and then copy the source code and replaced in the Unlit shader, after make that I turned on the ZWrite and modified the offset "property" alt text

Finaly, how can I solve that hiding bug?

20210107-182037.gif (289.8 kB)
screenshot-1.png (24.4 kB)
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

Answer by Zaeran · Jan 07, 2021 at 10:56 PM

If you're using a SpriteRenderer for your objects, you can adjust the SortingLayer on your Renderer to set which order they will render in. This will solve any z-fighting issues between them.

Comment
Add comment · Show 3 · 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 DanielGL · Jan 08, 2021 at 06:30 AM 0
Share

It doesn't work for me, since i'm using sprites in 3d world, see, in the image, the line of the sprite is being in front of another sprite who is in front of that line (remember my sprites are in x, y and z vectors, with a camera who rotates and move in all vectors) alt text

screenshot-1.png (202.4 kB)
avatar image Zaeran DanielGL · Jan 08, 2021 at 08:33 PM 0
Share

Do your sprites rotate to face the player at all times?

avatar image DanielGL Zaeran · Jan 09, 2021 at 04:10 AM 0
Share

Yes, my sprites are always facing the camera.

avatar image
0

Answer by hpr895 · Jan 06 at 03:26 PM

hi. (and not a year has passed)

maybe you need this:

 Tags { "RenderType"="Opaque" "Queue" = "Transparent" }
 Blend One OneMinusSrcAlpha
 AlphaToMask On

it helps me in the similar situation

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

149 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

Related Questions

Universal Render is stuck applying Cyan 1 Answer

Weird rendering on Android: some materials become black, some sprites are replaced 1 Answer

How to render one object on top of another in URP? 0 Answers

ShaderGraph Error "undeclared identifier BuildSurfaceDescriptionInputs / BuildVertexDescriptionInputs" 1 Answer

Unity 2019.4.17 crashes when working in HDRP 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