How to | Control the Response of a 3D Surface to Lighting
To control how a 3D surface responds to simulated light, set its reflection properties. The Wolfram Language lets you control the diffuse reflection of light on a matte surface and the specular reflection of light on a mirror-like surface. Combining them gives you extensive control over the final appearance and color of a 3D surface.
Intrinsic surface color corresponds directly to diffuse reflection, where light is scattered equally in all directions from the surface. For example, sheets of uncoated paper are matte ("dull") and thus show diffuse reflection.
By default, the intrinsic surface color of 3D objects in the Wolfram Language is white. Here, the color on the 3D cylinder comes from the Lighting setting the Wolfram Language uses by default:
More detailed control over the specific color of 3D surfaces can be gained with RGBColor, which lets you set explicit values ranging from 0 to 1 for red, green, and blue:
In fact, you can use many methods for setting the intrinsic surface color of 3D objects in the Wolfram Language. Here, CMYKColor is used:
When the sliders are set all the way to the left, the surface color is black. When the sliders are set all the way to the right, the surface color is white, which causes the cylinder to appear in the default color scheme:
The fraction of light that is specularly reflected can range from 0 to 1. For example, use Specularity to specularly reflect 30% of the light that falls on the sphere:
Many different colors in the Wolfram Language can be specularly reflected. For example, the sliders in the Manipulate here are used with RGBColor to dynamically set the color reflected by Specularity. As before, the Inset 2D square at the top right shows the raw RGBColor setting:
Specularity also lets you control exactly the width of the specular reflection of light by setting a specular exponent. The specular exponent is specified as the second argument to Specularity. If you do not explicitly set a specular exponent, Wolfram Language uses the default value of 1.5.
For example, use the slider in this Manipulate to dynamically adjust the specular exponent from 1 to 100. At a value of 100, the specularly reflected light is restricted to a small area:
ContourStyle is used similarly here: