#When should I clip vertices
16 messages · Page 1 of 1 (latest)
OpenGL 4.6 core spec section 13.7 talks about clipping
tinygl has example of clipping implementation in https://github.com/ska80/tinygl/blob/master/src/clip.c
What kind of 3D library are you working on? Typically you need clipping only with software rasterization, otherwise you can almost always rely on the GPU to do the clipping for you.
Sorry for being late but I'm trying to make a 3D library in the windows console ( I know its bad ) so I need to know how to discard triangles completely outside the view, but re work the vertices of ones intersecting the view planes
You could still use for example GL for rendering, then read framebuffer pixels and output to console.
If you choose to do software rasterization, then tinygl is good regeference I guess.
There is also this thing called guard band clipping https://en.m.wikipedia.org/wiki/Guard-band_clipping
Guard band clipping is a technique used by digital rendering hardware and software designed to minimize the amount of clipping performed. Instead of clipping polygons that extend out of the viewport, polygons are only clipped if they extend past a guard band. Clipping is still needed to prevent integer overflow in the rasterizer. The guard band ...
I am not sure how widely it is used with software rasterizers or of tinygl uses it.
Gurad-Band clipping is just an optimization, it doesn't prevent clipping altogether. you really have to deal with the w<=0 case accordingly
and one of course clips in clip space (hence the name)
geometry after the division is butchered for the w <=0 case
yeah you want test your clipper with some tricky triangles, like one with vertices in both sides of the near plane