tags: computer graphics, computer vision
Shaders are simple programs that run on the GPU, there are many types of shaders, like Vertex shader, fragment shader, etc…
Vertex Shaders
Vertex shaders are shaders that take vertices of the object from the object space as input and does some processing on them and outputs the new position or gl_position to the screen space either by projecting by a world matrix or a view matrix or all of them
“It processes each individual vertex in a 3D model and is responsible for transforming vertex positions from object space to screen space, as well as performing other tasks like lighting, skinning, and computing other per-vertex data” - ChatGPT
#version 330 core
layout (location = 0) in vec3 aPos;
void main()
{
gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0);
}The vertices in the code which we set:
float vertices[] = {
-0.5f, -0.5f, 0.0f,
0.5f, -0.5f, 0.0f,
0.0f, 0.5f, 0.0f
}; Are object space vectors (in relative to the object’s origin), then they are projected to the camera space through some processing in the vertex shader