Computer Graphics
Provmoment:
Ladokkod:
Tentamen ges för:
7,5 högskolepoäng
Tentamen
NDG011
Systemarkitektprogrammet
Namn:
(Ifylles av student)
Personnummer:
(Ifylles av student)
Tentamensdatum:
Tid:
2013-08-30
09:00 – 14:00
Hjälpmedel:
Inga hjälpmedel
Totalt antal poäng på tentamen:
För att få respektive betyg krävs:
G=21
VG=32
42 poäng
Allmänna anvisningar:
Skriv dina svar på separata blad
Spara alla filer på F: om inte annat specifikt anges
Se till att lösningarna inte har bindningar till filer på C: i andra mappar än specifikt angivna
Stäng ner samtliga applikationer och logga ut (via ikon) när du är klar med tentamen.
Vid olösliga problem med datorkonto, ta ett nytt och lämna in även detta i tentamensmappen.
Rättningstiden är som längst tre veckor
Viktigt! Glöm inte att skriva namn på alla blad du lämnar in.
Lycka till!
Ansvarig lärare:
Telefonnummer:
Rikard König
033 435 5945
Answers (swe. svarsblankett)
Namn:
(Ifylles av student)
Personnummer:
(Ifylles av student)
Question 1:
a)
b)
c)
d)
e)
f)
g)
Question 2:
A
B
C
D
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
a)
b)
c)
d)
e)
f)
g)
Question 3:
A
B
C
D
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
a)
b)
c)
d)
e)
f)
g)
A
B
C
D
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
Question 4:
a)
b)
c)
d)
A
B
C
D
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
Important note:
The minimum result on questions 1 to 4 to pass
is 12 points.
If this is not reached, question 5 to 6 will not be
considered and automatically given 0 points.
2
1. Answer with any of the given answers for the following questions.
(a) What is true about the pinhole camera model shown in the picture below? How
does the synthetic camera model solve this problem?
Alternatives:
A. It results in a projection that is turned upside down.
B. It is also called the synthetic camera model.
C. The projected image cannot be reversed into the original object.
D. It creates an orthographic projection.
(b) Which of the following statements regarding color theory are true?
Alternatives:
A. The human visual systems as three types of sensors for color.
B. Only colors received by the “cones” are needed to display an image in truthful colors.
C. Magenta, Cyan and Yellow are the primary colors of the subtractive color system.
D. The subtractive color system is the basis for computer games.
(c) What is true about local lighting?
Alternatives:
A. It calculates shadows perfectly.
B. It calculates reflections perfectly.
C. It leads to fast hardware implementation.
D. Today it has been replaced by the global lighting model.
(d) Which of the following matrices (when applied to row vectors) will perform a
positive translation along the Z-axis?
Alternatives:
A
1
0
0
0
0
1
0
0
0
0
0,8
0
B
0
2
0
1
1 0
0 1
0 0
0 1,2
C
0
0
0,9
0
0
0
0
1
1
0
0
0
3
0
0,6
0
0
D
0
0
1
1
0
0
0
1
1
0
0
0
0
1
0
0
0 0
0 0
1 1,8
3 0,3
(e) What is in general true of algorithms used in computer graphics?
Alternatives:
A. It is very preferable if the operations of the algorithm can be done in a pipeline.
B. They try to avoid divisions since division are computationally expensive compared to
addition and subtraction.
C. Pipelines increase the time of calculation of a single element.
D. They priorities simplicity before performance.
(f) What is the result of multiplying the Matrices X and Y?
X
2
3
1
2
Y
2
1
0
2
2 * 1
3
0
1
1
3
2
2
1
1
1
2
2
3
2
Alternatives:
A
B
C
11 9 7 12
11 12 11 17
11 9 7 12
11 12 15 17
10 9 7 12
11 12 15 17
11
11
D
9
11
7 14
11 17
(g) What is true regarding Liang-Barsky (LB) Clipping?
Alternatives:
A. LB can accept as easily as with Cohen-Sutherland without division
B. LB can reject as easily as with Cohen-Sutherland without division
C. LB does not extend to 3D
D. LB has to be used recursively
(7p)
4
2. Answer with any of the given answers for the following questions.
(a) The Hidden-surface-removal problem can be suitably solved using the _____ ?
Alternatives:
A. Clipping and Visibility approaches.
B. Interpolation and Culling approaches.
C. Object-space and Image-space approaches.
D. Rasterization and Scan-Line approaches.
(b) Two hard cases when applying depth-sort for use with painters algorithm are
_____ ?
Alternatives:
A. All z-coordinates of an object are behind the corresponding coordinates of all other
objects, and when one object penetrates the surface of another object.
B. Cyclic overlap of three or more objects, and when one object penetrates the surface
of another object.
C. All z-coordinates of an object are behind the corresponding coordinates of all other
objects, and when two object overlaps in the z-coordinate but not in the others.
D. Cyclic overlap of three or more objects, and when two object overlaps in the zcoordinate but not in the others.
(c) The main three mapping methods that are considered are _____ ?
Alternatives:
A. Texture, Image and Pixel mapping.
B. Texture, Polygon and Bump mapping.
C. Texture, Environment and Bump mapping.
D. Texture, Bilinear and Reflection mapping.
(d) Applying polygons on the z-buffer algorithm can be done _____ ?
Alternatives:
A. Efficient if observing the constants of the plane equation in respect to pixels.
B. Inefficient as polygons then need to be rasterized.
C. Efficient if first performing a depth-sort of the polygons.
D. Inefficient as polygons can overlap in a cyclic overlap.
5
(e) Two-part mapping works by _____ ?
Alternatives:
A. First mapping the 2D image to a 3D surface and then mapping the surface to the
screen window.
B. First mapping to an intermediate shape as a box, sphere or cylinder and then to the
actual shape.
C. First performing a pass with calculating the vectors and then performing a second
pass with calculating the actual pixels.
D. Allowing complex objects that consists of two or more shapes to be drawn by finding
the inverse s() and t() functions.
(f) Bresenham’s algorithm is efficient for drawing lines as it _____ ?
Alternatives:
A. Only have three candidate pixels in the y-axis for each x pixel.
B. Requires only integer arithmetic.
C. Requires only one floating-point operation per pixel.
D. Does not need any additional solution for solving the problem with steep lines.
(g) From an high overview, a non-hierarchical model is basically made up of _____ ?
Alternatives:
A. Graphs and Edges.
B. Meshes and Transformations.
C. Bones and Meshes.
D. Symbols and Instances.
(7p)
6
3. Consider the Blinn-Phong shading equation
at a fragment with normal n and the material
parameters cd, cs (colors) and m (shininess). The
direction towards the directional light source is l
and the direction to the viewer is v.
l
n
v
Answer with one or more of the given answers for the following questions.
(a) To compute the specular color term of the modified Blinn-Phong shading equation
for a fragment ____ (among other things) is needed?
Alternatives:
A. The shininess m of the material.
B. The direction towards the viewer v.
C. The specular color cs of the material.
D. The normal n at the fragment.
(b) To compute the diffuse color term of the modified Blinn-Phong shading equation
for a fragment ____ (among other things) is needed?
Alternatives:
A. The light intensity that is emitted by the emissive material.
B. The diffuse color cd of the material.
C. The intensity of light emitted by the directional light source.
D. The direction towards the viewer v.
(c) To compute the ambient color term of the modified Blinn-Phong shading equation
for a fragment ____ (among other things) is needed?
Alternatives:
A. The intensity of light emitted by the directional light source.
B. The specular color cs of the material.
C. The diffuse color cd of the material.
D. The normal n at the fragment.
(d) The required minimal output of a vertex shader is _____?
Alternatives:
A. The vertex position in clip coordinates.
B. The vertex color in RGBA.
C. The vertex texture coordinates.
D. The vertex position in the world frame.
7
(e) Which of the following statements is/are valid regarding drawing objects with
opaque and translucent meshes?
Alternatives:
A. The order in which opaque meshes are drawn affects the final result.
B. The order in which translucent meshes are drawn affects the final result.
C. A material with an alpha value close to 0 is almost completely transparent.
D. A material with an alpha value close to 0 is almost completely opaque.
(f) Which of the following statements is/are valid for bump mapping?
Alternatives:
A. It gives the appearance of small surface details using geometry.
B. New additional vertices are created by the vertex shader.
C. It modifies the normal used by the shading equation at each fragment.
D. It uses a normal map texture to model the environment surrounding the mesh.
(g) Which of the following statements is/are valid for environment mapping?
Alternatives:
A. The normal and the direction to the light source are used for lookups in the
environment map texture.
B. Environment mapping cannot be combined with bump mapping.
C. The normal and the texture coordinates are used for lookups in the environment
map texture.
D. Environment mapping is implemented by mapping the distant surrounding
environment in the scene to a cube map texture.
(7p)
8
4. Answer with one of the given answers for the following questions.
Consider the following HLSL effect file:
uniform const float4x4 World;
uniform const float4x4 View;
uniform const float4x4 Projection;
// Eye position in the world frame.
uniform const float3 EyePosition;
// Material information from the application
uniform const float4 DiffuseColor;
uniform const float3 SpecularColor;
uniform const int
SpecularPower;
uniform const texture T;
sampler TSampler = sampler_state
{
Texture = (T);
MipFilter = Linear;
MinFilter = Linear;
MagFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
};
// Lighting information from the application in the world frame
uniform const float3 AmbientLightIntensity;
uniform const float3 DirectionalLightDirection;
uniform const float3 DirectionalLightDiffuseIntensity;
uniform const float3 DirectionalLightSpecularIntensity;
// Fog settings
uniform const float
uniform const float
uniform const float
uniform const float3
FogEnabled;
FogStart;
FogEnd;
FogColor;
struct VertexShaderInput
{
float4 A : POSITION0;
float3 B : NORMAL0;
float3 C : TANGENT0;
float2 D : TEXCOORD0;
};
struct VertexShaderOutput
{
float4 A : POSITION0;
float3 B : TEXCOORD0;
float3 C : TEXCOORD1;
float3 D : TEXCOORD2;
float2 E : TEXCOORD3;
};
9
VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
VertexShaderOutput output;
float4 v1 = mul(input.A, World);
float4 v2 = mul(v1, View);
output.A = mul(v2, Projection);
output.B = mul(input.B, World);
output.C = mul(input.C, World);
output.D.xyz = v1.xyz;
output.E = input.D;
return output;
}
float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
{
float4 c1 = DiffuseColor * tex2D(TSampler, input.E);
float3 c2 = SpecularColor;
float k1 = SpecularPower;
float4 c3 = 0.0;
c3.rgb = c1.rgb * AmbientLightIntensity;
float3 v1 = normalize(input.B);
float3 v2 = normalize(input.C);
float3 v3 = cross(v1, v2);
float3 v4 = 2.0*float3(0.0, 0.0, 1.0) - 1.0;
float3 v5 = normalize(v4.x*v2 + v4.y*v3 + v4.z*v1);
float3 v6 = -DirectionalLightDirection;
float3 v7 = normalize(EyePosition.xyz - input.D.xyz);
float3 v8 = normalize(v6 + v7);
float3 c4 = DirectionalLightDiffuseIntensity;
float k2 = saturate(dot(v6, v5));
float4 c5 = float4(k2*c1.rgb*c4, c1.a);
float3 c6 = DirectionalLightSpecularIntensity;
float k3 = 1.0;
if (k2 == 0.0) k3 = 0.0;
float4 c7 = float4(k3*c6*c2*pow(saturate(dot(v5, v8)), k1), 0);
return saturate(c3 + c5 + c7);
}
technique Technique1
{
pass Pass1
{
VertexShader = compile vs_3_0 VertexShaderFunction();
PixelShader = compile ps_3_0 PixelShaderFunction();
}
}
10
(a) Which of the following statements is true?
Alternatives:
A. The effect implements normal and environment mapping
B. The effect implements neither normal nor environment mapping.
C. The effect implements environment mapping.
D. The effect implements normal mapping.
(b) Which of the following statements is true?
Alternatives:
A. The effect implements fog.
B. The effect uses a gloss map texture.
C. The effect uses a gloss map texture and implements fog.
D. The effect neither uses a gloss map texture nor implements fog.
(c) The field A in the VertexShaderOutput struct is ____?
Alternatives:
A. The clip coordinates of the vertex.
B. The texture coordinates of the vertex.
C. The world frame position of the vertex.
D. The tangent in the world frame of the vertex.
(d) Which of the following statements is true about the PixelShaderFunction?
Alternatives:
A. The function is actually not used by this effect.
B. The function implements distance based fog.
C. The function will shade both sides of a mesh drawn with cull mode set to none
correctly.
D. The function implements the diffuse contribution of Blinn-Phong shading.
(4p)
11
5. Create a program that displays a box in the middle of the screen. The box should be able
to rotate rotating around the origin of the world (0,0,0) (x-, y- and z-axis) when the x, y
or z buttons are pressed. The box should be defined in a separate class and should be
drawn using indexed vertices that are uploaded to the GPU using vertex buffers.
Drawing the box without indexing and uploading the vertices to the GPU can result in
maximum 4p.
(7p)
12
6. Create a program using XNA that displays a road, with a moving snowplow placed on
it. The road should be dynamically created by tiling together a given texture
(“roadtile.jpg”) , where each road-tile is a separate mesh. Each road-tile should
be about half the length of the snow-plow. The road should increase with another
added tile, while the snowplow is moving along the road. The snowplow should be
loaded as a model (”snowplow.fbx”) and while moving along the road the
snowplow should relatively move at least one part (bone) in some pattern. The camera
could be static, but should be placed such that it is clearly visible for at least 10
seconds to see the animated snowplow moving along the road which is dynamically
increasing in length tile by tile. The snowplow should move forward along the road
with a speed about 1 tile per second.
The necessary binary contents are provided in a directory on your account.
As a helping reminder, the basic algorithm for drawing a model is outlined as follows:
foreach(ModelMesh mesh in model.Meshes) {
foreach(BasicEffect effect in mesh.Effects) {
// fix effect
}
mesh.Draw();
}
(7p)
13
© Copyright 2026 Paperzz