~~REVEAL~~ ====== Einführung in die Computergrafik und Bildverarbeitung ====== Wintersemester 2021/22 ===== 22. Dezember 2021 - GLSL Shaders in PyOpenGL ===== - GLSL in Python verwenden - Fragestunde zur Studienleistung 2 ===== Tutorial ===== Download ``simple_shaders.py`` from GRIPS and try to get it running Then complete the following tasks: - change the code so that the fragment shader reacts to mouse clicks - animate the square's position - drag the square around using the mouse - make the square rotate in 3D space (you need matrix multiplication in your shader ([see here](https://www.shadertoy.com/view/3sGfzw)) - apply simple shading in the fragment shader (see link above) - advanced: implement a blur fragment shader (you need to render to a buffer first - see multipass example [here](https://github.com/Blakkis/GLSL_Python) ===== Fragment Shaders ===== - werden einmal pro Pixel im Bild aufgerufen, geben Farbwert zurück - Eingabeparameter: Bildposition (``vec2 fragCoord``) - Ausgabewert: Pixelfarbe (``vec4 fragColor``, RGBA) - Zeichnen in 2D: [Kreis](https://www.shadertoy.com/view/XsjGDt) - Blur-Filter (nicht Gaussscher Weichzeichner, nicht effizient): https://www.shadertoy.com/view/Xltfzj - [Halbton-Shader](https://weber.itn.liu.se/~stegu/webglshadertutorial/shadertutorial.html) ===== Vertex Shaders ===== - werden einmal pro Vertex aufgerufen - Eingabeparameter: Vertex-Koordinaten (``vec3``) - Ausgabewert: Vertex-Koordinaten, indem globale Variable ``glPosition`` gesetzt wird. - nicht direkt von ShaderToy unterstützt - Wireframe Cube: https://www.shadertoy.com/view/4lfBWf ===== Beispiele Shading ===== - Normalenbasiertes Shading: https://www.shadertoy.com/view/3sGfzw - Blinn-Phong-Shading: https://www.shadertoy.com/view/XlXGDj ===== Ausblick 11. Januar 2022 (online) ===== - Wrap-Up 3D - Intro Computer Vision / OpenCV