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 sometime开发者_如何转开发s 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
Personally, I find that this can be accomplished the "best" by a combination of two lights.
- A dim (maybe 30% lit) ambient light. This always shows all surfaces.
- 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.
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.
精彩评论