Rendering
Photorealistic Rendering
Rendering or image synthesis is the process of generating a image from a 2D or 3D model by means of a computer program.
The goal is to create images from 2D or 3D models which are not distinguisible from what we've seen in the real world.
If we can make photorealistic rendering, non-photorealistic rendering can be easily achieved.
Achieving photorealism in computer graphics requires:
- Realistic/detailed geometry of models
- Accurate representations of surface properties (e.g. material)
- Good physical descriptions of the lighting effects
- Good understanding of human perception (Human doesn't perceive absolute value... But they are good at perceiving relative value!)
Local Illumination Models
Only think about light source, eye, and object. (i.e. object illuminations are independent)
Easier, but doesn't compute light between objects.
No light scattering between objects, no shadows, no reflection, no transmission (see through semi-transparant objects).
Global Illumination Models
A surface point can receive light from various sources such as light sources and other objects.
- Ray tracing
- Radiosity
- Photon mapping
Properties of light sources
Linearity
Light source has linearity.
We can easily mix multiple light sources!
But human perceive differently; Human perceive intensity in log scale.
Falloff (attenuation)
As radiant energy travels, its amplitude is attenuated by the factor .
Why? The constant energy is emitted from a light source while the surface area gows with .
Sometimes, more realistic attenuation effects can be obtained with an quadratic function of distance, while also preventing the problem of divergence when the distance is zero.
Lamert's Cosine Law
The amount of light energy received by a surface depends on incoming angle.
This is the reason why we have summer and winter seasons.
Light Sources
We use specific types of light sources in computer graphics.
Color of light sources
We use 3D vector for light's intensity!
Each element represents red's intensity, blue's intensity, and green's intensity.
But actually this is not enough.
Linear combination of finite number of primary colors can't represent every color of light!
We'll just use RGB, but note that this is a approximation!
Point Lights
Point lights emit radiant energy from a single point.
Intensity at a point x on the surface is:
where N is the surface normal vector and L is the direction from x to the point light source.
Directional Lights
Directional lights are point lights that are infinitely far.
Directional lights don't have falloff.
Spotlights
Spotlights are point lights with non-uniform directional emission.
We assume symmetric about a central direction V with angular falloff, so spotlights outside of hotspot will have reduced intensity.
is an angle between L and V, and is an angle of hotspot.
is just a parameter that controls how quickly the falloff should occur.
Area Lights
Area lights emit light from their surface.
In general, computing radiometric quantities (e.g. intensity) related to area lights requires computing integrals over the surface.
However, this can't be computed exactly, so we just approximate it as many point light sources.
c.f. Point lights have sharp shadows, while area lights have soft shadows.
- Umbra: Every light source can't seen
- Penumbra: Some light source can't seen
Rendering point lights have too unrealistically sharp shadows, so we need area lights in practice.
Measuring reflection
BRDF (Bidirectional Reflectance Distribution Function)
There are bidirection reflection, to the incoming direction and to the outgoing direction.
Reflection can be implemented as distribution function.
Given incoming direction and outgoing direction , we define BRDF as .
Instead of direction, we can use spherical coordinates (zenith and azimuth angles).
e.g. If is 1 at specific direction , (dirac delta) we can represent mirror.
In practice, reflection can also change with frequency, so we need 5 parameters.
We can simplify this to computing BRDF only for RGBs.
Isotropic and anisotropic
When and are fixed, material is called isotropic if rotation around the normal does not change the reflectance.
Otherwise, the material is called anisotropic. Anisotropic material have strongly oriented microgeometry elements. (e.g. Aluminum)
Measuring BRDFs
BRDF can be measured with devices.
e.g. Gonioreflectometer measure reflection by changing and .
Note that we have specular reflection part (정반사) and diffuse reflection part (난반사).
Maybe we can parameterize BRDF?
Parametric BRDFs
Actual BRDF need tabulated 5D data, which is too large.
Parametric BRDF models represent the relationship between incident and outgoing light by some mathmatical formula.
Ideal Diffuse Reflectance
Incident light is scattered with equal intensity in all directions.
At the microscopic level, an ideal diffuse surface is a very rough surface. (e.g. chalk, clay, ...)
Light intensity depends on the angle of incidence according to Lambert's cosine law, but is independent of the angle of reflection.
For a single point light source,
where is diffuse coefficient, and is light source intensity.
BRDF for ideal diffuse surface is a constant function!
Ideal Specular Reflectance
Perfect reflector reflects all rights to the direction where angle of reflection is identical to the angle of incidnece.
i.e. This is a mirror!
Light only reflects to the mirror direction.
BRDF is a dirac delta function multiplied by a specular coefficient .
However, ideal specular BRDF is not useful for point light sources.
You can't see light source if you're outside of direction of reflection.
Non-ideal Reflectors
Most of the reflected light travels in the direction of the ideal mirror ray, while some of the light are also reflected around the reflected ray.
If more light is reflected around the ideal mirror ray, the surface becomes blurred.
Phong specular model: For a single point light source,
where is specular coefficient, is light source intensity, is reflected ray direction, is viewing direction, and is shininess parameter. (similar to )
If n is large, surface is shiny. i.e. BRDF is more like dirac delta.
Since , .
Ambient Illumination
In the real world, we can see objects beneath the table even if there is no direct path between the objects and the light sources.
The ambient term represents the reflection of all indrect illumination.
The Complete Phong Illumination Model
Sum of three components:
- Ideal diffuse reflection
- Non-ideal specular reflection
- Ambient
For single light source,
For multiple light source with emission,
Phong Illumination Model is good for representing simple plastics and metals, but cannot represent correctly for other materials like clothes, brushed metals.
Phong Illumination Model is not physically correct!
- Does not even conserve energy, it can reflect more energy than what goes in.
- Does not conform to the BRDF model directly. (cosine for diffuse, but not for specular)
- Ambient was a total hack, doesn't even related to actual light.
But it has been popularly used for real-time rendering (e.g. OpenGL) due to its compactness.
In general, specular reflection makes more use of the color of the light, and diffuse reflection makes more use of the color of the material.
Parameter Choosing Tips
- The sum of reflectance coefficients is usually smaller than 1.
- Try (shininess parameter) in the range [0, 100].
- Usually ambient term is small.
- The material properties in the Phong model of the common material is already calculated.
Fresnel Reflection
Specularity is increased near grazing angles.
But most BRDF models doesn't account for this.
Blinn-Phong variation
Use the halfway vector H between L and V.
It is considered more accurate than Phong model, especially highlight is more pretty?????
BSSRDF
Bidirectional Scattering Surface Reflectance Distribution Function
- In BRDF, light was reflected at the point where the light meets.
- In BSSRDF, light can travel through objects, reflected inside objects, then go out in completely different directions.
If you're really ambitious, you can measure and use BSSRDF!
Surface Rendering
Flat shading
Entire triangle has a solid color!
Problem: Mach band effect
Even when surface have a solid color, we perceive mach bands.
Gouraud shading
- Compute the average unit normal vector at each vertex. (i.e. average of the normal vectors of surfaces touching vertex)
- Illumination is calculated for each vertex
- Values are bi-linearly interpolated within a triangle.
Problem:
- Mach band effect still appears
- Orientation dependence (which two edges should we use?)
Nobody use this anymore....
Phong shading
Similar to Gouraud shading, we compute normal vector at each vertex.
However, instead of interpolating values, (color) we interpolate normal vector, then compute illumination again.
To solve orientation dependence, we use barycentric interpolation.
Better than Gouraud shading, especially Phong shading can render highlights inside surface!
Because Gouraud shading interpolate colors, highlight inside surface is ignored.
Problems with interpolated shading
- Polygon sihouette (If number of polygon is too low, boundary appears)
- Perspective distortion (Not invariant to perspective projection)
- Shared edges (How do we compute normal vector if edges are shared?)