2
\$\begingroup\$

I'm using blender to create assets to use in Unity3D, and I'm having some trouble understanding how the smooth/flat shading interacts with shadows, I'm sorry if it has been asked before, but all the "related" answers refer only to the shading of the object itself, not the shadow it casts.

I'm a 3D artist, I do not understand Unity and the mechanics behind it the same way I understand 3D stuff, I'm also trying to understand if the problem lies in the 3D object or some configuration in Unity.

Shadow artifacts

I'm using a real time directional light.

1 and 2 are flat shaded. 2 has open geometry while 1 has closed geometry, both have such artifact but it's clearly seen on 2.

3 and 4 both have closed geometry. 3 is fully smooth shaded while 4 is flat shaded.

Solution A: Mess around with Bias and Normal Bias. With Normal Bias at 0, the shadow artifacts are gone but the mesh itselt gets some other artifacts.

Solution B: Use Two-sided shadows, this method completely fixes the problem, in any situation, but it adds another draw call and makes it more expensive (I'm not 100% sure it does) - is this an optimal solution?

This same issue was discussed in a closed group but no one could give me a conclusive answer. However, someone who works with 3DS Max said that exporting a mesh with proper smoothing groups does not result in these artifacts, I tested that in 3DS Max and it did not work - I think I did it the right way, but I'm not 100% certain.

For all the proposed methods, I tested several times, with diferent mesh/modifier and exporting options. I'm using mostly .fbx but I also tested in .obj format (which includes a specific option for smoothing groups in blender).

Smooth shaded objects work perfectly, flat or smooth+flat shaded objects result in this drama.

Please help me to bring light to this issue, I might be blind to some obvious aspect, I'm confused because in the other discussion I was presented with contradicting arguments without conclusive proof of anything. Now I don't know if the problem lies with Blender/export or Unity configuration.

Let me know if I can provide more information.

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

During the rendering process, there can be many objects made up of many vertices each. When objects touch each other, 2 objects may have vertices that exactly share the same coordinate in world space. The way the rendering system knows whether the 2 vertices in the exact same spot are part of separate or same geometry, is to look at the normals to see if it is shared between the 2 vertices. With flat shading every face looks like a separate geometry and so gaps are sometimes rendered, when using normal bias for shadow calculations.

\$\endgroup\$

You must log in to answer this question.

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