I am learning programmable rendering pipeline by implementing a tiny software renderer. I try to implement it in a 'hardware' style. However, I am not familiar with the GPU pipeline and got some problems of homogeneous clipping.
The homogenous clipping space contains a w variable which various at each vertex. Is each vertex object's homogenous coordinate (between projection matrix and homogenous division by w) at its own clipping space? If so, how to clip the lines and triangles nearer than the Frustum or even stretching behind the camera (i.e. w <= frustum_znear)?
Update: this thread says that the clipping in homogeneous space is directly an intersection problem in the 4D homogeneous space. Which means the intersection point is p_vec4 = t * point1_vec4 + (1 - t) * point2_vec4
. Say I have P0(-70, -70, 118, 120)
and P1(-32, -99, -13, -11)
in 4D homogeneous space, and the intersection point with plane w = -z
(which in NDC is z = -1) is (-35, -96, -1, 0.9) t = 0.99
, how to get the corrresponding vertex object in NDC space?
And once I get the correct intersection point, should I do the interpolation between vertex objects produced by vertex shader to get new vertex object?