Computer graphics and virtual reality Flashcards
Describe how the Z-buffer algorithm for depth sorting of objets drawn on a computer screen works
It works on pixel level:
- Initiate video memory and a Z-buffer for each pixel on the screen
- depth [x,y]=infinity, refresh[x,y]=I_backround
- Polygons are rendered in an arbitrary sequence
- For each pixel: check if the z-coordinate of the current polygon is less than the stored one:
Ax+By+Cz+D=0, z_x,y=(-(Ax+By+D))/C
- In that case the video memory is updated for the pixel:
z_x,y < depth[x,y] –> depth[x,y]=I_surf
- When all polygons are checked the screen is updated with the color closest to the observer
(se bild!)
Describe aliasing and anti-aliasing
- Aliasing: Sawtooth edges due to low display resolution
- Anti-aliasing: Draw nearby points with a mixture of the background color and the line color
Describe how perspective projection is calculated
- Projects point on the projection plane with similar triangles
- (x_p/d) = (x/(z+d))
- x_p= ((dx)/(z+d))
- y_p = ((dy)/(z+d))
- Object further away appears smaller
Describe how parallel projection is calculated
Simply set z=0
Objects have the same size independent on the distance to the observer
Describe the illumination model
The color in a pixel i affected by:
- The light of the surroundings (ambient light):
—–The same color everywhere
- Point light sources:
—– The color is dependent on distance and orientation to the light source
—– Incoming light can be reflected diffuse or specular
—– The intensity fades with distance
Why is ambient light needed?
- So that surfaces without direct light will not be completely black -> poor realism.
- I = I_a * K_a
- I = light intensity at a certain point
- I_a = color of light source
- K_a = reflection coefficient
Describe point light + diffuse reflection
Light hitting the surface is spred equally in all directions -> placement of the light source influences but not the placement of the observer
- I_d = I_i * K_d * cos(v)
- I_d = I_i * K_d * (L * n)
- I_i = intensity of the light source
- K_d = diffuse reflection coefficient [0,1]
- L = vector for incoming light
- n = surface normal
Describe point light + specular reflection
The appearance of smooth, polished, surfaces is dependent of both the placement of the light source and the position of the observer
- I_s = I_i * K_s * (cos(v))^g
- I_s = I_i * K_s * (R * V)^g
- I_i = intensity of the light source
- K_s = specular reflection coefficient [0,1]
- g = gloss parameter (shininess)
- R = reflection direction, angle = incoming angle
- V = observation direction
What is the complete reflection expression?
- I = I_ambient + [I_diffuse + I_specular]
- I = I_a * K_a + [I_i * K_d(Ln) + K_s(RV)^g]
Describe how rendering over multiple polygon surfaces works
- The illumination models without modification gives the same color over the whole polygon = many pixels gets the same color -> facetted picture - easy to calculate but poor realism. This is called flat shading.
- More sophisticated rendering algorithms gives methods to set different color on different pixels on a polygon -> smoother transition between colors, for example the Gouraud and Phong methods.
Explain the Gouraud method
- Interpolate intensities
- The color of a triangle is calculated at each vertex (corner) with the normal at that corner. The color is then interpolated over the surface of the triangle.
(1) Calculate normal vector for all polygon surfaces
(2) Calculate “mean normal vectors” for the vertices of the polygon
(3) Mean normal + Illumination model -> calculation of intensities (colors) in the vertices
(4) Intensity values are interpolated line by line over the polygon
Describe the Phong method
- Interpolate surface normals
- The normal at the vertices (corners) are interpolated over the surface of the triangle and the color is calculated for each pixel.
- Surface normals are interpolated in the same way as intensities for Gouraud
(1) Calculate normal vector for all polygon surfaces.
(2) Calculate “mean normal vectors” for the vertices of the polygon
(3) Surface normals are interpolated line by line over the polygon
(4) Surface normal + Illumination model -> calculation of intensities (colors) in each pixel