Lab assignments

Spirit of the Labs

Be aware that the purpose of the labs goes beyond developing your graphics (and mathematics) programming skills to testing your general methodology and approach to problem solving, in addition to autonomy and presentation. These are crucial at Master level and beyond. Important concepts include:

1) Programming methodology: The ability to fix bugs in a methodological manner rather than through trial and error processes. In computer graphics programming, this typically involves developing intuitive knowledge of the underlying maths, perhaps through the use of pen and paper, before even approaching the keyboard or programming aspects.

2) Flexibility and robustness to error: Real-world problems are never defined clearly or perfectly. You will encounter errors and ambiguities and must develop ways to deal with them. Spotting them is a good way to start, and involves step 1) above.

3) Research: Carefully reading and understanding instructions rather than attempting to carry them out by rote. Be aware that all of the details you need to solve the labs are available through careful planning and reading of the instructions on these pages, as well as in the lectures. The labs reward students who listen and plan rather than jumping straight into the lab work.

4) Reporting and soft skills: You should be able to report your approach and present your results in an ordered and succinct manner that clearly communicates your approach, problems encountered, solutions and summarises your results. 

5) Proactive communication: Asking for help at help sessions, starting threads in the forums or determining your own strategy for seeking feedback and solving problems.

Materials

You should do three lab assignments in total. Lab assignment 1 is mandatory. The specific lab 2 and lab 3 assignments that you do depends on the lab track that you decide to take. There are two options: either rendering (lab track 1) or real-time animation (lab track 2).

Lab 1: Set-up and Introduction to 2D and 3D Graphics
Lab 1 Instructions (read this first)
Lab 1 Source code

and

Lab track 1: Rendering

Lab 2: Raytracing
Lab 2 Instructions (read this first)
Lab 2 Source code

A gallery of (mistaken) art work for this lab from previous years is available here.

Lab 3: Rasterisation
Lab 3 Instructions
Lab 3 Source code

or

Lab track 2: Real-time animation

Lab 2: Transformations
Lab 2 Instructions
Lab 2 Source code

Link to updated particle system code for Visual Studio 2017, Win 10. 

Lab 3: Hierarchical Transformations
Lab 3 Instructions
Lab 3 Source code

Update: If you are using Mac OS or Linux, I would recommend to do the 'Special Unity Track' below since Lab3 will need some Windows functions to display particle systems.

If you are generating projects using cmake on Windows, new source code for Lab2 and Lab3 are posted here.

Note that the labs can be set up with the development tool/IDE, environment and platform of your choice. Examples include GCC and Visual Studio. There are a large number of combinations of the aforementioned that may result in idiosyncratic build problems, so you will need to conduct the set up for your own specific configuration. In some cases, setting up the labs for the first time may be non-trivial if you haven't built projects in that particular development environment before. The hints and tips section here may be useful for some help with this.

Note that an older version of SDL is used in order to avoid set up issues with different platforms. If somebody creates a stable build using the latest version of SDL for the main platforms/development environments (and updates the instructions accordingly), I will be happy to upload it as a future option (and you will of course be credited for it).

Special Unity Animation Lab Track

This year, we offer an experimental Unity version for Track 2 Animation. We're interested in your feedback. You are very welcome to give suggestions to the new lab track. 

The Unity version I used to create the labs is 2018.3.2f1. It is recommended to use the same version since Unity has bad consistency with older versions.

Lab track 2: Unity version

Lab 2: Transformations and Particle System
Lab 2 Instructions
Lab 2 Source Unity package

Lab 3: Collision Detection and Level of Details
Lab 3 Instructions
Lab 3 Source Unity package

Note that you should do the tasks described in the instructions under the sections named 'Tasks'.

Submission

Submission of all the lab assignments is due 18th May 2020 as a single .zip or .rar archive with an appropriate directory structure.

The recommended documentation is a well-presented, two to four page document per lab detailing your implementation methods (your approach to completing the lab), experiences (problems encountered, solutions) and outputs (summary of what worked and what did not; also screenshots of the various stages of lab completion).

It should not contain many theoretical details or excessive code - source code comments can be added separately. If you worked in a group, group members should be clearly listed with contact details and there should also be a short section describing the contributions of each group member.

The submission materials should consist of source code, executable and documentation for each of the three labs.

Lab submission will be conducted through Canvas (Canvas links here).

Note: If you cannot log into Canvas when you click on the link above, then you probably need to be registered to it (this does not relate to your registration on the course). In this case, send the course responsible an email with subject line "DH2323 need Canvas access" from your official KTH emails address and you will be added to the system.

Teacher Christopher Peters created page 9 March 2015

commented 19 April 2015

Making the program compile with optimization flags gave me a great speed boost (getting real time rendering for the first part with 600x600 pixels); You can do it by adding this to CMakeLists.txt

set(CMAKE_CXX_FLAGS "-O2")

(and regenerating your Makefile with "cmake CMakeLists.txt")

commented 20 April 2015

Good suggestion on the optimizer. I improved from 25 to 80 FPS on the gradient. Rough FPS numbers, but definitely a 2-3 speed improvement.

commented 25 April 2015

For the third assignment, W2 and H2 in equations 3 and 4 should be respectively replaced by W/2 and H/2.

commented 25 April 2015

If you want to get the same rendering as the one the subject, you can replace the global variable vec3 lightPower = 1.1f*vec3( 1, 1, 1 ); in section 6.1 by vec3 lightPower = 14.f*vec3( 1, 1, 1 ); (very dark otherwise :') )

Teacher commented 27 April 2015

Good hints and tips above. You might also want to see this page:

https://www.kth.se/social/course/DH2323/page/lab-hints-and-tips/

I have a feeling that not everybody is aware of it!

commented 27 April 2015

I have a question regarding the requirement of an executable. Currently, I'm working in an OS X environment which means I am creating mac native builds (.app "executables"). Do I have to fix a windows partition and install, say, visual studio or would the source code and lab report suffice? 

Teacher commented 27 April 2015

For this, please include the source code, lab report and OS X executable (.app or equivalent). Also (regardless of what OS you are using) make sure to include plenty of screenshots of your working program.

commented 4 May 2015

I was wondering about the rotation in Lab 3.
I cant get the rotation to work with a whole loop around the camera.
it gets stuck when the room is behind the camera, and when we try to move forward it slows down and does not get trough the wall in front of it.

We use the same code as in lab 2, and it worked there....

Anyone that can help us?
Or is there going to be a Lab help sessions this week?

commented 4 May 2015

I had some similar issues with clipping in Lab 3. This might explain your problems or be a part of it.

One major difference is that Lab 2 originates with pixels that we know are on the screen.

Here in lab3, we can end up with vertice coordinates far outside the screen in any direction. For me, it meant that triangles disappears if I move/rotate one of their vertices outside of screen. Haven't solved that yet, but expect to clip pixels that go outside screen.

commented 4 May 2015

It says the following in lab instructions.

"When you move around with the camera you might notice that there are problems if the vertices are behind the camera. This is actually a bit tricky to fix and nothing you need to do for this lab. The solution to the problem is to perform clipping of the triangles before they are drawn. Clipping is a topic that could be studied in the optional project."

commented 4 May 2015

Good! Then it's safe to leave it there.

I traced my crashes to VertexShader() though. Can get very small z values --> scaled away far out of screen when getting too close. Guess it creates *very* long lines that takes forever to draw and sometimes breaks the stack.

When I clamped x, y into the screen range the crashes disappeared. Looks a bit strange when the lines get stuck at the screen edge, but acceptable.

Christopher Peters edited 7 May 2015

Materials There are three labs in total. A gallery of (mistaken) art work from the previous year is available here (you may need to reload the page in order for it to be correctly displayed).

Note that the following labs can be set up with the development tool/IDE, environment and platform of your choice. Examples include GCC and Visual Studio. There are a large number of combinations of the aforementioned that may result in idiosyncratic build problems, so you will need to conduct the set up for your own specific configuration. In some cases, setting up the labs for the first time may be non-trivial if you haven't built projects in that particular development environment before. The hints and tips section here may be useful for some help with this.

Lab 1: Set-up and Introduction to 2D and 3D Graphics Lab 1 Instructions(read this first)Lab 1 Source codeLab 2: RaytracingLab 2 Instructions (read this first)Lab 2 Source codeLab 3: RasterisationLab 3 Instructions Lab 3 Source code

Note that an older version of SDL is used in order to avoid set up issues with different platforms. If somebody creates a stable build using the latest version of SDL for the main platforms/development environments (and updates the instructions accordingly), I will be happy to upload it as a future option (and you will of course be credited for it).

Submission Submission of the labs is due on Friday 8th May 2015 as a single .zip or .rar archive with an appropriate directory structure (the Bilda lab submission system will be opened nearer to the submission datcan be reached here).The recommended documentation is a well-presented, two to three page document per lab detailing your implementation methods (your approach to completing the lab), experiences (problems encountered, solutions) and outputs (what worked, what did not, screenshots). It should not contain many theoretical details or excessive code - source code comments can be added separately. If you worked in a group, group members should be clearly listed with contact details and there should also be a short section describing the contributions of each group member.

The submission materials should consist of source code, executable and documentation for each of the three labs. Lab submission will be conducted through Bilda, under 'Event -> Assignments -> DH2323 DGI15 Lab assignment submission'. Note that Bilda is not yet open for submissions Bilda lab submission can be reached here.

Christopher Peters edited 7 May 2015

Materials There are three labs in total. A gallery of (mistaken) art work from the previous year is available here (you may need to reload the page in order for it to be correctly displayed).

Note that the following labs can be set up with the development tool/IDE, environment and platform of your choice. Examples include GCC and Visual Studio. There are a large number of combinations of the aforementioned that may result in idiosyncratic build problems, so you will need to conduct the set up for your own specific configuration. In some cases, setting up the labs for the first time may be non-trivial if you haven't built projects in that particular development environment before. The hints and tips section here may be useful for some help with this.

Lab 1: Set-up and Introduction to 2D and 3D Graphics Lab 1 Instructions(read this first)Lab 1 Source codeLab 2: RaytracingLab 2 Instructions (read this first)Lab 2 Source codeLab 3: RasterisationLab 3 Instructions Lab 3 Source code

Note that an older version of SDL is used in order to avoid set up issues with different platforms. If somebody creates a stable build using the latest version of SDL for the main platforms/development environments (and updates the instructions accordingly), I will be happy to upload it as a future option (and you will of course be credited for it).

Submission Submission of the labs is due on Friday 8th May 2015 as a single .zip or .rar archive with an appropriate directory structure (Bilda lab submission can be reached here).The recommended documentation is a well-presented, two to three page document per lab detailing your implementation methods (your approach to completing the lab), experiences (problems encountered, solutions) and outputs (what worked, what did not, screenshots). It should not contain many theoretical details or excessive code - source code comments can be added separately. If you worked in a group, group members should be clearly listed with contact details and there should also be a short section describing the contributions of each group member.

The submission materials should consist of source code, executable and documentation for each of the three labs. Lab submission will be conducted through Bilda, under 'Event -> Assignments -> DH2323 DGI15 Lab assignment submission'. Bilda lab submission can be reached here.

Note: If you cannot log into Bilda when you click on the link above, then you probably need to be registered there. In this case, send the course responsible your official details (including KTH email address) and you will be added to the system.¶

Christopher Peters edited 7 May 2015

Materials There are three labs in total. A gallery of (mistaken) art work from the previous year is available here (you may need to reload the page in order for it to be correctly displayed).

Note that the following labs can be set up with the development tool/IDE, environment and platform of your choice. Examples include GCC and Visual Studio. There are a large number of combinations of the aforementioned that may result in idiosyncratic build problems, so you will need to conduct the set up for your own specific configuration. In some cases, setting up the labs for the first time may be non-trivial if you haven't built projects in that particular development environment before. The hints and tips section here may be useful for some help with this.

Lab 1: Set-up and Introduction to 2D and 3D Graphics Lab 1 Instructions(read this first)Lab 1 Source codeLab 2: RaytracingLab 2 Instructions (read this first)Lab 2 Source codeLab 3: RasterisationLab 3 Instructions Lab 3 Source code

Note that an older version of SDL is used in order to avoid set up issues with different platforms. If somebody creates a stable build using the latest version of SDL for the main platforms/development environments (and updates the instructions accordingly), I will be happy to upload it as a future option (and you will of course be credited for it).

Submission Submission of the labs is due on Friday 8th May 2015 as a single .zip or .rar archive with an appropriate directory structure (Bilda lab submission can be reached here).The recommended documentation is a well-presented, two to three page document per lab detailing your implementation methods (your approach to completing the lab), experiences (problems encountered, solutions) and outputs (what worked, what did not, screenshots). It should not contain many theoretical details or excessive code - source code comments can be added separately. If you worked in a group, group members should be clearly listed with contact details and there should also be a short section describing the contributions of each group member.

The submission materials should consist of source code, executable and documentation for each of the three labs. Lab submission will be conducted through Bilda, under 'Event -> Assignments -> DH2323 DGI15 Lab assignment submission'. Bilda lab submission is available here.

Note: If you cannot log into Bilda when you click on the link above, then you probably need to be registered there. In this case, send the course responsible your official details (including KTH email address) and you will be added to the system.

commented 8 May 2015

Hi!

We are having a bit of a trouble trying to figure out how the rotation of the camera in lab 2 is supposed to look like. Is it supposed that the camera should move around the y=0 axis in a circular motion or is it supposed to just rotate around its own axis or should the camera move in the circular motion and rotate around its own axis at the same time?

commented 8 May 2015

I rotated the camera around its own axis.

Circular motion is more complex and I think it will give less useful control of the camera.

commented 9 May 2015

What exacly do you expect us to write in the documentation for each of the three labs?

commented 10 May 2015

I also wonder this. How much detail are you putting into the documentation? I kind of feel that I'm writing too much since I'm not sure of what's important and not

Teacher commented 10 May 2015

To give you some guidelines, generally 3-4 pages for each report tends to be fine (including screenshots). Typically, lab 2 and lab 3 reports are longer than those for lab 1, since they involve more tasks.

In terms of content, you mainly describe your process, outcomes and problems encountered, and include screenshots to illustrate your process and outcomes visually. It would also help to clearly mention at the beginning if you managed to get everything in the lab working.

commented 10 May 2015

Ohh, okay, I thought the report and a documentation were 2 separate things... :P

Then I've been done since Friday. :)

commented 10 May 2015

Okay, thanks, then I have a better understanding. But, for instance, would it be preferred to write about the thought process for the creation of, say, the ClosestIntersection function in lab 2 instead of the math behind it?

commented 11 May 2015

I want to submit the labs now, but the submission on Bilda is closed. Is it going to open again or should I mail it?

commented 11 May 2015

Hi everybody!

We are now working on lab3 but we are experiencing some problem with the Interpolate function. "step" translates everything from float to int so we only get 0 or 1 as values which results in a distorted picture. Have anyone else had the same problem and know what to do?

It says that we should use "vec2" in the instructions but that type does not exist for us so we use "ivec2" instead which we know is not right to use in this case.

commented 11 May 2015

I guess it's a result from using ivec2. Add "using glm::vec2;" as done with vec3 (which is what I did) or refer to vec2 by adding glm:: at each vec2 instansiation/initialization

Teacher commented 13 May 2015

For those who did not manage to submit by the original deadline: Bilda will reopen again in the coming weeks, so you should submit then. Assignments should only be submitted via Bilda (i.e. should not be emailed).

commented 23 June 2015

Hi! Do you know when the lab assignments will be input in the KTH grading system?

Thanks!

Teacher commented 24 June 2015

For those of you who submitted around the lab and project deadlines, your official course grades should be available. If this is not the case, please send me an email ASAP so that I can check.

commented 29 March 2016

For Lab 2, I'm not 100% sure if my results match yours. I see that the example of Ray Tracing is not square, whereas the skeleton gives us a 500x500 canvas, so maybe that's what is making it hard for me to compare. Does this look close enough to be correct or is this reminiscent of some error?

Lab2Output

Christopher Peters edited 30 March 2016

Spirit of the Labs Be aware that the purpose of the labs goes beyond developing your graphics (and mathematics) programming skills to testing your general methodology and approach to problem solving, in addition to autonomy and presentation. These are crucial at Master level and beyond. This includes:

1) Programming methodology: The ability to fix bugs in a methodological manner rather than through trial and error processes. In computer graphics programming, this typically involves developing intuitive knowledge of the underlying maths, perhaps through the use of pen and paper, before even approaching the keyboard or programming aspects.

2) Flexibility and robustness to error: Real-world problems are never defined clearly or perfectly. You will encounter errors and ambiguities and must develop ways to deal with them. Spotting them is a good way to start, and involves step 1) above.

3) Research: Carefully reading and understanding instructions rather than attempting to carry them out by rote. Be aware that all of the details you need to solve the labs are available through careful planning and reading of the instructions on these pages, as well as in the lectures. The labs reward students who listen and plan rather than jumping straight into the lab work.

4) Reporting and soft skills: You should be able to report your approach and present your results in an ordered and succinct manner that clearly communicates your approach, problems encountered, solutions and summarises your results. 

5) Proactive communication: Asking for help at help sessions, starting threads in the forums or determining your own strategy for seeking feedback and solving problems.

Materials There are three labs in total. A gallery of (mistaken) art work from the previous year is available here.¶ ¶ Note that the followingThe specific lab 2 and lab 3 that you do depends on the lab track that you decide to take. There are two options: rendering or real-time animation. ¶

Lab 1: Set-up and Introduction to 2D and 3D Graphics Lab 1 Instructions(read this first)Lab 1 Source code¶

A gallery of (mistaken) art work from the previous year is available here.¶

Lab track 1: RenderingLab 2: RaytracingLab 2 Instructions (read this first)Lab 2 Source codeLab 3: RasterisationLab 3 Instructions Lab 3 Source code¶

Lab track 2: Real-time animation¶

Lab 2: TransformationsLab 2 Instructions (read this first)Lab 2 Source code¶

Lab 3: Hierarchical TransformationsLab 3 Instructions Lab 3 Source code¶

Note that the
labs can be set up with the development tool/IDE, environment and platform of your choice. Examples include GCC and Visual Studio. There are a large number of combinations of the aforementioned that may result in idiosyncratic build problems, so you will need to conduct the set up for your own specific configuration. In some cases, setting up the labs for the first time may be non-trivial if you haven't built projects in that particular development environment before. The hints and tips section here may be useful for some help with this.

Lab 1: Set-up and Introduction to 2D and 3D Graphics Lab 1 Instructions(read this first)Lab 1 Source codeLab 2: RaytracingLab 2 Instructions (read this first)Lab 2 Source codeLab 3: RasterisationLab 3 Instructions Lab 3 Source code¶ Note that an older version of SDL is used in order to avoid set up issues with different platforms. If somebody creates a stable build using the latest version of SDL for the main platforms/development environments (and updates the instructions accordingly), I will be happy to upload it as a future option (and you will of course be credited for it).

Submission Submission of the labs is due inaround early May 2016 as a single .zip or .rar archive with an appropriate directory structure (Bilda lab submission will open nearer to the submission date).The recommended documentation is a well-presented, two to three page document per lab detailing your implementation methods (your approach to completing the lab), experiences (problems encountered, solutions) and outputs (what worked, what did not, screenshots). It should not contain many theoretical details or excessive code - source code comments can be added separately. If you worked in a group, group members should be clearly listed with contact details and there should also be a short section describing the contributions of each group member.

The submission materials should consist of source code, executable and documentation for each of the three labs. Lab submission will be conducted through Bilda, under 'Event -> Assignments -> DH2323 DGI16 Lab assignment submission'. Bilda lab submission will be available nearer to the submission deadline.

Note: If you cannot log into Bilda when you click on the link above, then you probably need to be registered there. In this case, send the course responsible your official details (including your KTH email address) and you will be added to the system.

commented 30 March 2016

If you are using MAC. I couldn't create a CMAKE project and got an error. I fixed it by navigating to Library/Frameworks (actually had to make this folder) and dragged SDL2.framework there. Then CMAKE worked nicely. Hope this works.

commented 3 April 2016

For those who are doing the setup for Lab 1 on Windows using Visual Studio 2013, you may have to do step 10.  My build was failing because my VS project didn't have a Subsystem set - it didn't default to the console.

commented 4 April 2016

Mac users,  I share with you my SDL2 template for LAB1,  as I suspect this may spare some people both time and frustration.

commented 4 April 2016

I got problems with installing SDL correctly on windows 7, 64 bit. Does anyone know how to do this properly? The "cmake ." command complains that it cannot find sdl_include and sdl_library. 

To TA & Christopher: Could we get another lab session dedicated for setting up the skeleton code? 

commented 6 April 2016

I would like to point out that "Figure 1" in laboratory 1 is wrong.

Figure 1, bilinear interpolation

According to page 5 in the laboratory instructions:

Code on page 5

So whoever made the image has either fumbled around their interpolation function arguments or departed from mirrored bottom corners.

Alain Birchmeier removed his/her comment
Christopher Peters removed his/her comment
Christopher Peters removed his/her comment
Teacher commented 6 April 2016

@Jack: We've organised a lab session this Monday 11th in the Visualisation Studio at 10a.m. - if you can make it, we could give you a help there. There will indeed be more labs sessions.

@Rodrigo: Well spotted. Although it's also possible that the lab instructions on page 5 are wrong. So for those doing the lab, either case (i.e. obtained image above or obtained image matching lab instructions that Rodrigo has described) will be marked as correct. Also, many thanks for the Lab1 SDL2 template for the Mac!

Henrik Dahlberg removed his/her comment
commented 7 April 2016

SDL2 GLM VS15 Template

SDL2-2.0.4

I made a template for Visual Studio 15 for those who wants to use SDL2, found in the first link. Place the folder found in the second link directly under C:\ and it should work right away.

Nick Anderson removed his/her comment
Nick Anderson removed his/her comment
commented 7 April 2016

How will these be graded? Like for lab 1, we output a rainbow and also stars. I have it factored such that you just need to comment out Draw and uncomment DrawRainbow, but how will our code submissions be graded?

For lab 2, I added many more controls (up/down, rotate camera left/right and up/down), in addition to the ones asked for, so should I just add these to the write up?

Controls

Thanks and cheers

Teacher commented 8 April 2016

The labs are graded as a simple pass/fail. A pass is awarded if all of the requirements specified in the instructions have been fulfilled. You should make that clear in the respective lab reports by including a summary of what worked (and what didn't) and also by including screenshots demonstrating your results at relevant stages. If you do not implement everything asked for, or don't have it working correctly, you'll be asked to resubmit.

As mentioned in the lectures, I suggest that you do not make the labs more complicated for yourselves than required in the instructions. Extra features are always nice, but you won't receive extra marks for them (since the labs are P/F). Especially, they should not get in the way of making sure that you've completed the basic pass requirements.

commented 9 April 2016

When will the links for lab track 2 be released?

Henrik Dahlberg removed his/her comment
Christopher Peters removed his/her comment
Christopher Peters removed his/her comment
Teacher commented 11 April 2016

We expect to upload them this week. Also, note that I've moved the provisional submission deadline for the labs for now to Friday May 13th (since the previous suggested date of May 6th is a holiday).

commented 15 April 2016

What is a "normal" rendering time for lab2 (raytracing) if you solve each intersection using glm::mat3?

commented 18 April 2016

At the end of the lab my rendering time is approximately 12 seconds at 500x500, running on a single thread on a CPU with a maximum frequency of 3.5 GHz, on OS X.

If you run on Windows you might not get 100% CPU utilization, in which case the rendering time will suffer.

The running time is in O(n^2), if n pixel width, if we assume that we can draw a pixel in constant time. This is obviously not correct but it'll give you a ballpark figure.

commented 18 April 2016

I have not checked precisely but I think my implementation renders at least two–three frames per second on a 2.5 GHz Intel Core i5 (OS X). Perhaps you are compiling in debug mode? When I added the -O2 flag it made my code run a lot faster.

commented 18 April 2016

I should probably have been clear about that, my times refers to running in debug mode from within Xcode

commented 20 April 2016

For lab 3 with the depth buffer:

"In it we will store the inverse depth 1=z for each pixel"

The labs are very consistent in saying 1=z, but I am curious if you actually mean 1/z? Also, wouldn't just computing 1/z with just z values not work for showing depth correctly 100% of the time?

commented 20 April 2016

For lab2 Real time animation track,

1) How to we build and run it on KTH computers

2) I tried g++ vectorLab.cpp, but it shows compiler errors on the code provided to us.

3) None of the TAs know how to solve it.

commented 21 April 2016

Hey,

was anybody successful running the provided code of the Particle System (Animation Lab 2) in Xcode? If so, what changes did you apply to make it work?

Teacher commented 25 April 2016

>For lab2 Real time animation track,

>1) How to we build and run it on KTH computers

My main advice, if your compiler or IDE of choice is not working, is to try building the labs using Visual Studio. In many cases, we've included the project files to do so (although possibly for a different version of MS Visual Studio).

The Matsalen lab (plan 5, East) has Windows 7 and Visual Studio installed on them: https://www.kth.se/en/csc/utbildning/studentservice/rooms-1.284076

Christopher Peters edited 27 April 2016

Spirit of the Labs Be aware that the purpose of the labs goes beyond developing your graphics (and mathematics) programming skills to testing your general methodology and approach to problem solving, in addition to autonomy and presentation. These are crucial at Master level and beyond. Important concepts include:

1) Programming methodology: The ability to fix bugs in a methodological manner rather than through trial and error processes. In computer graphics programming, this typically involves developing intuitive knowledge of the underlying maths, perhaps through the use of pen and paper, before even approaching the keyboard or programming aspects.

2) Flexibility and robustness to error: Real-world problems are never defined clearly or perfectly. You will encounter errors and ambiguities and must develop ways to deal with them. Spotting them is a good way to start, and involves step 1) above.

3) Research: Carefully reading and understanding instructions rather than attempting to carry them out by rote. Be aware that all of the details you need to solve the labs are available through careful planning and reading of the instructions on these pages, as well as in the lectures. The labs reward students who listen and plan rather than jumping straight into the lab work.

4) Reporting and soft skills: You should be able to report your approach and present your results in an ordered and succinct manner that clearly communicates your approach, problems encountered, solutions and summarises your results. 

5) Proactive communication: Asking for help at help sessions, starting threads in the forums or determining your own strategy for seeking feedback and solving problems.

Materials You should do three lab assignments in total. Lab assignment 1 is mandatory. The specific lab 2 and lab 3 assignments that you do depends on the lab track that you decide to take. There are two options: either rendering (lab track 1) or real-time animation (lab track 2).

Lab 1: Set-up and Introduction to 2D and 3D Graphics Lab 1 Instructions (read this first)Lab 1 Source code

and

Lab track 1: Rendering

Lab 2: RaytracingLab 2 Instructions (read this first)Lab 2 Source code

A gallery of (mistaken) art work for this lab from previous years is available here.Lab 3: RasterisationLab 3 Instructions Lab 3 Source code

or

Lab track 2: Real-time animation

Lab 2: TransformationsLab 2 InstructionsLab 2 Source code

Lab 3: Hierarchical TransformationsLab 3 Instructions Lab 3 Source code

Note that the labs can be set up with the development tool/IDE, environment and platform of your choice. Examples include GCC and Visual Studio. There are a large number of combinations of the aforementioned that may result in idiosyncratic build problems, so you will need to conduct the set up for your own specific configuration. In some cases, setting up the labs for the first time may be non-trivial if you haven't built projects in that particular development environment before. The hints and tips section here may be useful for some help with this.

Note that an older version of SDL is used in order to avoid set up issues with different platforms. If somebody creates a stable build using the latest version of SDL for the main platforms/development environments (and updates the instructions accordingly), I will be happy to upload it as a future option (and you will of course be credited for it).

Submission Submission of all the lab assignments is due in May 2016 (the provisional deadline is on Friday 1320th May) 2016 as a single .zip or .rar archive with an appropriate directory structure (Bilda lab submission will open nearer to thelink to Bilda lab submission date).The recommended documentation is a well-presented, two to three page document per lab detailing your implementation methods (your approach to completing the lab), experiences (problems encountered, solutions) and outputs (summary of what worked and what did not; also screenshots of the various stages of lab completion).

It should not contain many theoretical details or excessive code - source code comments can be added separately. If you worked in a group, group members should be clearly listed with contact details and there should also be a short section describing the contributions of each group member.

The submission materials should consist of source code, executable and documentation for each of the three labs. Lab submission will be conducted through Bilda, under 'Event -> Assignments -> DH2323 DGI16 Lab assignment submission'. Bilda lab submission will be available nearer to the Link to Bilda lab submission deadline.

Note: If you cannot log into Bilda when you click on the link above, then you probably need to be registered there. In this case, send the course responsible your official details (including your KTH email address) and you will be added to the system.

commented 30 April 2016

Hi, I am a bit confused regarding the instructions for task 2.4 in Lab 2 Animation track. It states that we should use myVector.cpp to perform the neccesary operations, but I don't see how I would do that efficiently since myVector does not accept an external matrix other than the ones currently loaded in openGl.

commented 30 April 2016

Is it okay to extend the class on our own?

Anshil Bhansali removed his/her comment
commented 6 May 2016

I have an issue with task 2.4/5 in lab2 animation track

To perform a translation by modifying the model view matrix, I changed the values in the 3rd, 7th and 11th positions in the matrix (rightmost column), and it didnt seem to work, then i tried to change the values of the 12th, 13th, 14th values(bottom row) and it worked as expected, aren't the translation values in the rightmost column i.e 3, 7 and 11th positions?...

commented 8 May 2016

Felix Grape & Nathanael Eneroth:

My rendering time for raytracing is 4 to 5 fps and for rasterization it's 45-50 fps. I also use -O2 flag when running. I also used the intersection-formula from the lab-description.

Marcus Åkerman removed his/her comment
commented 8 May 2016

Forgot to mention I run on a Macbook pro from late 2011. 

2,4 GHz Intel Core i5, 8 GB 1333 MHz DDR3, HD Graphics 3000 512 MB - if it helps putting it in perspective.

And I use Jonas Nockert's skeleton for SDL etc.

commented 9 May 2016

In lab3 of the animation tank, is the main gun supposed to rotate independent of the turret, or it only rotates with the turret?

Teacher commented 9 May 2016

This is up to you, but ideally the main gun would also rotate around the x-axis (i.e. be able to change its elevation).

commented 10 May 2016

For the BoundingSphere, how are we supposed to calculate the bounding sphere for the whole tank? when we are given only the meshes of the sub parts? Do we find the average over all the vertices over all the sub objects (turret, main gun etc), and henceforth? 

Anshil Bhansali removed his/her comment
commented 10 May 2016

In lab3 animation track, task 2.2 I am having some trouble with the function to test if a position potentially penetrates the sphere. I compared the distance between the position and the center of the sphere, and if that distance was less than/equal to the radius of the sphere, then it is considered inside. In the output, I see all the spheres, and the point, and although it doesn't visually collide with a sphere, my function says it does.... any idea?

Teacher commented 10 May 2016

>Do we find the average over all the vertices over all the sub objects (turret, main gun etc), and henceforth? 

For the bounding sphere, you'll need to calculate the centroid of all of the vertices (i.e. off all sub-objects) and also the most distant vertex (out of the set of all of the vertices in all of the sub-objects) from it.

>see all the spheres, and the point, and although it doesn't visually collide with a sphere, my function says it >does.... any idea?

It sounds as if there are two possibilities:

1) The drawing code is incorrect. One possible way to debug this is to draw the vertex positions (or just the most extreme position) of each sub-object of the tank instead of the overall mesh - make sure they are still being drawn in the proper positions.

2) The geometry code is incorrect

In both cases, it might be the case that there are some transformations that have not been applied. It's easy to make the mistake of comparing two sets of coordinates that belong to different coordinate spaces (e.g. comparing an object space vertex coordinate with one in world space). You need to make sure that everything is in the same coordinate space. Scaling transformations should also be checked (it is easy to miss those...). 

commented 11 May 2016

In laboration 2 animation track I am having trouble running the provided project for part 4 on the Windows computers in Matsalen. I get the error message "GL_ARB_point_parameters extension was not found". Anyone know how to fix this so I can continue with the lab? Would be much appreciated.

Anshil Bhansali removed his/her comment
commented 11 May 2016

In lab3 animation track, to detect if a line collides with a bounding sphere, should the line extend both sides to infinity, or should it be restricted in length?

commented 11 May 2016

in the same task^, how exactly would we find the z coord of the closest point to the line, because in lab2 we found the closest point to a line in a 2d plane...

Adria Cruz Cebrian removed his/her comment
commented 12 May 2016

Hi. I have been stuck on the same issue in lab 3 animation track for some days now.

My issue is this: 

I can create bounding spheres and draw them at their correct size and place in openGL, BUT, when following the instructions on doing the "potential collision" part of the lab, I am forced to deal with the raw bounding sphere data which is not formattedby openGL: It is not scaled down to 0.1, not translated, nor rotated. The result is that my function detect collisions all the time because on the drawn screen my projectile is seemingly at distance 14 from the sphere center, but the radius of the sphere itself is around 140 (hence the misinterpretation that the projectile is withing the bounding sphere). By my simple measurement on the drawn screen I can see on the drawn bounding sphere,which has been processed by openGL scale, transformation, rotation etc.., that it should have a correct radius of about 14 for one of the cases (say, tank body).

I went to the help session today where a TA suggested that i perform the same glTransformations, glRotations and glScaling on the objmesh before creating it, but that does not work: The objmesh and its vertexArray on the faces is not affected.

Some tips or hints on how i should tackle this problem would be greatly appreciated.

/Jack

Assistant commented 13 May 2016

My suggestion is to scale the model before you generating the bounding volumes and do the collision detection. Pay attention that before doing the scale, make sure to translate the center to the origin. 

ps: It will be good if you can bring laptop with source code to the lab next time that I can debug (not a phone). 

Jack Shabo removed his/her comment
commented 14 May 2016

Does anyone know a cool way to show transparent spheres in opengl (using gluSphere and alpha channels) such that you can have transparent spheres within other transparent spheres visible (distinguished) from the outer sphere? (I am asking in regard to Animation Lab 3). My current settings with gluBlend does not seem to do just that.

commented 16 May 2016

For Lab 3 (Rasterization), I was just finishing up the section on filling in the polygons when I encountered a very strange memory error.  For some reason, after DrawPolygon runs a few times, it gets to the end of the function and then breaks with a heap corruption error.  I'm not using heap allocation myself at any point in the lab, and as far as I can tell I'm not going out of bounds when looping through arrays.  Has anyone encountered a similar error?

commented 16 May 2016

Jessica, the heap corruption error does not ring any bells but I would check line lengths and lengths of allocated arrays. I ran into problems in DrawLine when moving the camera because an allocation of "vector<ivec2>" became huge. I implemented polygon clipping (Sutherland-Hodgman) to avoid that but I don't think that is necessary for passing the labs.

Hope that helps!

commented 16 May 2016

Hey Jonas, thanks!  I'll probably have to walk through it step-by-step to figure out how it could be going wrong.  If I hit 'continue' after the error shows up, then the image is still drawn correctly, but the memory error continues to persist.  I'll just have to keep working on it.

Jonas Nockert removed his/her comment
commented 16 May 2016

Oh, if you haven't before, this is also your chance to step into the wonderful world of C++ debugging! : ) It sounds like you might be using Visual Studio and, luckily, there's a debugger built in. You have to recompile with debug information first and then "debug" rather than "run" it. It's tricky to give much concrete advice because it depends so much on the specific problems you encounter. There are tutorials online to get you started though (and I can try to help with any specifics).

(Sorry if this is stuff you already know!)

commented 17 May 2016

In lab 2 I'm having a hard time doing the ray-tracing properly I think. I'm getting the "room" that the boxes are in, but there are no boxes... Anyone who can shine light on this? It's as if the boxes were removed or something because the far back is grey like it's shown in the instructions. All other colors seem to be fine.

Cheers

commented 17 May 2016

Is it possible to have a lab session tomorrow or day after? so that we can get some help completing our labs

commented 17 May 2016

In lab3 animation track, task 2.2 part 6, I am a little confused about what they are asking. 

1) By "Generate sparks", you mean to draw the bounding spheres of the specific parts of the tank?

2) Do we generate sparks when a particle (from the particle system) enters one or more of the bounding spheres?

3) How do we get access to the particles in the particle system? Do we have to go into the CParticleSystem class and create our own function to get access ?

Teacher commented 17 May 2016

1) 'Generate sparks' essentially means creating and placing a particle system object and then generating particles from it that look like sparks.

2) No: you only need to generate sparks in/near a bounding sphere when the projectile (i.e. point from Q3) is inside it. Placement of the particle system is up to you, but it does not need to be very accurate e.g. you could place it at the center of the bounding sphere.

3) You should not really need to make any modifications to the particles themselves. Instead, just set up the particle system so that it generates particles that look somewhat like sparks and then place it appropriately and enable it when the projectile enters a bounding sphere.

commented 17 May 2016

Is it possible to get an image of what the output should look like ?

commented 17 May 2016

ok.png

I'm still confused over this. I don't understand why the boxes are missing. I've made rotation and other parts of the lab work, but this remains a mystery to me. I'm probably doing something very wrong but I just don't understand what it is.

commented 18 May 2016

Måns, If the boxes are missing you are probably not checking for the closest intersection. The walls behind the boxes will intersect the day as well and are probably overriding the intersection with the box. Try to keep check of the distance to the camera in your intersection algorithm and only keep the closest one.

commented 18 May 2016

Aaaah ok, thank you! :)

Anshil Bhansali removed his/her comment
commented 18 May 2016

Welp I seem to be sort of stuck again and would like some input..

When I cast shadows in lab 2 I use the vector lightPos - intersection.position for the direction and the intersection.position as starting vector for the arguments in the ClosestIntersection function. I then compare the returned intersections distance with the absolute value- or length of the vector r (lightPos - intersection.position). It yields no valid results so far and I can't figure out why.

Any tips are welcome.

cheers

commented 19 May 2016

Måns Åberg, can you post a picture of your latest rendering? Are you seeing any of the boxes?

commented 19 May 2016

Marcis Åkerman

Yes the boxes are there. I attached two versions here, One with the boxes barely visible and one that gives a hint of a shadow. 

distance.pngdistance plus abs (lightpos minus intersectpos).png

commented 19 May 2016

Måns Åberg, I think I got something very similar to your second image, can't really remember what exactly caused it, but are you sure you got the correct intersection point in the ClosestIntersection() function? I calculated it in a way that looked correct up to the shadow part :P The final equation I used was v0 + u*e1 + v*e2. Another thing; have you tried the other direction going from the light source to the point instead of vice versa and see how that affects the outcome?

commented 19 May 2016

Mats Åberg, in the second one you should discard all intersections lower than a certain bias-value. Try 0.001 (or experiment with different values). Also make sure that the triangle in the first intersection is not the same in the second intersection.Both of these will make you avoid self-intersections when shooting the shadow-ray.  I think these self-intersections occurs because of the float inaccuracy that makes the second ray start behind the same triangle and hits it first before anything else. The returned t-value is therefore the lowest possible and will make your iteration return black color.

commented 19 May 2016

Also make sure you normalize your direction-vectors.

commented 20 May 2016

Thanks for the tips. I tried adding all the triangles except for the one being the starting point and just it as input for the triangles in the closestIntersection function, but it made no difference. I discarded all intersections below different threshold values and that too did not work.

I'll just attach how it looks like now along with the source code for some functions. Thanks for the help so far nonetheless, appreciated.

Source Code

Shadow.png

commented 29 April 2017

I'm a bit confused about the camera controls for Lab 2 (on the rendering track). When it says we should update the left and right arrow keys to rotate the camera left and right, does that mean the left and right keys only rotate now and don't translate, or that the left and right arrow keys should both rotate and translate?

commented 5 May 2017

Is it at all possible to make the last part of lab 2 (animation track) more portable? It is a nightmare to get it to even compile under Mac/Linux and I have not even got the VS build to compile. 

Does anyone else have a compilable version in hand?

commented 5 May 2017

Hi Alexander,

Yes the files really need to be updated. I just created a repository with the fixed code:

https://github.com/BGodefroyFR/DH2323-Particle-System

It should run on Visual Studio 2017, with Windows 10.

Teacher commented 5 May 2017

Also, in relation to Visual Studio, please contact us as soon as possible if you are having difficulty getting something in the Labs to compile/build using it. We can provide a lot of help with that.

Assistant commented 5 May 2017

"I'm a bit confused about the camera controls for Lab 2 (on the rendering track). When it says we should update the left and right arrow keys to rotate the camera left and right, does that mean the left and right keys only rotate now and don't translate, or that the left and right arrow keys should both rotate and translate?"

The left/right key should only manage rotations around y-axis. If you want to include right/left translation, I would suggest to use other keys without conflict.

commented 15 May 2017

I have a a question on animation lab3, in the first task, it required to build a display list and a OBJdraw function which is kind of similar to the objdraw in objloader.cpp, but when I was doing the other part of the lab I didn't use these things, what are they built for?

And another question is that in the objdraw built by myself, I try to initialize *pMesh by g_LinkedListHead (same as objdraw in ObjLoader.cpp), but it said cannot find g_LinkedListHead, and I also try to initialize pMesh by tankBody, it said it's null pointer.

commented 15 May 2017

Hi,

Regarding the upload of the labs on Bilda, what exactly is meant with "Please include a note in a prominent location is you required your grades to be expedited for whatever reason." ?

Thanks in advance

Assistant commented 15 May 2017

I have a a question on animation lab3, in the first task, it required to build a display list and a OBJdraw function which is kind of similar to the objdraw in objloader.cpp, but when I was doing the other part of the lab I didn't use these things, what are they built for?

You don't need to implement the whole DrawOBJ from scratch. You call 

DrawOBJ ( tankBody−>m_iMeshID ) ;

for the rest parts of tank. Since you need to translate and different parts a little bit to assemble the whole tank, you need a display list to be executed here to make transformation.

Fangkai Yang removed his/her comment
Assistant commented 15 May 2017

Regarding the upload of the labs on Bilda, what exactly is meant with "Please include a note in a prominent location is you required your grades to be expedited for whatever reason." ?

Some students are exchange students who need final grades urgently for some reason of transferring credits or those who need to get the master degree in a hurry. For these students, they get the priority to get the final grades. 

commented 16 May 2017

error.png

I need help with lab2. I receive this error and have no idea how to solve it...

commented 16 May 2017

Everyone who has problems with the Visual Studio project in the labs go try it on the Windows computers in school. I wasted almost a week on trying to get a old VS solution to compile in VS 2017 when it just worked in the school environment with VS 2010. :)

Assistant commented 16 May 2017

@Tomas Vändahl

The reason is that you only have declaration but not a definition. You probably didn't include the lib which contains the definition or you define the function as a standalone and forgot the class sector like Vector::

commented 16 May 2017

Hi,

I'm having some trouble with lab 2 (animation), part 4. When I compile and run the provided code, I only see a window with a black background, but no particles. I'd like to troubleshoot the problem but I'm honestly not sure where to even start.

  • I've finished parts 1 through 3 of this lab, and copied the functions from myVector.cpp and myQuat.cpp. They should work fine.
  • I don't get any errors or warnings when compiling the code.
  • The console window asserts (six times) that the texture image particle.bmp has been assigned.

Any ideas?

commented 16 May 2017

Hi Sonja,

I got this issue too. The particle system needs to be "updated" in order to display something.

You should implement the animation as described in the next task and you will see the particles moving :)

Otherwise, you can use directly this fixed version (for VS 2017): https://github.com/BGodefroyFR/DH2323-Particle-System

commented 16 May 2017

Thank you! I will try that.

commented 18 May 2017

Is it possible to make Animation Lab 2 & 3 on Mac? Been on it for 3 hours and it doesn't work in either XCode nor Visual Studios for Mac. Would really appreciate some guidance if possible! :)

commented 24 May 2017

Hi!

I have a problem with lab 3 (animation), when we are supposed to integrate the particle system from lab 2. The problem right now is even getting the particle code into the tank lab (I assume '#include "particleSystem.h"' should be enough for it?). As soon as I add that line of code to the main.cpp file, I get tons of errors about myVector being ambiguous. I have commented out the lines:
//#include "myVector.h"
//#include "myMatrix.h"
in particleSystem.h since my main.cpp file already has them included, but then I get a bunch of errors as such:

particle system VS errors.png

Any ideas on how to solve it?

commented 25 May 2017

@Erik, check the namespaces... I remember getting a lot of errors at that point and I think it was due to namespaces but I'm not sure if that's the problem for you. Also, make sure that definitions in headers are only read once. That might cause problems if a file is imported from several other files and things are redefined. Put #ifdef guards around all definitions... Hmm... 

commented 25 May 2017

@Elias, thanks for the tip! I'll have a look at it :)

commented 29 May 2017

I am unable to login to KTH Canvas. The kth.se login works fine and I can see the top bar (showing my schedule and courses etc) indicating that I'm logged in, but KTH Canvas is refusing to recognize that, simply saying:

Failed to log in

There was a problem logging in at KTH Royal Institute of Technology

You may try to log in again.

If this persists, I will be unable to hand in my lab reports.

commented 29 May 2017

Seems to be working now. I managed to turn in my lab reports!

Feedback News