GPU上与分辨率无关的立方贝塞尔曲线图(Blinn/Loop) [英] Resolution independent cubic bezier drawing on GPU (Blinn/Loop)

查看:230
本文介绍了GPU上与分辨率无关的立方贝塞尔曲线图(Blinn/Loop)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基于以下资源,我一直在尝试在GPU上使分辨率独立的三次贝塞尔曲线渲染正常工作:

Based on the following resources, I have been trying to get resolution independent cubic bezier rendering on the GPU to work:

GPU宝石3第25章

弯曲的蓝色

使用可编程图形硬件的分辨率独立曲线渲染

但是,正如Curvy Blues网站中所述,其他两个网站上的文档中都有错误.弯曲的布鲁斯(Curvy Blues)告诉我看看这些评论,但我似乎找不到这些评论.某个地方的另一个论坛也告诉我相同的事,我不记得那个论坛是什么.但是肯定有一些我想念的东西.

But as stated in the Curvy Blues website, there are errors in the documents on the other two websites. Curvy Blues tells me to look at the comments, but I don't seem to be able to find those comments. Another forum somewhere tells me the same, I don't remember what that forum was. But there is definitely something I am missing.

无论如何,我试图重新生成正在发生的事情,但我不理解从变换坐标组合的决定因素中计算出判别式的部分.

Anyway, I have tried to regenerate what is happening and I fail to understand the part where the discriminant is calculated from the determinants of a combination of transformed coordinates.

所以我有原始坐标,我将其粘贴在4x4矩阵中,使用M3-矩阵转换此矩阵并获得C矩阵. 然后,我根据C矩阵中的坐标创建3x3矩阵,并计算行列式,然后将其组合以创建二次方程式的a,b和c,这将帮助我找到根.

So I have the original coordinates, I stick them in a 4x4 matrix, transform this matrix with the M3-matrix and get the C-matrix. Then I create 3x3 matrices from the coordinates in the C-matrix and calculate the determinants, which then can be combined to create the a, b and c of the quadratic equation that will help me find the roots.

问题是,当我完全那样做时:判别是不正确的.我显然将蛇纹石的坐标(对称的,但是正确的蛇纹石)放入坐标中,但它指出这是一个风口浪尖. 当我自己使用wxMaxima进行计算时,得出一阶和二阶,然后计算叉积,简化为二次方程,当我输入相同的坐标时,该方程的判别式似乎是正确的. 当我强制代码使用我自己的判别式来确定它是否是蛇形的,但是我使用行列式来计算更多的k,l,m纹理坐标时,结果也是不正确的. 因此,我认为行列式中一定有一个错误.

Problem is, when I do it exactly like that: the discriminant is incorrect. I clearly put in coordinates for a serpentine (a symmetric one, but a correct serpentine), but it states it is a cusp. When I calculate it myself using wxMaxima, deriving to 1st and 2nd order and then calculating the cross-product, simplifying to a quadratic equation, the discriminant of that equation seems to be correct when I put in the same coordinates. When I force the code to use my own discriminant to determine if it's a serpentine or not, but I use the determinants to calculate the further k,l,m texture coordinates, the result is also incorrect. So I presume there must be an error in the determinants.

任何人都可以帮助我解决这个问题吗?

Can anyone help me get this right?

推荐答案

我想我已经解决了.结果接近完美(有时会倒过来,但这可能是一个不同的问题).

I think I have managed to solve it. The results are near to perfect (sometimes inverted, but that's probably a different problem).

这是我做错的地方,希望我能帮助别人不要浪费我所有的时间.

This is where I went wrong, and I hope I can help other people to not waste all the time I have wasted searching this.

我的代码基于blinn-phong文档. 我有坐标b0,b1,b2,b3.我曾经用w将它们视为2D坐标,但我更改了此视图,从而解决了问题.通过将它们视为z = 0的3D坐标,并使它们成为均匀的4D坐标进行变换(w = 1),可以得出解.

I have based my code on the blinn-phong document. I had coordinates b0, b1, b2, b3. I used to view them as 2D coordinates with a w, but I have changed this view, and this solved the problem. By viewing them as 3D coordinates with z = 0, and making them homogenous 4D coordinates for transformation (w = 1), the solution arrived.

通过计算C矩阵:C = M3 * B,我得到了这些新坐标. 在计算行列式d0,d1,d2,d3时,我习惯从C矩阵中的第0列和第1列获取x,y坐标,并从第2列获取w因子.考虑一下,坐标实际上是3D坐标,因此,对于w因子,应该取第3列,而忽略第2列.

By calculating the C matrix: C = M3 * B, I got these new coordinates. When calculating the determinants d0, d1, d2, d3, I used to take the x, y coordinates from columns 0 and 1 in the C matrix, and the w factor from column 2. WRONG! When you think of it, the coordinates are actually 3D coordinates, so, for the w-factors, one should take column 3 and ignore column 2.

这给了我正确的行列式,导致了一个判别式,该判别式能够弄清我正在处理的曲线类型.

This gave me correct determinants, resulting in a discriminant that was able to sort out what type of curve I was handling.

但是要注意,使我的搜索时间更长的一个事实是,我认为当它明显是蛇纹石时,判别结果应始终> 0(蛇纹石). 但是,情况并非总是如此,当您拥有一个数学上完美的sepentine(坐标是均值正好位于中间)时,行列式会说这是一个尖峰(行列式= 0).我曾经以为这个结果是错误的,但事实并非如此.所以不要被这个愚弄了.

But beware, what made my search even longer was the fact that I assumed that when it is visibly a serpentine, the result of the discriminant should always be > 0 (serpentine). But this is not always the case, when you have a mathematically perfect sepentine (coordinates are so that the mean is exact middle), the determinant will say it's a cusp (determinant = 0). I used to think that this result was wrong, but it isn't. So don't be fooled by this.

这篇关于GPU上与分辨率无关的立方贝塞尔曲线图(Blinn/Loop)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆