# 3D lighting model

The simplest lighting effect for 2D fractals is based on the slope, or more generally, the surface normal calculated from DE or smooth iteration or something else. In 3D lighting, that corresponds to some version of diffuse light, which depends only on the surface normal and the vector to the incoming light source (or sources).

A lighting model usually separates out the environment (light sources and their properties, and background) from the material properties of the surface, so they can be independently specified. Material properties include colour and texture, and how much diffuse and specular light they reflect, absorb, transmit, etc. Some of the simplest are the amount of diffuse light and the amount of specular light that are visible. The two common types of specular lighting are highlights (simulating reflection from a light source with some radius) and reflection from the background (ideally a full 360 degree environment map.) In Frax they don't use a picture for the reflections, they calculate an approximation of some windows with white light with some formula to avoid all the usual calculations, which works pretty well. That formula isn't publicly known and environment maps are much more flexible.

So diffuse light depends on the dot product of the surface normal and the light source direction. Specular light depends on the surface normal, light source direction, and also the vector to the eye. For highlights you use the light source vector and some function to calculate the intensity with whatever response curve you want. For background reflection you calculate the reflection of the eye ray on the surface and project it to an environment map. The math for this is pretty standard and you can find it anywhere.

For highlights you typically want several material properties. Besides the highlight strength, there is shininess (or highlight size, with intensity adjustment to conserve energy somewhat), some sharpness control (eg varying between Gaussian and circles with sharp cutoff), and metallicity (vary highlight color between surface colour and light source colour).

In a lighting model, the material properties determine the mix of diffuse and specular light effects, which come from the same light sources. This is more realistic than you would get from mixing some glossy light effects with an existing diffuse light effect that didn't use the same light sources. For good highlights you really do need the freedom to adjust the direction, intensity and colour of each light source (at least two lights are better than one.)[1]

# Description

• "bump mapping. It allows fake-3D visualization of subtle details previously hidden by the slow gradients in the palette." Botond Kósa[3]
• Normal map: "Fine scale relief on flat surfaces can be visible with proper lighting. " Arnaud Cheritat[4]
• unity3d : ParameterNormalMap
• "Slopes rendering is originally a screen-space post-processing effect, using differences between neighbouring pixels' smooth iteration counts. More recently it can use directional distance estimate (normalized by pixel spacing) instead, which I think gerrit proved is equivalent in the limit of infinitely fine pixel grid." Claude Heiland-Allen