Demystifying shaders
-
Upload
functional-imperative -
Category
Software
-
view
117 -
download
0
Transcript of Demystifying shaders
![Page 1: Demystifying shaders](https://reader031.fdocuments.in/reader031/viewer/2022030218/5886879e1a28abf6158b4abf/html5/thumbnails/1.jpg)
Demystifying Shaders
Bruno Opsenica @BruOps
![Page 2: Demystifying shaders](https://reader031.fdocuments.in/reader031/viewer/2022030218/5886879e1a28abf6158b4abf/html5/thumbnails/2.jpg)
- WebGL Shaders are written in GLSL-ES- High level shading language- C like syntax- Strongly typed!
- We pass them in as strings to our application
Open GL Shading Language (GLSL)
![Page 3: Demystifying shaders](https://reader031.fdocuments.in/reader031/viewer/2022030218/5886879e1a28abf6158b4abf/html5/thumbnails/3.jpg)
Basics - Vertices
![Page 4: Demystifying shaders](https://reader031.fdocuments.in/reader031/viewer/2022030218/5886879e1a28abf6158b4abf/html5/thumbnails/4.jpg)
The simplest quadThese coordinates are in
Model SpaceThey are defined to the
model’s own origin
system
Our vertex shader must
transform these
coordinates to clip space
![Page 5: Demystifying shaders](https://reader031.fdocuments.in/reader031/viewer/2022030218/5886879e1a28abf6158b4abf/html5/thumbnails/5.jpg)
Our Goal:
![Page 6: Demystifying shaders](https://reader031.fdocuments.in/reader031/viewer/2022030218/5886879e1a28abf6158b4abf/html5/thumbnails/6.jpg)
Projection Transform
![Page 7: Demystifying shaders](https://reader031.fdocuments.in/reader031/viewer/2022030218/5886879e1a28abf6158b4abf/html5/thumbnails/7.jpg)
Fragment / Pixel Shader
![Page 8: Demystifying shaders](https://reader031.fdocuments.in/reader031/viewer/2022030218/5886879e1a28abf6158b4abf/html5/thumbnails/8.jpg)
- Vertex Shader acts on each vertex to transform our
points into clip space:- model space -> view space -> clip space- must set vec4 gl_Position;
- Fragment Shader sets the color of each pixel/fragment- must set vec4 gl_FragColor;
- We use uniforms, attributes and varyings to calculate
these values
Summary
![Page 9: Demystifying shaders](https://reader031.fdocuments.in/reader031/viewer/2022030218/5886879e1a28abf6158b4abf/html5/thumbnails/9.jpg)
- Shader School -
https://github.com/stackgl/shader-school- www.thebookofshaders.com by Patricio Gonzalez Vivo- www.clicktorelease.com/blog/ by Jaume Sanchez- www.shadertoy.com
- Figures taken from:- Real Time Rendering by Adenine-Moller et al- Wikipedia- http://www.codinglabs.net/- OpenGL Documentation
Resources and Further Reading
![Page 10: Demystifying shaders](https://reader031.fdocuments.in/reader031/viewer/2022030218/5886879e1a28abf6158b4abf/html5/thumbnails/10.jpg)
Functional Imperative
functionalimperative.com(647) 405-8994@func_i