B.Sc. in Computing in Computer Games Development – Year 3 January 2011 Letterkenny Institute of Technolo gyCourse Code: PROG K7B01 Subject: Graphics Programming for Games II Stage: Award Date: January 2011 Examiners: Mr. Dermot HegartyDr. M. McNeill Time allowed: 2 hours INSTRUCTIONS Answer any THREE questions from four All questions carry equal marks There are Appendices at the end of the examination paper containing information which may be useful in answering questions Graphics Programming for Games II Page 1 of 14 BACHELOR OF SCIENCE IN COMPUTING IN COMPUTER GAMES DEVELOPMENT
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
8/3/2019 Graphics Programming for Games II Jan 2011
B.Sc. in Computing in Computer Games Development – Year 3 January 2011
Question 1
(a) Explain how blending is achieved using OpenGl. Note that Appendix Agives an example of simple two-dimensional blending.
(6 marks)
(b) For three-dimensional blending we should implement the followingsequence of events:Draw opaque objects first. Then make depth buffer read-only and draw translucent objects.(i) Explain why opaque objects must be drawn before transparent
objects.(2 marks)
(ii) What is the purpose of making the depth buffer read-only?(4 marks)
(c) Appendix B shows some code that uses a display list and shows theresulting display.(i) Using the appendix as an example, give a detailed explanation of
OpenGL display lists and how they can be used improveperformance (frame rate, for example). In your answer, explainwhy the drawing of the four green larger triangles will requiremuch more overall processing effort than the triangles in thedisplay list. Hints: immediate mode, retained mode; what getssent to the graphics card and when?
(9 marks)
(ii) Change the code such that the display list contains the fivetriangles, i.e. no need for the ‘for(i = 0; i < 5; i++)’
loop.(4 marks)
Graphics Programming for Games II Page 2 of 14
8/3/2019 Graphics Programming for Games II Jan 2011
B.Sc. in Computing in Computer Games Development – Year 3 January 2011
Question 2
(a) The figure above gives a visual depiction of the OpenGL graphicspipeline.Are shaders concerned with clipping? Explanation of your answer shouldmake reference to the diagram.
(3 marks)
(b) List the steps taken to provide shaders in an OpenGL applicationprogram.
(6 marks)
(c) Give brief explanations for the follow types of variables in GLSL: varying,uniform.
(4 marks)
(d) Give the code for a pass-through vertex shader and a pass-throughfragment shader.
(6 marks)
(e) Below is a vertex shader and an associated fragment shader. Explainwhat each shader does and what the overall effect is.
(6 marks)
vertex shader :
varying vec3 normal;
void main()
{
normal = gl_NormalMatrix * gl_Normal;
gl_Position = ftransform();}
Graphics Programming for Games II Page 3 of 14
8/3/2019 Graphics Programming for Games II Jan 2011
B.Sc. in Computing in Computer Games Development – Year 3 January 2011
Question 4
Note: Appendix D contains equations and geometry related to the PhongLighting Model. You may find this useful.
(a) Appendix C shows code which produces a sphere, cone and teapot withdemonstrating lighting.Use it to explain OpenGL’s simulation of lighting and materialreflectivity. In your explanation, make sure to cover the essentialdifferences between ambient, diffuse, and specular reflection; mentionthe roles of normals in OpenGL programs such as the one given; mentionhow OpenGL combines lighting contributions.
(12 marks)
(b) Write the few lines of code would make the SolidSphere (from part a)into a red ball and much less shiny than it is now, but not completelymatte.
(3 marks)
(c) Given the code fragment below, and, considering ambient and diffuseonly, explain what will be the colour (shade) at vertex vf[0]. Assumethat the light direction is in the direction of the normal; no attenuation.You should carefully explain your calculations. Your answer should be anRGB triple.