Preparation for Lesson 8 Lesson 8 is focused on geometry shaders and environment mapping. For a smooth lesson, review: • If not solved in the 7th lesson, think about how to render a point as a billboard, which is a textured square that is always facing the viewer. • Review environment mapping and what is a cube texture. Go through project 8 in the study materials. Focus on: • We will use a cube texture for reflection of the surrounding objects, and we will update this texture. The code contains the initialization of a random scene and 5 animated objects. The code also contains the initialization of the six camears oriented according to the six sides of the cube map, the initialization of the cube texture, and the initialization of a framebuffer with attachments with these six sides of the cube texture. • The rendering procedure first updates the cube texture (more at the lecture) and then use this texture for the final image. • We will experiment with several methods to render the scene, which means we have more combinations of shaders. We hope that the comments in reloacLshaders function will help you to find your way around. • The scene contains a skybox. However, this skybox is not rendered as a 3D cube as we did in PV112. Instead of that, we render a 2D quad and use vertex shader to transform its coordinates from clip space to view space using inverse of the projection matrix and the inverse of the view matrix. Although this look complicated, it is actually more simple, since we do not compute a size of the 3D cube to fit between the near and far plane. Příprava na 8. cvičení Na osmém cvičení budeme probírat geometry shadery a environment mapping. Pro hladký průběh cvičení si zopakujte a připravte: • Pokud se to nestihlo na sedmém cvičení, popřemýšlejte, jak vykreslit bod jako billboard, tedy jako otexturovaný čtverec, který je vždy natočen k pozorovateli. • Vzpomeňte si, jak funguje environment mapping, vzpomeňte si, co je cube textura. Projděte si projekt Cv8 ve studijních materiálech. Zaměřte se zejména na: 1 • Ve cvičení budeme používat cube texturu pro odlesky okolí a tuto texturu budeme aktualizovat. V kódu najdete mj. inicializaci náhodné scény a 5 objektů, které se v této scéně animují. V kódu také naleznete inicializaci šesti kamer orientovaných podle šesti stěn cube mapy, a cube textury a framebuffer objekty navázané na tyto textury, do kterých budeme kreslit. • Kreslení probíhá tak, že je nejprve aktualizována textura s okolím (více na přednášce), a ta je poté použita pro finální kreslení do hlavního okna. • Ve cvičení si ukážeme více variant kreslení scény, což ovšem také znamená více shaderů. Doufáme, že komentář na začátku funkce reloadshaders alespoň trochu pomůže se v nich vyznat. • Scéna obsahuje skybox. Ten ovšem není kreslen tak, že bychom vykreslili kostku s jednotlivými texturami cube textury, jak bylo řečeno v PV112. Místo toho vykreslíme jednoduchý 2D quad, a ve vertex shaderu pomocí inverze projekční a pohledové matice převedeme směr pohledu ze souř. systému obrazovky do souř. systému kamery a poté do souř. systému světa. Ačkoliv se to může zdát komplikované, je to vlastně jednodušší, nemusíme třeba určovat velikost kostky, aby se vlezla mezi blízkou a vzdálenou ořezovou rovinu kamery. 2