Search code examples
c#wpflightingviewport3d

Useful lighting of a single-colored 3D object in a WPF Viewport3D


I have a 3D Modell of a house, where the roof is invisible so that the rooms can be seen (like here)

But (for now) I have no textures and each surface has the same color, e.g.,

var myMaterial = new DiffuseMaterial (new SolidColorBrush(myColor))

If I view it in a WPF Viewport3D, I want to be able to differentiate between the surfaces. e.g., I want to see when the floor ends and the wall starts.

This should be possible by lighting the object. I already tried:

Ambient light doesn't work, because all surfaces would look equally colored:

myViewport3D.Children.Add(new ModelVisual3D(){Content = new AmbientLight(Colors.White)})

And if I use directional light and stick its position to the moving camera, some surface normals are sometimes nearly perpendicular to the camera/light and so are nearly black, which looks even more unnatural.

So what is a good way to distinguish the surfaces of a single-colored 3DObject in a WPF Viewport3D?


Edited after user "jdv" wrote his comment


Solution

  • Since you can use 2 light sources, I would try using a dim light to act as an ambient background light and a somewhat stronger directional light to give contrast to the surfaces.

    I am not a 3d expert, but would think of it this way:

    In a dark room (no ambient light), with a flashlight (the directional light), you will see dramatic differences based on the angle of the surface to your flashlight. Add some ambient lighting and the harshness of those differences decreases as your ambient light source gets stronger, until at some point, it overpowers the flashlight and everything appears evenly lit.

    Good luck, hope you are able to achieve the effect you are after.