views:

127

answers:

2

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

+1  A: 

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.

adrift
Thanks that works. But I have to keep in mind that this method might not be the best. In theory there are always at least two faces with different normals that gets the same amount of light per area. In my case this doesn't matter cause all walls are along the axis, so that I need to consider only 6 normals.
Janko R
Japp I played around with it and its good. thanks :)
Janko R
+1  A: 

Personally, I find that this can be accomplished the "best" by a combination of two lights.

  1. A dim (maybe 30% lit) ambient light. This always shows all surfaces.
  2. A directional light, at about 80% white, which follows the camera, but is off by 30 degrees or so. I find a light "over the camera's left shoulder" tends to be what people often expect.

Also, if your surface normals are not always going to be correct, you can use a third light - another directional light pointing the opposite direction of the first. This will light the back faces of the surfaces if you've got inappropriate normals.

Reed Copsey