Created
July 29, 2021 23:33
-
-
Save alexboots/06ebe8797215fbb9cb089937b8ac4f2c to your computer and use it in GitHub Desktop.
Book of shaders notes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Getting started | |
-------------------------------- | |
GLSL stands for openGL Shading Language | |
- Each pipe of thread has to be independant of each other | |
- Threads are blind to what each other is doing | |
- DATA MUST FLOW IN THE SAME DIRECTION | |
- impossible to check the result of another thread, modify input data, or pass outcome of one thread to another | |
- Each thread is blind and memoryless | |
Hello world | |
-------------------------------- | |
- Shader language has a single `main` functino that returns a color at the end | |
- Final pixel colour is assigned to `gl_FragColor` | |
- vec4 = stands for four dimentional vector of floating point precision | |
- RED, GREEN, BLUE, ALPHA | |
RBG ALPHA | |
RGBA | |
same as css order | |
always use 1.0 whole decimals for floats or some browsers will break | |
Can specify precisions: | |
precision mediump float; | |
precision lowp float; or precision highp float; | |
Uniforms | |
-------------------------------- | |
ALL THREADS ARE BLIND TO EACH OTHER | |
- We need to be able to send message from the CPU to all threads | |
- each thread receives the same data (UNIFORM) which it can _read only_ | |
INPUTS ARE CALLED UNIFORM :: | |
- supported types: float, vec2, vec3, vec4, mat2, mat3, mat4, sampler2D and samplerCube | |
- Uniforms are little bridges /-------\ between the CPU and GPU | |
- | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment