Jump to content
Posted 21 September 2012 - 06:07 AM
Posted 21 September 2012 - 06:16 AM
Posted 21 September 2012 - 06:51 AM
Edited by King_DuckZ, 21 September 2012 - 06:53 AM.
Posted 22 September 2012 - 12:42 PM
This is how OpenGL is specified - however, no-one actually does it that way (for eons). "Guard bands" are used ( http://en.wikipedia.org/wiki/Guard_band_clipping ). For normal frustum - there are no actual clip-planes used at all (even for near and far plane [i do not know any official names for it tho] - nowadays one can even turn that part off in OpenGL).
Hello everybody, I'm trying to figure out how to implement clipping in my code. My understanding is that when a triangle crosses a clipping plane (ie the frustum), new vertices are added to avoid disappearing triangles artifacts.
Posted 22 September 2012 - 01:34 PM
Ok, thanks for clarifying! I can't find it right now, but one of the tutorial I stumbled upon stated that clipping was necessary in order for the rasterizer to remain inside its buffer. Somehow, I understood it was my responsibility to do that, not the hardware's. All the better then, I'll just remove invisible polygons and leave partially visible polygons as they are!
It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.
Posted 22 September 2012 - 08:26 PM
Not exactly. The transformed vertices are in clip space, which is a 4D space where every 3D point has a w value. Clipping happens here. The perspective divide happens AFTER this (divide everything by w), bringing it to (eventually) NDC.
In GL, after your vertex shader, the transformed vertices are in Normalized Device Coordinates (NDC), which is a cube from (-1,-1,-1) to (1,1,1). Any primitives that clip the edge of this cube are handled appropriately by the GPU's rasterization hardware.