Glitch/overlapping when two objects are on exactly same transform
Asked Answered
H

2

1

Is this just a shader problem or something else?

Greetings fellow devs.

I’ve been struggling with this same problem occasionally when I started using unity.

My current project is using a prefab maze parts (just like in the

Labyrinth board game) and they’re instantiated to their certain places

when player presses keyboard button. Works like it should. :slight_smile:

But when two prefabs (using box colliders,mesh,kinetic rigidbody and

standard shader) are placed to scene problem occurs with some prefabs →

When two prefabs end to same coordinate they start clipping.

Added a gif to show what i’m typing about.

Gif of my problem in imgurl

This is only happening in play mode. In editor window everything looks good. :stuck_out_tongue:

Problem can be “fixed” by adding -/+0.001 to one of gameobjects current

scale and glitch is gone. But! then there’s a small visible edge and i’m

trying to have smooth surface all around the maze.

So is this easily prevented by changing some player settings, setting

custom shaders to prefabs/gameobjects or do I need to micro adjust

and checking every one of them in play mode just like i’ve been doing to this day?

And here’s pic one of prefabs just for kicks:

Picture of one of Prefabs

Haleyhalf answered 18/12, 2020 at 21:47 Comment(0)
D
0

That is what’s known as Z-fighting. It’s what happens when floating point accuracy picks a fight with every pixel being rendered, and is a result of stacking multiple triangles on top of each other in that exact manner. It’s also pretty commonly seen in 3D games in general.

For the most part, it’s not really something that’s easily solved except by ensuring that your meshes don’t overlap so precisely, by whatever means are necessary. (This could include modifying the models, faking a minute depth change in the vertex shader on an arbitrary per-object basis, etc.)

Dryfoos answered 6/6, 2023 at 2:32 Comment(1)

So there's even a name for this phenomenon. Interesting. :) I'm glad you could give me "Everyday you learn something new" moment. Well looks like it's going to take a while when fixing and checking every possible prefab combination in working order. Thank you yet again for precise answer. I'll start my prefab modifying marathon -->

Haleyhalf
L
0

this solve the problem for me
(( Problem can be “fixed” by adding -/+0.001 to one of gameobjects current
scale and glitch is gone ))
as you did say before
and thanks for this

Lacroix answered 13/7 at 19:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.