I was creating a simple unity game with a sphere as a ball. The problem is that the ball face towards the camera origin renders material correctly but the one away from camera does not. The ball has a standard material , the scene has directional light which faces in the camera's direction.The camera is orthographic and the background is solid.
Let me explain, in the material inspector window preview the ball is properly shaded from all sides as you can see. But in the game screenshot I have posted, the left half of the ball abruptly becomes lighter. Now this lighter shade is not because of the directional light or any other light source its because of the camera. because as I move near the camera center origin the original material shade returns but the farther I move the lighter shade nearly takes over half of the ball. I tried changing the camera rendering path to a vertex legacy lit and that solves the problem but I don't think that is the ideal solution. I am a newcomer to Unity and this is my first game. I tried going through the documentation but didn't find anything helpful. Any help will be greatly appreciated. :) .
Answer
The default shaders in Unity 5+ use something called physically-based rendering. This means they try to model a number of quirks we observe in real materials, which aren't included by the Lambertian/Phong approximations that have been popular in games in the past.
One of those effects is Fresnel reflection, where the shiny reflection off of a surface becomes more intense at glancing angles.
These effects often look great when we're trying to model a realistic-looking scene, but when we try to inject non-realism, we can run into artifacts.
Here, the trouble comes from the combination of a physically-based material and an orthographic camera. Orthographic cameras don't exist in reality, so applying reflection models meant for (comparatively) realistic perspective cameras can reveal some artifacts. When a sphere is far from the center of the view, a normal camera will lose sight of the far edge, but an orthographic camera will still see a whole hemisphere - effectively seeing "around" the object to parts that are normally invisible:
This means that Fresnel reflection effect at the edges is able to hit a brightness peak we normally won't see, because a surface will be occluded from view for a perspective camera before it ever turns away at such an angle. This creates the unwanted highlight you're observing.
The best thing to do, if the physically-based material is giving you artifacts you don't want in a non-photoreal scene, is to use a different material that doesn't try to model these effects, like the Legacy->Diffuse or Mobile->Diffuse materials.
"But isn't it wrong to use a legacy diffuse shader if it has been deprecated?"
Not really. The new shaders are meant to give consistency for setting up scenes with real-world effects like global illumination. If you're not using that, then you can skip all that complexity. The Legacy shaders still work just fine.
No comments:
Post a Comment