Wrong Fresnel shading with ortho camera

I noticed a weird effect when I combine both an ortho camera with Fresnel shading:

Rotate the camera to get the ball close to the edge and you will notice that the ball’s edge close to the viewport edge gets green again which I would not expect for correct Fresnel shading. Since it’s a ortho camera I would not expect any changes how the ball is rendered (except for its position of course).

I guess the wrong angle is used for calculating the Fresnel shading: instead of using the angle between camera and rendered point in 3D space, the plain camera orientation vector should be used, because in ortho mode you see each pixel in the 3D space from the same direction.

Thanks for looking into this issue!

Maybe @sebavan or @Evgeni_Popov would know?

Is there any way I can support fixing this? I’m happy to discuss the details.

Pinging @sebavan again as hes back

It is a currently know limitation of our materials, but the good thing is we could potentially rely on a material plugin to help with this.

@7om what kind of materials are you planning to use ? only StandardMaterial ?

I’m just using StandardMaterial.

Some context: I’m using (emmisive) vertex colors to display a color-coded scalar. I disabled any lighting-related shading, because it would interfere with the color display. To give the user at least some hint about the actual geometry, I’m using the Fresnel rendering to darken the edges.

Hence, StandardMaterial, disableLighting, emmisive vertex colors, and Fresnel rendering on emmissive.

Thanks for your support!

To give the user at least some hint about the actual geometry, I’m using the Fresnel rendering to darken the edges.

Hmmm this would be more of an alternative solution but have you considered using wireframe or edges rendering? :thinking:

The images should look similar to this (maybe even less shading, but that’s nice about the Fresnel shading, because I can tweak it w/o influencing other objects which get the normal rendering treat):

Wireframe or explicit edge rendering would be too intrusive, IMHO. But thanks for the input. :slight_smile:

Something like this: https://playground.babylonjs.com/#M2YD6F#2 ???

1 Like

@sebavan That looks perfect! Cheers! :partying_face:

1 Like

@sebavan Do you plan to include this as a fix for the ortho view or should I use your approach?

I could image that the wrong view direction vector is used in several places for ortho view.

You should use this approach for now, and I ll see if I can make it in the framework but it would need to handle all the weird edge cases :slight_smile: