- Home /
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...
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"
Finaly, how can I solve that hiding bug?
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.
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)
Do your sprites rotate to face the player at all times?
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
Your answer
Follow this Question
Related Questions
Universal Render is stuck applying Cyan 1 Answer
Weird rendering on Android: some materials become black, some sprites are replaced 1 Answer
Uniform face colour flat shading using Shader Graph 0 Answers
How to render one object on top of another in URP? 0 Answers
Block Perspective in Top-Down 2D Games 2 Answers