0
\$\begingroup\$

I have a strange problem that I am not sure if it is a bug from Unity or not. I have render texture that renders camera output to a raw image. Camera looks at a object that consists of 2 parts: the Ball and a round objects in front of the ball. The render texture doesn't always render the object in front of the ball, but it seams that this happens randomly sometimes object is there and sometimes it isn't so I am not sure if this is a Unity bug or I did something wrong.

Here is the setup and the bug: enter image description here

1.The ball object camera is looking at: 1a: The ball that always get render 1b: The with object that is in front and gets render sometimes 2.The output on the raw image when the bug appears (when everything is ok results is like in the camera preview) 3.Camera preview that is always the same

As I said this seams to happen randomly. Also to note I am reloading the scene with this bug on several occasions in my game and on some loops it is fine on some not. I am using URP.

\$\endgroup\$
2
  • \$\begingroup\$ This looks like a case of z-fighting to me. You have two polygons extremely close together in depth, so sometimes they round to the same number in the limited precision of the depth buffer, and it's luck of the draw which one gets rendered in front. Do you notice any difference if you move the surfaces farther apart, shrink the near to far depth range of your camera, or increase the depth buffer precision of your render texture? \$\endgroup\$
    – DMGregory
    Jan 19, 2023 at 14:43
  • \$\begingroup\$ Awesome tnx I changed Deapth Stencil Format to a higher one and it worked. It did come with a bigger texture but it works so nice. \$\endgroup\$
    – Ivan
    Jan 19, 2023 at 15:07

1 Answer 1

1
\$\begingroup\$

Ok so with the help of the comments I fixed it. I changed the Deapth Stencil Format of my render texture and it worked. Note that this comes with bigger texture size. Here are my render texture settings:

enter image description here

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .