Previously, the generated clouds were simply illuminated according to their turbulent surface. Hence, the color mostly depended on the distance to a cloud's origin. To incorporate the sunlight, the Phong illumination model was used and adapted. This model consists of three separately illuminated components of which the final colors are composed. Phong therefore used an ambient, diffuse and specular component to obtain realistically represented 3D objects.
Ambient component
The ambient component represents the illumination that only depends on the constant illumination of the environment. Thus, it is independent of the location of the camera and the position of light sources. To obtain the ambient illumination IA at a given point on the distorted sphere, the color was mainly derived from the noise.IA(x) = sunColor * (1.1 – noise(x))The noise factor as calculated by the vertex shader is from the range [0,1] and therefore the ambient illumination is always positive. The constant value 1.1 spawned the best results in a series of tests. Figure 1 displays a cloud with ambient illumination.
Figure 1 ambient illumination |
Diffuse component
The diffuse component depends on the angle of entry of the light. The diffuse illumination ID at a given point x on the distorted sphere is defined asID(x) = sunColor * (L . N)where L is the unit vector of an incoming light ray, N is the normal vector from the point on the surface and L . N is the angle between L and N.
Figure 2 shows the diffuse component of a cloud where the light source is above the object.
Figure 2 diffuse illumination |
Specular component
The specular component treats the reflection of the light from the surface of the cloud. Therefore, it depends on the light direction, the material of the reflecting object and the viewpoint of the observer. To calculate the specular illumination, the vector of the reflected light, the normal of the point on the surface and the observer's position are needed.Figure 3 displays the result of the specular illumination where the light source is placed above the cloud.
Figure 3 specular illumination |
Composed component
In the Phong illumination model, all three components are combined to obtain the final illumination. However, the specular component did not look real on a cloud because a highlight depending on the observer's position is not realistic and was thus removed increasing the performance of the fragment shader as it is time-consuming to calculate the exponentiation and the reflectance vector. The result that incorporates the diffuse and the ambient illumination can be seen in Figure 4.Figure 4 illumination combining the ambient and the diffuse component |
Keine Kommentare:
Kommentar veröffentlichen