4
\$\begingroup\$

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. Please note that the camera is in the center and the face away from camera is very light. 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.Ball material

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. :) .

\$\endgroup\$
  • \$\begingroup\$ "renders material correctly" - remember that you're the only one who knows what is "correct" for your game unless you describe it to us, or show us a picture of what you want so we can understand what's wrong with what you have now. Looking at the screenshots you've posted, I don't know what it is you're trying to change about them. \$\endgroup\$ – DMGregory May 29 '16 at 12:46
  • \$\begingroup\$ 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. Any help will be greatly appreciated :) \$\endgroup\$ – Ikun May 30 '16 at 16:18
  • \$\begingroup\$ It sounds like you're trying to remove one of the specular components of the physically-based default material. If you change to another shader, like the Legacy Diffuse shader for example, this extra glancing reflection highlight will not be present. \$\endgroup\$ – DMGregory May 30 '16 at 16:27
  • \$\begingroup\$ Thanks a lot , I tried the legacy diffuse shader and the problem was solved. But isn't it wrong to use a legacy diffuse shader if it has been deprecated ? Also I did not understand your specular component explanation. Could you explain or kindly point me somewhere i can understand this? \$\endgroup\$ – Ikun May 30 '16 at 16:36
5
\$\begingroup\$

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:

Diagram of visibility for perspective vs orthographic cameras

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.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.