4 ms·
Why didn't they ever implemented a rectangle primitive to be drawn instead of a triangle ? Anyway, here the perf impact is negligible
by ttoinou 4y ago
Why didn't they ever implemented a rectangle primitive to be drawn instead of a triangle ? Anyway, here the perf impact is negligible
- delusional 4y agoA triangle is the simpleste polygon. As soon as you start doing quads the complexity skyrockets: what if it self intersects? What if it's concave? What does a winding order mean when the verts can be all out of order?
- jbverschoor 4y agoTriangles are used to render 3d meshes because of that yes. However, the article is about "Full screen post processing effects", which is easier done in a rectangle
- fooker 4y agoPost processing is often used to generate textures for deferred rendering.
- Jasper_ 4y agoDo you mean a bounding rectangle? That exists on a lot of GPUs, where you draw a triangle and the entire bounding box surrounding the triangle is covered. However, the details differ greatly between different GPUs, meaning it's hard to standardize. Full-screen triangles are just fine.
- st_goliath 4y agoTriangles in 3D euclidean space have the advantage of being uniquely defined by 3 vertices that have the nice property of always sitting on a single plane. There's no linear transformation you could apply that results in something other than a well-defined, planar triangle. The worst that might happen is collapsing it into a line or a point. The same cannot be said for quads. If you e.g. have 4 vertices where 3 are sitting on the same plane, but the 4th isn't, there are 2 different, possible ways to subdivide this into triangles. In addition to all the possible non-linear surfaces one might image occupying that space. Old OpenGL and Direct3D versions did have quad and arbitrary polygon rendering support. IIRC from vague memory, the above scenario was something you were supposed to avoid and results varied between graphics card vendors. On a side note: If we are talking purely 2D, some old 2D software rendering systems used trapezoids as basic primitives, defined by their top and bottom edges. For instance, the X11 XRender API explicitly supports drawing trapezoids. They are easy to rasterize, interpolate across and quite flexible. Many other 2D shapes can be conveniently composed from them, including screen space triangles, if you were to implement a software rasterizer.
- ttoinou 4y agoOf course you're right but I was thinking about a subset of features for quads for this kind of use case. But yeah for all features triangles are better !
- Jasper_ 4y agoThe OpenGL specification basically had no explanation of what a "Quad" was, it didn't say anything about how to render quads, interpolate quads, etc. Pretty much every driver implemented quads as a funky way of spelling "two triangles". Much like tristrips/trifans/etc., index buffers give you all of the benefits with none of the drawbacks. > For instance, the X11 XRender API explicitly supports drawing trapezoids. It should be said XRender trapezoids have extra constraints: the top and bottom edges of the trapezoid must be completely straight (go exactly left to right). So it's basically a rectangle with sloped left/right sides. This makes it extremely easily to software rasterize, while you can still break each trapezoid into two triangles for 3D hardware.
- lmm 4y ago> It should be said XRender trapezoids have extra constraints: the top and bottom edges of the trapezoid must be completely straight (go exactly left to right). So it's basically a rectangle with sloped left/right sides. Isn't that just the definition of a trapezoid? Do you mean the top and bottom have to be parallel with the x axis or something?
- mananaysiempre 4y ago> Old OpenGL and Direct3D versions did have quad and arbitrary polygon rendering support. I vaguely recall that at different times people tried to build both PC and phone graphics hardware around quads and basically failed, but I don’t know why that didn’t work (aside from the issues of geometry that you mention).
- Keyframe 4y agoSega Saturn being a notable example.
- jra101 4y agoNVIDIA has an OpenGL extension that does just that [1]. [1] https://registry.khronos.org/OpenGL/extensions/NV/NV_fill_rectangle.txt https://registry.khronos.org/OpenGL/extensions/NV/NV_fill_re...
- fooker 4y agoEvery three points forms a triangle where all points are on a single plane. This makes interpolation for normals, texture, etc trivial. This is not true for every 4 points.
- tverbeure 4y agoNvidia's NV1 used quads as primitive. Shortly after its release, in 1995, Microsoft introduced DirectX which was triangle based. It didn't do well...