jaiesh
jaiesh

Reputation: 146

Clipping Space In OpenGL Pipeline

How does clipping and projecting work in a simplified explanation? It has something to do with normalizing the vertices and matrix multiplication that involves dividing x,y,z by a 4th variable. I am having trouble understanding what actually happens.

Upvotes: 0

Views: 776

Answers (1)

fraillt
fraillt

Reputation: 318

Its pretty simple. Clipping is process that says if primitive (point, line or triangle) is visible. (and is done after modelview* projection matrix transformation) if triangle is partially visible, triangle is split into more triangles that fit in frustum.

After clipping is done, we need to normalize vertex (x,y,z,w) coordinates in order to project them to screen (window coordinates). This is called perspective division: new coordinates is x,y,z,1 = x/w, y/w, z/w, 1. Windows coordinates are dependant on viewport settings, and transformation is very simple.

window_x = viewport_x + vertex_x * half_viewport_width + half_viewport_width;
window_y = viewport_y + vertex_y * half_viewport_height + half_viewport_height;

Upvotes: 5

Related Questions