Jiří Chmelík, Jan Čejka Fakulta informatiky Masarykovy univerzity 17. 09. 2019 17.09.2019 1/38 Outline 1 Organization Introduction o Shading Languages * Repetition of knowledge Toon-shading, eel-shading o Toon-shading o Cel-shading a Food for thought ^ Topic of Next Seminar PV227 - GPU Rendering (Fl MUNI) Lesson 1 - Outline (T) Organization ^ Introduction Shading Languages Repetition of knowledge 3 Toon-shading, eel-shading Toon-shading Cel-shading Food for thought 4 Topic of Next Seminar 17.09.2019 3/38 Course Teaching method = seminars active participation ... PV227 - GPU Rendering (Fl MUNI) Lesson 1 - Introduction 17. 09. 2019 Course Teaching method = seminars active participation ... Figure: Taken from weebly.com PV227 - GPU Rendering (Fl MUNI) Lesson 1 - Introduction 17.09.2019 4/38 Course - curriculum o Introduction, Repetition, Toon Shading o Shadows o Deferred shading o SSAO, DoF * HDR, bloom a Particle systems, compute shaders a Geometry shaders o Tessallation shaders o Microfacets o Physically Based Rendering, IBL o Vulkan a Parallax Occlusion Mapping Lesson 1 - Introduction Course Used technologies: o Windows <* Visual Studio 2015 (or newer) o C++ o OpenGL o Libraries ► FreeGLUT ► GLM ► GLEW ► DevIL ► AntTweakBar Requirements To successfully pass the course: a no more than 2 absences, o two assignments: ► individual, home work, ► two weeks limit, ► oral presentation. PV227 - GPU Rendering (Fl MUNI) Lesson 1 Requirements To successfully pass the course: a no more than 2 absences, o two assignments: ► individual, home work, ► two weeks limit, ► oral presentation. Expectations: o programming skills: C, C++ a knowledge of OpenGL (PV112) <* basic knowledge of basics principles of computer graphics (PB009) PV227 - GPU Rendering (Fl MUNI) Lesson 1 - Introduction 17. 09. 2019 Contacts o Jin Chmelik ► office: A412 ► e-mail: jchmelik@mail.muni.cz o Jan Cejka ► office: A419 ► e-mail: 324987@mail.muni.cz PV227 - GPU Rendering (Fl MUNI) Lesson 1 - Introduction 17. 09. 2019 Want to know more about GPUs? PV197 - GPU Programming, Jiří Filipovič: 9 Introduction: motivation for GPU programming, GPU architecture, overview of parallelism model, basics of CUDA, first demonstration code 0 GPU hardware and parallelism: detailed hardware description, synchronization, calculation on GPU - rate of instruction processing, arithmetic precision, example of different approaches to matrix multiplication - naive versus block-based O Performance of GPUs: memory access optimization, instructions perormance, example of matrix transposition O CUDA, tools and libraries: detailed description of CUDA API, compilation using nvcc, debugging, profiling, basic libraries, project assignment • Optimization: general rules for algorithm design for GPU, revision of matrix multiplication, parallel reduction • Parallelism in general: problem decomposition, dependence analysis, design analysis, parallel patterns O Metrics of efficiency for GPU: parallel GPU and CPU usage, metrics for performance prediction of GPU code, demonstration using graphics algorithms, principles of performance measurement O OpenCL: introduction to OpenCL, differences comparing to CUDA, exploiting OpenCL for hardware not accessible from CUDA 3 ... PV227 - GPU Rendering (Fl MUNI) Lesson 1 - Introduction 17.09.2019 9/38 Outline Organization Introduction o Shading Languages o Repetition of knowledge Toon-shading, eel-shading Toon-shading Cel-shading Food for thought Topic of Next Seminar PV227 - GPU Rendering (Fl MUNI) Lesson 1 - Introduction 17. 09. 2019 10/38 Outline 1 Organization Introduction o Shading Languages Repetition of knowledge 3 Toon-shading, eel-shading Toon-shading Cel-shading Food for thought 4 Topic of Next Seminar Lesson 1 - o Cg (C for Graphics), by NVIDIA - no longer under active development, o HLSL (High Level Shading Language), by Microsoft, o GLSL (OpenGL Shading Language), by Khronos Group. o Vulkan + SPIR-V, by Khronos Group. Shader Languages Comparison o almost the same capabilities, o conversion tools exist, o Cg and HLSL very similar (different setup), o HLSL DirectX only, GLSL OpenGL only, Cg for both -> different platforms supported. Chosen Language We will use GLSL in this course: a open standard (same as OpenGL), 9 no install needed, a all platforms, all vendors. Will will use GLSL 4.30 for OpenGL 4.3 o newer features will be mentioned but not demonstrated, o NVIDIA 400 family supports OpenGL 4.5 9 NVIDIA 600 family supports Vulkan Outline Organization Introduction Shading Languages o Repetition of knowledge Toon-shading, eel-shading Toon-shading Cel-shading Food for thought Topic of Next Seminar PV227 - GPU Rendering (Fl MUNI) Lesson 1 - Introduction 17. 09. 2019 15/38 Repetition of knowlegde Repeat the knowledge of PV112, everyone at home as homework o See Repetition.pdf in IS o Understand project Repetition in IS PV227 - GPU Rendering (Fl MUNI) Lesson 1 - Introduction 17.09.2019 16 Outline 1 Organization ^ Introduction Shading Languages Repetition of knowledge Toon-shading, eel-shading o Toon-shading Cel-shading Food for thought 4 Topic of Next Seminar Lesson 1 - Introduction 1. Lesson: Toon-shading, eel-shading Source code Download and prepare source code from IS: o Download and unzip PV227.zip (j Download and unzip Cv1.zip Open Cvl.sln in Visual Studio, and compile and run the source code. Toon-shading Diffuse lighting: use only several intensities of the light PV227 - GPU Rendering (Fl MUNI) Lesson 1 - Introduction 17. 09. 2019 Toon-shading o Task 1: Implement toon-shading for diffuse lighting for objects without textures. Hint: Look for "Task 1" in notexture_fragment.glsl PV227 - GPU Rendering (Fl MUNI) Lesson 1 - Introduction 17.09.2019 22 Toon-shading Specular lighting: the same as diffuse lighting, usually only a single white intensity. Without specular highlight With specular highlight PV227 - GPU Rendering (Fl MUNI) Lesson 1 - Introduction 17.09.2019 23 Toon-shading o Task 2: Implement toon-shading for specular lighting for objects without textures. Hint: Look for "Task 2" in notexture_fragment.glsl PV227 - GPU Rendering (Fl MUNI) Lesson 1 - Introduction 17.09.2019 25 Toon-shading: textures What about textures? a Create special textures a Do not use textures Toon-shading o Task 3: Implement toon-shading for diffuse and specular lighting for objects with textures. Hint: Look for "Task 3" in texture_fragment.glsl o Task 4: Threshold the color of the texture Hint: Look for "Task 4" in texture_fragment.glsl PV227 - GPU Rendering (Fl MUNI) Lesson 1 - Introduction 17.09.2019 27 Outline 1 Organization ^ Introduction Shading Languages Repetition of knowledge Toon-shading, eel-shading Toon-shading a Cel-shading Food for thought 4 Topic of Next Seminar Lesson 1 - Introduction Cel-shading Adds contours around objects. Contours, method 1: view direction Check the angle between the normal and the view direction black if n • / < threshold PV227 - GPU Rendering (Fl MUNI) Lesson 1 - Introduction 17. Contours, method 1: view direction Good for round objects, bad for flat objects Good Bad, no contour Bad, left side is black PV227-GPU Rendering (Fl MUNI) Lesson 1 - Introduction 17.09.2019 31/38 Contours, method 2: enlarge object Render black back faces of objects enlarged a bit along their normals, then render the front faces as usual PV227 - GPU Rendering (Fl MUNI) Lesson 1 - Introduction 17.09.2019 32/ Contours, method 3: Postprocessing Use postprocessing to detect edges and detect edges. PV227 - GPU Rendering (Fl MUNI) Lesson 1 - Introduction Cel-shading Choose one (or both if you are fast): o Task 5a: (easier) Implement the first method, i.e., inspect the view direction. Hint: Look for "Task 5a" in notexture_fragment.glsl and in texture_fragment.glsl a Task 5b: (harder) Implement the second method, i.e., render the objects twice, first only the black faces in black, and then the front faces in a standard way. Hint: Look for "Task 5b" in Cv1_main.cpp (two places). Lesson 1 - Introduction Outline 1 Organization ^ Introduction Shading Languages Repetition of knowledge Toon-shading, eel-shading Toon-shading Cel-shading o Food for thought 4 Topic of Next Seminar Lesson 1 - Introduction Food for thought o How to solve more lights? Threshold separate lights and then add the result together? Or vice versa, first add the lights together and then threshold the result? o How to solve transparent objects, like glass, fog, or smoke? Borderlands 2 Lesson 1 - Introduction Food for thought 9 How about different thresholds for different materials? Think about 1D textures. a How about different styles of the lines? Taken from gatheryourparty.com PV227 - GPU Rendering (Fl MUNI) Lesson 1 - Introduction 17.09.2019 37/38 Topic of next seminar: Shadows