- Home /
[Help] Some backfaces redering through mesh on both unity created sphere and an imported sphere
I am working in Unity 5.6.1f1 Personal 64 bit on a windows desktop windows 7 pro sp1.
I have run in to an issue where some backfaces on a sphere are rendering through the mesh.
This first happened on a Unity created sphere. My solution was to make a sphere in maya and import it. This had a similar issue.
On the unity created sphere it creates kind of an eggshell effect and on the sphere created in maya exported to an .obj file and imported into unity it displays the end faces and also a random face on the surface.
On the imported sphere, I double checked the normals in maya all are facing outwards, and the UVs appear to be correct.
Here is a link to a video showing the issue: https://youtu.be/VJphRV67bmc
Has anyone run into this issue before and is there a solution for it?
Never had this issue, but I$$anonymous$$HO it seems to be a shader problem. i.e. it's not the mesh that has the problem.
Ya I second this, probably a problem with the shader. I had a similar looking artifact when I was working with transparency. Check to see if shader is using alpha blending and disable if so.
Answer by Bunny83 · Dec 05, 2017 at 03:15 AM
The problem comes from two factors:
Your used shader does not either not write to the depth buffer and / or doesn't perform a depth test
Your used shader does render backfaces. So it doesn't use backface culling.
As the object appears there doesn't seem to be any reason for any of the above mentioned points. The object appears to be solid. As such you should enable depth buffer writing and testing in the shader. Also i don't see a reason why you want to render backfaces. Almost all shaders usually use backface culling except some transparent / particle shaders. What shader do you acutally use? This would be a needed detail to fully answer your question.
The reason this happens is that the triangles of your mesh are defined in some kind of order. The GPU will render the triangles in the order they appear in the index buffer. If you don't use the z-buffer for depth testing that would mean if a triangle further away from the camera is drawn last it will simply overwrite what's already in the framebuffer. The depth buffer was invented just for such cases. However convex objects (like a sphere) usually don't have this problem when you enable backface culling, If the back facing triangles aren't rendered at all you will only see the front facing triangles and those can never overlap for a convex object.
Your answer
Follow this Question
Related Questions
Unity extract data before rendering 0 Answers
Objects are not visible until the camera gets closer. 1 Answer
Is it possible to render in Unity without the editor/scene/player being visible? 0 Answers
Unity2D strange green line under sprites 0 Answers
Native rendering plugin D3D11 device type not being set in x86 builds. 0 Answers