低多边形锥 - 在尖端平滑阴影 [英] Low polygon cone - smooth shading at the tip

查看:221
本文介绍了低多边形锥 - 在尖端平滑阴影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您细分缸到8面棱镜,计算顶点的法线根据其位置(平滑着色),它看起来pretty的好。

If you subdivide a cylinder into an 8-sided prism, calculating vertex normals based on their position ("smooth shading"), it looks pretty good.

如果您细分锥到8棱锥,计算的基础上自己的立场法线,您遇到的锥(锥技术上顶点的小费,但让我们把它叫做技巧,以避免混淆网格顶点)。

If you subdivide a cone into an 8-sided pyramid, calculating normals based on their position, you get stuck on the tip of the cone (technically the vertex of the cone, but let's call it the tip to avoid confusion with the mesh vertices).

对于每一个三角形的脸,你想匹配沿着两边的法线。但是,因为你只能指定一个正常的三角形的每个顶点,你可以匹配一个边缘或其他,但不能两者兼得。您可以通过选择一个提示正常的,是两个边的平均妥协,但现在没有你的边缘看起来不错。下面是选择平均正常为每个尖端顶点看起来像的细节

For each triangular face, you want to match the normals along both edges. But because you can only specify one normal at each vertex of a triangle, you can match one edge or the other, but not both. You can compromise by choosing a tip normal that is the average of the two edges, but now none of your edges look good. Here is a detail of what choosing the average normal for each tip vertex looks like.

在一个完美的世界中,GPU可以栅格化真四,不仅是三角形。然后,我们可以用一个简并四指定每个面,使我们能够指定一个不同的标准对每个三角形的两个相邻的边缘。但我们所用是三角形的工作...我们可以降低锥体成多个栈,使边缘不连续性是仅在圆锥的顶端可见,而不是沿整个事情,但仍然会有一个小费!

In a perfect world, the GPU could rasterize a true quad, not just triangles. Then we could specify each face with a degenerate quad, allowing us to specify a different normal for the two adjoining edges of each triangle. But all we have to work with are triangles... We can cut the cone into multiple "stacks", so that the edge discontinuities are only visible at the tip of the cone rather than along the whole thing, but there will still be a tip!

任何人有任何技巧平滑上色低多边形锥?

Anybody have any tricks for smooth-shaded low-poly cones?

推荐答案

是的,可以肯定的是三角形的限制。我想展示你接近从圆筒锥使问题相当清楚的问题:

Yes, it certainly is a limitation of triangles. I think showing the issue as you approach a cone from a cylinder makes the problem quite clear:

下面的一些事情,你可以尝试...

Here's some things you could try...

  1. 使用四边形(如@WhitAngl说)。管它什么新的OpenGL,还有的的为一个四边形使用后所有。

  1. Use quads (as @WhitAngl says). To hell with new OpenGL, there is a use for quads after all.

细化多一点均匀。设置在正常尖端一个共同的向上向量中移除任何恶劣的边缘,虽然看起来有点怪对抗​​不亮的一面。很不幸,这违背了你的问题的标题,低多边形锥的。

Tessellate a bit more evenly. Setting the normal at the tip to a common up vector removes any harsh edges, though looks a bit strange against the unlit side. Unfortunately this goes against your question title, low polygon cone.

确保您的圆锥体周围的物体空间的原点中心(或程序上产生它的顶点着色器),使用该片段的位置,产生正常的......

Making sure your cone is centred around the object space origin (or procedurally generating it in the vertex shader), use the fragment position to generate the normal...

in vec2 coneSlope; //normal x/z magnitude and y
in vec3 objectSpaceFragPos;

uniform mat3 normalMatrix;

void main()
{
    vec3 osNormal = vec3(normalize(objectSpaceFragPos.xz) * coneSlope.x, coneSlope.y);
    vec3 esNormal = normalMatrix * osNormal;
    ...
}

也许有一些花哨的技巧,你可以做,以减少片段着色器OPS了。 此外,还有镶嵌更VS更昂贵的着色器的整体平衡。

Maybe there's some fancy tricks you can do to reduce fragment shader ops too. Then there's the whole balance of tessellating more vs more expensive shaders.

一个圆锥体是一个相当简单的对象,而我喜欢挑战,在实践中,我不能看到这是一个问题,除非你想锥的许多的。在这种情况下,你可能会进入几何着色器或实例化。更重要的是,你可以借鉴使用四边形的锥体和光线投射在片段着色器隐锥。如果锥都在飞机上,你可以尝试法线贴图,甚至视差贴图。

A cone is a fairly simple object and, while I like the challenge, in practice I can't see this being an issue unless you want lots of cones. In which case you might get into geometry shaders or instancing. Better yet you could draw the cones using quads and raycast implicit cones in the fragment shader. If the cones are all on a plane you could try normal mapping or even parallax mapping.

这篇关于低多边形锥 - 在尖端平滑阴影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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