'Physically based rendering from first principles' that clearly explains the basics of 'light' in physically based rendering



To express realistic textures in CG, it is essential to simulate the interaction between light and objects using

physically based rendering . There is a website that uses animations to clearly explain the basics of how light is calculated, from the basic properties of light to the reflection of light on the surface of an object.

Physically based rendering from first principles
https://imadr.me/pbr/

◆Chapter 1: What is light?
There was a mystery in that assuming either light is a wave or a particle would result in contradictory phenomena, but today quantum electrodynamics is recognized as the most accurate theory describing all interactions between light and matter. On the site, you can hover your mouse over each theory to find out which light phenomenon corresponds to which.



Physically based rendering uses

geometric optics to simulate the interaction of light, but the first half of the book explains what light is, including some background knowledge and other theories.

◆Electric force
There are two types of electric charges: positive and negative. Charges of the same type repel each other, while opposite charges attract each other. The amount of force acting on two charged particles is calculated using Coulomb's law , where k is a constant, q1 and q2 are the amounts of each charge, and r is the distance between them.



On the site, you can actually move an electric charge and understand how the electric force affects it by looking at the direction and size of the arrows.



The image of

the electric field generated by an electric charge looks like this.



The image is animated, showing the electric field as a color gradient.



Special theory of relativity and magnetism
The site allows you to understand through animations the movement of charges as seen by an observer and the positive charge itself, and the force that acts on charges according to

the special theory of relativity, i.e., magnetism.



◆Maxwell's equations

Maxwell's equations describe how electric and magnetic fields are created and interact: Moving the bar and the magnet inside the coil creates a changing magnetic field that induces a current in the wire, which we can visualize as Maxwell's third equation, or Faraday's Law of Electromagnetic Induction .



According to

Ampere's law , Maxwell's fourth equation, a magnetic field is generated when a current is passed through a coil. Moving the bar changes the voltage, which in turn changes the magnetic field depending on the direction of the current.



Electromagnetic waves
Waves generated by synchronized electric and magnetic fields are called

electromagnetic waves , and they travel at the speed of light in a vacuum. The amplitude of the wave represents the maximum strength of the electric or magnetic field, i.e., the number of photons, and the frequency corresponds to the energy of the photons. Moving the bar changes the wavelength of the electromagnetic wave depending on the amplitude and frequency.



When the wavelength is between approximately 400nm and 700nm, the human eye perceives it as visible light. Moving the bar changes the frequency and color of the electromagnetic waves.



Light Generation
When an electric current is passed through an incandescent light bulb, the resistance of the filament generates heat, and as the electrons in the filament vibrate and collide, they emit photons. This light radiation is classified as

blackbody radiation . On the site, by moving the bar to change the voltage, you can visually see the temperature changes and the process by which light is emitted from the light bulb.



Unlike incandescent bulbs, the light emitted from the sun is produced by

nuclear fusion reactions . In the sun's core, hydrogen nuclei fuse to form helium, which then emits photons as gamma rays. Approximately 49% of the electromagnetic waves emitted from the sun are infrared, 43% are visible light, and the remaining 8% are ultraviolet.



In an LED, when

a P-type semiconductor and an N-type semiconductor are arranged and an electric current is passed through them, light is generated by electroluminescence .



Other light sources are listed in the Wiki's

Luminescence section .

◆Chapter 2: Abstraction of Light
When a photon hits an object, it will either be reflected or refracted. According to the law of reflection, the angle of reflection is equal to the angle of incidence relative to the surface normal. Moving the bar will change the angle of reflection according to the angle of incidence.



The refraction angle is calculated from

the refractive index using Snell's law . By moving each bar, you can visually see how the refraction angle θ2 changes from the incident angle θ1 and the refractive indices n1 and n2.



The amount of reflected and refracted light is determined by

Fresnel's equations , but calculating the entire Fresnel equation in real time can be time-consuming, so in 1994 Christoph Schlick devised an approximation .

First, calculate the reflectance at 0 degrees from the normal.



Next, substitute R0 into the approximate reflectance function.



The magnitude of transmitted light Tθ can be calculated from the magnitude of reflected light Rθ using the formula 'Tθ = 1 - Rθ.' By changing the angle of incidence θ1 of light and the refractive indexes n1 and n2 using the bar, the magnitude of reflected light and the magnitude of transmitted light can be calculated and reflected in the diagram.



The phenomenon in which all light is reflected is called

total internal reflection .



Total internal reflection causes a phenomenon known as

the Snell window . The diagram on the website shows the point where the yellow lines converge, from which the viewpoint is taken, and shows what kind of light is seen converged. By moving the bar, the viewpoint angle changes, and you can see which direction the light can be seen.



If you dive underwater and look up, the light on the surface will be refracted through a 96-degree wide circular window, creating the appearance shown here.



◆Microfacet model
For nanogeometry, on the scale of billionths of a meter,

wave optics can be used to describe how light interacts with matter as light waves that diffract at surfaces. For microgeometry, on the scale of millionths of a meter, geometric optics can be used to describe light as straight rays that reflect and refract at surfaces. Thus, the law of reflection, Snell's law, and Fresnel's equations can be used.

Computer graphics rendering goes even further, down to the pixel, treating each pixel as a microfaceted model containing millions of tiny microscopic surface irregularities, and using statistical averages to simulate the appearance of the surface at that pixel.

The normals of the microfacet model become less aligned as the surface becomes rougher. By moving the bar, you can change the surface roughness, and you can see how the direction of light reflection becomes more distorted as the surface becomes rougher.



Furthermore, the rougher the surface, the more the light rays spread out over a cone, and the size of this cone can be calculated using

the bidirectional reflectance distribution function . By moving the bar, you can see how the cone spreads as the surface gets rougher.



Here, we distinguish between two types of microfacet models: metallic and non-metallic.

◆Metal
In metals, photons are easily absorbed by free electrons within a few nanometers of the surface. Unabsorbed light is reflected evenly across the visible light spectrum, producing a distinctive silvery-gray color. The exceptions are gold, copper,

osmium , and cesium , which absorb specific wavelengths, resulting in their distinctive colors.



Changing the roughness of the metal surface changes the specular reflection, but diffuse reflection does not occur because photons other than the reflected light are absorbed.You can see that when you move the bar to change the surface roughness, the specular reflection changes but diffuse reflection does not occur.



◆Nonmetal
Non-metals include materials that do not conduct electricity, called

dielectrics, such as plastic, wood, glass, water, diamond, and air.



When a photon hits a dielectric material, it is only absorbed if its energy matches the energy of an electron in the object; if it does not, specular reflection occurs. A further phenomenon called diffuse reflection occurs, where light refracts within the dielectric material, interacting with pigments in the material and bouncing around before exiting the surface. Surface roughness affects specular and diffuse reflection. By moving the bar to change the surface roughness, you can see how specular and diffuse reflection change.



◆Spectral distribution
When a red apple is illuminated with white light containing all visible wavelengths,

the anthocyanins in the apple absorb most of the wavelengths, including the violet, blue, and green wavelengths, reducing the intensity of the color. The remaining red wavelengths are scattered from the apple's surface, causing the apple to be perceived as red.



The amount of energy carried at each wavelength in incident light can be graphed using a function called

the spectral power distribution (SPD). For example, below is the SPD of the theoretical illuminant D65 , standardized by the International Commission on Illumination (CIE), which represents the spectrum of average midday light in Western Europe or North America:



Comparing with the SPD of solar radiation

AM0 measured in space before entering the Earth's atmosphere, we can see that there is no drop in the ultraviolet range at AM0.



The SPD for a tungsten incandescent lamp is as follows:



◆Spectral reflectance curve
SPD tells us how much color a light source is made up of, while

a spectral reflectance curve , which shows the percentage of incident light reflected by an object, effectively represents the color of that object. A red apple reflects most light in the red wavelengths, so its spectral reflectance curve looks like this:



The color of an object appears to be the result of a combination of the spectral distribution of the light source and the object's spectral reflectance. If you shine white light on a red apple, the apple will appear red, and the same result can be achieved with red light. However, if you shine green light on it, the rest of the apple, except for the leaves, will not reflect light and will appear black. The site has bars that allow you to adjust the intensity of the red, green, and blue light emitted by the flashlight, and you can see how the red apple will appear according to the SPD.



The reason why a banana appears yellow under white light is because yellow is the composite color obtained by reflecting green and red. When illuminated with only red light, the banana only reflects red, so it appears reddish. This phenomenon, in which a red apple and a yellow banana appear the same red under red light, is called

metamerism .



◆Chapter 3: Rendering Equations
An example of a rendering equation used in physically based rendering.



・Lo(p,ωo): Light emitted from point p in the direction ωo
・Li(p,ωi): Incident light from direction ωi to point p
Bidirectional reflectance distribution function (BRDF): A function that indicates how much of the incident light Li(p,ωi) is reflected at point p in the outgoing direction ωo, and indicates the material.
・Dot product: cosine term

The rendering equation derives the outgoing light Lo reflected at point p towards direction ωo by summing all incoming light Li coming from directions ωi in the hemisphere Ω, weighted by the BRDF at that point and a cosine term.



We will explain this rendering equation item by item.

◆Lambert's cosine law
According to

Lambert's cosine law , when the angle of incidence of the light is perpendicular, the surface area that comes into contact is small, and the more oblique the angle, the larger the area. By moving the bar and changing the angle, the area that comes into contact with the surface changes.



◆Bidirectional reflectance distribution function (BRDF)
The BRDF is the most important part of the rendering equation, it describes the surface of a material and its appearance. Here, microfacet theory and energy conservation can be applied to make the rendering model physically based. It represents the incoming light direction ωi and the outgoing light direction ωo, the surface roughness α, and the diffuse and specular reflection components weighted by the coefficients kd and ks respectively.



There are many types of BRDFs, but the most common for real-time rendering is

the Cook-Torrance specular microfacet model combined with the Lambertian diffuse model.



The Lambertian diffuse component is the diffuse color called

albedo multiplied by a cosine coefficient, but since the cosine coefficient is already in the rendering equation, the equation we need is as follows: where D is the normal distribution function, F is the Fresnel equation, and G is the geometric function.



◆Normal distribution function
The normal distribution function is a function that approximately represents the number of tiny planes oriented to reflect light that is reflected from the incident direction ωi toward the outgoing direction ωo. In this example, we will use the Trowbridge-Reitz GGX function.



ωh is the half vector between the incident and outgoing directions, and is given by:



On the site, you can see how the surface roughness and number of microfacets change as the bar is moved.



◆ Geometric functions
In the diagram below, the red incident light ray is in a state called shadowing, where it cannot bounce back in the direction of emission. The blue incident light ray is blocked on its way to the emission direction, a state called masking. Moving the bar changes the angle of the incident light ray, resulting in changes to the red shadowing light and blue masking light.



These effects are approximated by geometric functions, here we use the Schlick-GGX geometric functions.



The value of k is as follows:



Moving the bar changes the surface roughness, which changes the shadowing and masking effect.



Fresnel equation
For real-time rendering, we use Schlick's approximation, which is fast and sufficiently accurate.



By moving the bar, the reflectivity changes and you can see the change in the intensity of the reflected light.



◆ Putting it all together
These formulas are combined to produce physically based rendering, which the site allows users to visualize by changing the surface roughness, metalness value, and base color on the bars.



Here is a table showing the correlation between the surface roughness of the sphere and the metallurgical value:



Typically, metal values are either 0 or 1, but in physically based rendering it is practical to allow for intermediate values, smoothly interpolating between metal and non-metal, which can be useful for representing rusted metal materials.


The explanations on the site cover the basics, and in the future they will cover effects such as volume rendering, subsurface scattering, optical dispersion, thin film interference, and rainbow colors.

in Software,   Science, Posted by darkhorse_logmk