Realtime graphics on GPU - labs summer semester 2021/2022

This page is dedicated for information about lab practices for Realtime graphics on GPU (NPGR019). For information about lectures, please visit the lecturer's page. For visiting archives of past year's, you can visit their respective year's: 2020, 2021.

Use my personal e-mail address for all communication directly:

{name}.{surname}.88{at}gmail{dot}com,

where name and surname refers to my name. Be considerate and fill properly your name in your e-mail client (i.e., no e-mails from Coolguy69 etc.) and use some meaningful subject ideally containing the code of the lecture (NPGR019). All of this serves the purpose of not pairing-up suspiciously looking nicknames to your real names in SIS and/or fish your messages from the spam folder.

I'm usually responsive so if I don't reply within day or two it means you've probably triggered gmail's spam filter. You are also kindly invited to our Discord server for faster communication.

In order to pass the lab practices, you need to pick 2 assignments from the pool below, implement them and submit them via e-mail by 30. 6. 2022, i.e., the end of the summer semester examination period. Note, that to be able to sign up for the exam, you should obtain the grade for practicals first. Use separate messages for each project and use a meaningful subject like "NPGR019 - {name of the project}". I will send you e-mail confirming delivery followed by further questions (if any) and the result or I may ask you for some further improvements or fixes.

Lab practices overview

Important: Labs will be held primarily in present form in SW1 starting on Monday 14.2. - both slots 1220 and 1400 - and Wednesday 16.2. 1720.


Introduction

14. 2. & 16. 2. 2022


  • Introduction, formalities
  • Assignments
  • Gentle introduction to a first OpenGL program and the labs framework

Hello triangle

21. 2. & 23. 2. 2022


Vertex, index buffers, 3D scene

28. 2. & 2. 3. 2022


  • Vertex and index buffers
  • First truly 3D scene
  • MSAA, vsync, depth testing, wireframe rendering, backface culling
  • Quick introduction to RenderDoc graphics debugger

02-3D-Scene controls:


  • W, S, A, D, R, F - camera movement
  • Mouse RMB + move - camera orientation
  • Enter - reset camera transformation
  • F1 - Enable/Disable MSAA
  • F2 - Enable/Disable Wireframe
  • F3 - Enable/Disable Backface culling
  • F4 - Enable/Disable Depth testing
  • F5 - Enable/Disable Vsync

Going 3D

7. 3. & 9. 3. 2022


  • Assignments
  • Brief introduction to MSAA, vsync, depth testing, wireframe rendering, backface culling

Going 3D in depth

14. 3. & 16. 3. 2022



03-DepthBuffer controls (new or different controls, rest is the same as above):


  • +/- - Zoom in/out
  • Backspace - FOV reset
  • F6 - Depth buffer visualization
  • 1 - Color visualization (default)
  • 2 - Non-linear depth buffer visualization
  • 3 - Linear depth visualization
  • 4 - Difference between depth buffer and linear depth

Depth buffer, framebuffers, textures

21. 3. & 23. 3. 2022


Textures

28. 3. & 30. 3. 2022


  • Texture creation, usage, sampling, filtering

04-Texturing controls (new or different controls, rest is the same as above):


  • 1 - Nearest neighbour filtering (default)
  • 3 - Trilinear filtering
  • 4 - Anisotropic filtering
  • 5 - Anisotropic filtering with clamp to edge addressing
  • 6 - Anisotropic filtering with mirrored repeat addressing

Textures & shading

4. 4. & 6. 4. 2022



06-Shading adds F6 for HDR rendering on/off.

HDR Rendering & instancing

11. 4. & 13. 4. 2022



05-Intancing controls:


  • F6 - Enable/disable instancing
  • 1 - Draw 1 cube
  • 2 - Draw 125 cubes
  • 3 - Draw 1000 cubes
  • 4 - Draw 15 625 cubes
  • 5 - Draw 125 000 cubes
  • 6 - Draw 1000 000 cubes

Instancing & deferred rendering

20. 4. & 25. 4. 2022



09-Deferred specific controls:


  • F1 - Enable/disable VSYNC
  • F2 - Enable/disable light animation
  • 1 - Deferred lighting mode
  • 2 - Visualize linear Z buffer
  • 3 - Visualize world space normals
  • 4 - Visualize specularity G-Buffer
  • 5 - Visualize AO G-Buffer

Shadow volumes

27. 4. & 2. 5. 2022



07-ShadowVolumes specific controls:


  • F1 - Enable/disable MSAA
  • F2 - Enable/disable wireframe rendering
  • F3 - Enable/disable VSYNC
  • F4 - Enable/disable HDR rendering
  • F5 - Enable/disable light animation
  • F6 - Toggle between Z-pass/Z-fail algorithm

Useful resources


  • GLFW - multi-platform library abstracting the window creation and more.
  • SDL - multi-platform library allowing window creation, sound handling etc.
  • GLAD - GL loader generator for .dll.
  • GLM - OpenGL Mathematics library. C++ header only mimicing GLSL.
  • Assimp - Open Source Asset Import Library.
  • STB Image - Open source, easy to use image loading library.

Semestral project assignments

You should pick 2 of the following assignments and implement them within the OpenGL C/C++ framework of these practicals. You can also choose to implement one with all the bonuses if present as it amounts to 2 assignments in a row.

I shall be provided with an easy to compile and run solution that doesn't need too much overhead to get up and running. You can use whatever resources you'd like (textures, models, model loading libraries, etc.) but I suggest you keep the assignment as simple as possible and focus only on the task at hand. All of the required geometry and textures for the assignments can be usually hardcoded in the program, e.g., use simple planes, cubes, cylinders, spheres - just as you see in my examples. Provide interactive camera in all submissions.

The source code must be well commented so I can understand what you are trying to achieve and can see that you understand your code. The handed-in assignments should ideally compile and run on Windows machine under MSVS 2017, I'll be using that as a primary testing machine.

Don't forget to bundle all needed external resources and/or .dll files needed to run. Make sure you clean the project before packing so you don't send me compiler generated object files, MSVS debug symbol and intellisense databases, etc. For reference, all of my example programs shown during the labs last year were under 3 MB packed in a .zip file including textures, i.e., if you're sending me something grossly exceeding 10 MB then something is wrong.

Finally, before sending your submissions, please make sure that the program can be compiled and run on a different PC (or at least from different folder on your PC - hardcoded paths to your username documents folder may be one of the problems). If the filesize exceeds 10 MB, please upload the solution somewhere (Google drive for instance) and send me a link instead. Do not use services with auto-expiration links.


Shadow maps for point and spot lights

Shadow mapping is de-facto standard for casting shadows into a computer generated scene in real-time. It is usually implemented using directional lights, i.e., sun. However, we may want to have point lights and spot lights in the scene casting shadows as well. That is the goal of this assignment: implement a simple scene that uses several point and spot lights each casting shadows using shadow mapping.

The scene you create should be sufficiently complex, e.g., several cubes and spheres on a plane that act as both occluders and shadow receivers. It should provide enough varied geometry to assess how you dealt with common shadow map artifacts like Peter panning and shadow acne.

07-ShadowVolumes is a recommended starting point, implement a spot light (point light already included) and replace shadow volumes rendering with shadow maps.

Requirements

  • Render a scene with 2 light source types (spot and point) with several lights of each type
  • Lights and some objects should be dynamic with possibility to stop the animation
  • Solve common artifacts, i.e., shadow acne, Peter panning, and shimmering
  • Filter the shadows using some method like Percentage Closer Filtering, Poisson Disk Sampling, etc. for smooth edges

Bonus

  • Efficiently implement point and spot light shadow maps into 09-Deferred, i.e., G-Buffer pass, shadow pass (new), light pass
  • Use geometry shader to render all omnidirectional shadow maps in a single pass
  • Store all shadow maps together (per type) either in a texture array, texture atlas, or use bindless

GPU particles

Implement a simple particle system that will represent some effect such as fire, smoke, etc. (be creative). Render the particles as sprites with an animated texture. Particles should be lit by a scene light.

06-Shading is a good starting point for such a scene.

Requirements

  • Simulated particle effect using GPU sprites (billboards)
  • Particles should be animated (both the particle and its texture in UV space)
  • Particles should be affected by scene light

Bonus

  • Simulate the effect entirely on the GPU using compute shaders
  • Use geometry shader to expand singular points into particle billboards
  • Implement soft particles to hide geometry cutting by the billboards

Postprocess antialiasing

While MSAA is a go-to HW supported technique to obtain smooth images, in many cases this technique is not desirable (large render-targets, combination of MSAA and non-MSAA rendering passes, etc.) or not available such as in deferred rendering. Implement a postprocess antialiasing method of your choice into the 09-Deferred example, e.g., FXAA, MLAA, SMAA.

Requirements

  • Add support for antialiasing to the 09-Deferred example using postprocess antialiasing method

Cartoon shader

Implement a non-photorealistic toon/cel shader with contours. To generate contours you can employ, for example, a classic method of analyzing depth buffer and scene normals for edge detection, or you can use geometry shader to generate silhouettes. 06-Shading or 09-Deferred are good starting points.

Requirements

  • Pixel shader cel shading effect
  • Contours for silhouette edges
  • Use interesting geometry showing off the effect, e.g., spheres, cylinders, Utah teapot (you can easily read it from an .obj file)

Mirror, mirror

Utilize a stencil buffer to render a scene with a mirror reflecting it. Alternatively, you can render a scene with portal showing the scene from a different angle. 06-Shading is a good starting point for this assignment.

Requirements

  • Create interesting, sufficiently complex scene
  • Place a mirror to the scene so its geometry will be reflected
  • Or place a portal and allow for simultaneous viewing of the scene through it

Copyright (C) 2015-2021 Martin Kahoun