Live data from Hacker News

Bilinear interpolation on a quadrilateral using Barycentric coordinates

gpuopen.com

21–30 of 37 posts

Re: Bilinear interpolation on a quadrilateral using Barycentric coordinates

#21

I am definitely not an expert in 3D graphics... but this looks such an astonishingly simple and effective method, it makes me to question why this wasn't already thought of and picked up? I get that with fixed-pipeline GPUs you do what the hardware and driver make you do, but with the advent of programmable pipelines, you'd though improving stuff like this would be the first things people do? Anyway, gotta run and im…

Because when working with a textured asset, these seam distortions simply don't occur. The inverse of the distortion is baked into the texture map of the asset. So the distortion between a triangle's world-space size vs. its texture-space size cancels out exactly, and everything looks correct.

Okay, so the same idea that I spitballed in a sibling thread:

> Btw. wouldn't it be possible in modern pipelines to remap or "disfigure" the texture when converting to triangles, so that it counters the bias accordingly? Ah, but that bakes in the shape of the quad, so it can't be modified runtime or it will get distorted again, right.

How does that work with animated meshes?

Re: Bilinear interpolation on a quadrilateral using Barycentric coordinates

#23

This is one of those things that feels like a broken/half-assed/oversimplified implementation got completely proliferated into the world a long time ago and it took several years for the right person to do a full-depth mathematical analysis to reveal what we should've been doing all along. Similar to antialiasing and sharpening, texture filtering, color spaces and gamma correction, etc. It reminded me of this article…

It in no way replaces triangles, and very few will use it for good reason.

Why?

In many cases modern renders use triangles only a few pixels in size, you won't see C1 discontinuity at that size.

All the outer edges of quad still have C1 discontinuity between other quads, all it fixes is the internal diagonal

It has performance & complexity overhead

Re: Bilinear interpolation on a quadrilateral using Barycentric coordinates

#26

Earlier quoted context omitted.

Because when working with a textured asset, these seam distortions simply don't occur. The inverse of the distortion is baked into the texture map of the asset. So the distortion between a triangle's world-space size vs. its texture-space size cancels out exactly, and everything looks correct.

Okay, so the same idea that I spitballed in a sibling thread: > Btw. wouldn't it be possible in modern pipelines to remap or "disfigure" the texture when converting to triangles, so that it counters the bias accordingly? Ah, but that bakes in the shape of the quad, so it can't be modified runtime or it will get distorted again, right. How does that work with animated meshes?

If you animate the mesh in a non-affine way, then seams are inevitable. The quad-rendering technique described in the article wouldn't save you from that either: seams would appear where two quads meet.

Re: Bilinear interpolation on a quadrilateral using Barycentric coordinates

#27

Earlier quoted context omitted.

Ironically, back in the OpenGL 2.0 days, it was a lot easier to do things like this.

Well, technically the API is still available pretty much everywhere (be it directly or via a wrapper library) and most hardware still has support for drawing lines, so it is still easy in current days to do things like this too :-P. I'm using it all the time when i want to draw lines in 3D. (though as far as lines and OpenGL is concerned i remember reading ages ago that not even SGI's implementation had full support…

The API still exists, but in most implementations things like line styles and thickness are no longer supported.

Re: Bilinear interpolation on a quadrilateral using Barycentric coordinates

#28
To answer some of the questions here, the reason this has not been used before is because this technique requires being able to access the quad definitions (ie. which 4 vertices makeup each quad) within the gpu.

Up until recently with Mesh Shaders, there's really just been no good way to send this data to the GPU and read back the barycentric coordinates you need in the fragment shader for each pixel.

The article offers several options, to support older GPUs, like Geometry Shaders and Tesselation shaders. This is good, but these are really at best Terrible Hacks(tm). Proof of the ability to contort old extensions is not proof of reasonable performance!

Notably, geometry shaders are notorious for bad performance, so the fact that they list them as a viable strategy for older devices makes it pretty clear they aren't thinking much about performance, just possible compatibility.

Still, I think this is very cool, and now that GPUs are becoming much more of a generic computing device with the ability to execute arbitrary code on random buffers, I think we are nearly at the point of being able to break from the triangle and fix this! We hit this triangulation issue several times on the last project, and it's a real pain.

Re: Bilinear interpolation on a quadrilateral using Barycentric coordinates

#29

This is one of those things that feels like a broken/half-assed/oversimplified implementation got completely proliferated into the world a long time ago and it took several years for the right person to do a full-depth mathematical analysis to reveal what we should've been doing all along. Similar to antialiasing and sharpening, texture filtering, color spaces and gamma correction, etc. It reminded me of this article…

For someone who wrote textured triangles on a 386:

First rule of computer graphics: lie

Second rule of computer graphics: lie

Third rule of computer graphics: lie

Re: Bilinear interpolation on a quadrilateral using Barycentric coordinates

#30
post #11

Earlier quoted context omitted.

Because there is no reason to not use triangles. Look at prideout's reply in the thread, the argument about having just one normal vector and the fact they can only describe one plane is huge. Unless you want more edge cases to deal with (hehe, pun intended), you're better off sticking to tris.

I know about the advantages and uniqueness properties of triangles. However, if the article is correct about that artists prefer using quads when editing (I know absolutely nothing about 3D editing, and didn't know that, I thought triangles are universal these days), something is clearly missing from the pipeline if a neatly mapping textures to quads, then converted to triangles ends up messing the interpolation. May…

Artists usually prefer quads, but it really depends on what they're doing. It's also not unusual for them to willingly create a model of mostly quads with tris in the mix at the same time.

In the end, the representation of a quad in a 3D modelling editor doesn't really matter. Be it an actual quad or 2 tris. Because any sane artist wants every quad to have 1 normal vec, if they want 2 on a quad they will happily use 2 tris instead.

It is a non issue.

(btw I have done plenty of 3D art for games, I have also made my own vk renderer, I don't see a problem with using tris in the end, even if "visual quads" do de-clutter my work and do help reasoning about the flow of the model at hand)

Post reply on HN