Computer Graphics Final Review
1. Difference between an attribute, a uniform, and a varying variable:
Const - The declaration is of a compile-time constraint. It is also a global variable, which means that it is accessible throughout the program.
Attribute - This only occurs in the vertex shader. Global Variables may change per primitive that are passed from the OpenGL application to the vertex shaders. This is a read-only variable. This is an example here. It can be written to from the host JavaScript/WebGL program.
precision highp float;
attribute vec3 position;
attribute vec3 normal;
uniform mat3 normalMatrix;
uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
varying vec3 fNormal;
varying vec3 fPosition;
void main()
{
fNormal = normalize(normalMatrix * normal);
vec4 pos = modelViewMatrix * vec4(position, 1.0);
fPosition = pos.xyz;
gl_Position = projectionMatrix * pos;
}
These attributes are per-vertex parameters, typically positions, normals, UVs, among others.
Uniform - The next thing is uniform. These are global variables that may change per primitive and are passed from the OpenGL application to the shaders. These are used both in vertex and fragment shaders, examples include the matrices. This is a read-only variable. It can be written to from the host JavaScript/WebGL program.
Varying - This is a variable that is used for interpolated data in both the vertex shader and fragment shaders. It is available for writing in the vertex shader and read-only in the fragment shader. They are essential for passing information down the pipeline, and vary from pixels to pixel. Varying values are interpolated based on the position of the pixel drawn. Most graphics pipelines use bilinear interpolation for this.
This covers question 1. The next question covers Global Illumination. Global Illumination casts a swarm of lights into a scene and in some cases light bounces and gets absorbed into objects. Environment mapping is where we allow a reflective surface to be textured to a colorful environment, and we get to see the textures back. This is part of WebGL. Another WebGL property is known as decal textures, which is basically utilizing multiple textures, which is a fundamental property of many games.
Caustics are a concentration of light that are a consequence of concentration of light via complex refraction patterns. There is a bending of light that enters a glass oval-shaped object and a specific concentration that occurs some of the lines on the other side. This happens when the photons are reflected from the light source. Refraction is the property of light to "bend" depending of the density of material, for example light can appear "shifted" this way, in glass depending on the relative density of air and glass. Dispersion can have a rainbow-colored affect on a back surface/overview of the flow, like the water "egg" on the other side of a picture.
Ray tracing can give an approximation of what can happen, if we assume that after the light emanates from a light source, the first bounce can either be diffuse or specular, but we are making an assumption is that every subsequent reflection is purely specular.
The forward ray tracing is physically intuitive but many rays are wasted, and we need to spawn many rays in order to make sure that the light reaches the camera. Backward ray tracing, in contrast, track rays from the camera and out into the world, hopefully reaching a light source.
A limitation of the ray-tracing algorithm is that it makes a rather crude approximation that all but one of the bounces of a ray are purely specular (i.e. mirror-like).
The next topic that I want to properly discuss is the render-to-texture functionality. We have three tasks: creating the texture in which we’re going to render ; actually rendering something in it ; and using the generated texture. This is particularly effective for mapping both shadows and dynamic environments, which is an object that has constantly changing environment.
Bump mapping is a texture mapping technique in computer graphics for simulating bumps and wrinkles on the surface of an object. A bump map is a texture that encodes the "height offset" of a surface relative to the baseline of an underlying flat model. It requires specific texture mapping units. Its effect on a flat plane goes away if we tilt the bump-mapped plane to the point where it becomes parallel with the viewing direction. It requires using a texture mapping unit, regardless of whether we use texture mapping for color purposes. It creates an illusion of surface roughness by manipulating the surface normal. Pixel tests are utilized for the Z-buffer algorithm.
A Z-buffer is an image by default is set to an extremely large value. For example, we can draw a gray triangle and a colored triangle on top of it. Subsequent drawing calls are only allowed to complete if the depth of the newly written pixel is "nearer". When we clear the screen and depth buffer, it prompts the GPU to resets all the values to infinity. Any value is essentially the absolute value of the Z coordinate of any triangle that manage to find itself on the location and wrote itself on the screen.
To eliminate aliasing we use mip maps, a technique to make textures aesthetically much more pleasing.
We often do texturing in the fragment shader, instead of the vertex shader. Typically for texturing we want to operate at a finer scale than the resolution of each triangle. The vertex shader would just create a smooth color gradient, whereas the fragment shader can present way more detail.
Even if we have diffuse reflection in a specific shader, I would expect to see color variation between the fragments of a single triangle, since if on a map, an object can have different normal vectors at intersections, therefore without straight normal vectors, can result in variation.
Skyboxes don't require the support of multiple texture, neither does the textured object that supports specular reflection. However, to apply shadows and reflect with other images within a scene, this requires render-to-texture. Hierarchically modelled texture doesn't require multi-textured mapping.
Applying decal textures uses multiple textures, as well as creating a bumpmap for faking surface roughness.
Finally, comes the question to dread: To try to figure out what the Ambient lighting coefficient, the diffuse reflection coefficient, the Specular reflection coefficient, and the specular exponent does.
Ambient (or general ) light is typically seen as the starting point for a space or a room. It makes up the "base" amount of light in a room. It affects the overall image and makes it either brighter or darker.
Diffuse light is light that is scattered, causing it to fall on the crop from all sides. The light is evenly distributed, leaving no sharp shadows.
The specular exponent, also know as the Phong Exponent, controls the applied-smoothness to a surface. It results in a more narrow spot. Specular reflection, or regular reflection, is the mirror-like reflection of waves, such as light, from a surface.
This is the original image:
This is after decreasing the diffuse reflection.
After increasing the specular exponent.
After increasing the ambient coefficient.
After decreasing the specular coefficient.



Comments
Post a Comment