7. Before going deeper tell me all the stages in the Pipeline. First you said, Vertex shader. Then, is it fragment shader?
No, I was wrong. The order s like this.
Vertex Shader -> Primitive Assembly -> Rasterization -> Fragment Shader -> Per-Fragment Operations->Frame Buffer.
8. So, we give our model as array of vertices with all the Matrices and shaders to Vertex shader. And it emits “varyings” and gl_Position, you said. What happens after that?
Primitive Assembly is this stage. What you mean by primitives are triangle, line and points. From what I understand now is, the gl_positions still stay in the 3D space. (That means, how I understood projection matrix was wrong) And the shaded vertices of the model are assembled into individual geometric primitives. The primitives are “clip”ped and “cull”ed before sent to the next stage.
9. What the hell is Clipping?
When you apply projection matrix, few vertices would go out of the view spectrum. When the assembler creates primitives with those vertices, part of / the whole primitives may go out of the view spectrum. So, those primitives are clipped. This is called clipping. After this state the vertices are converted to screen coordinates.
10. So who will explain me about culling?
This happens in the screen coordinate space. It is discarding primitives which are backward facing. It is like not considering back side of a polygon model when camera looks at the front side.
11. What the the next stage after Primitive Assembly?
The primitives are converted into a 2 dimensional fragments, which are then processed by fragment shader. These 2 dimensional fragments represents pixels that can be drawn on the screen. This stage is called “Rasterization“.
12. What happens at the “Fragment Shader” module?
It can discard a fragment or generate a color value called gl_FragColor from the screen cordinates, color, depth, stencil values a fragment.
13. What happens to the shaded fragment then?
It is checked if the location of the fragment is owned by current OpenGL Context and if it is inside the OpenGL’s Scissor rectangle. After that stencil and depth tests are performed. (I have no idea what they are). After that the fragment color may be blended with the color which is already in the frame buffer at that position. Then something called “Dithering is done to reduce artifacts”. These steps are combinedly called Per-Fragment Stage.