简体   繁体   English

使用法线在opengl中使用.off

[英]Working with .off in opengl with normals

How can i put the right normals to the object? 如何将正确的法线放置到对象上? There is a way to transform from .off into an object that contains normals? 有一种方法可以将.off转换为包含法线的对象?

OFF files usually don't support special attributes per face or per vertex and thus have no normals. OFF文件通常不支持每个面或每个顶点的特殊属性,因此没有法线。

The simplest thing you can do is do simply calculate the normals yourself using one of the well-known and easy to implement face-normal algorithms. 您可以做的最简单的事情就是使用一种众所周知且易于实现的人脸法线算法自己计算法线。 Here are a few examples. 这里有一些例子。

You can also look at doing normals via a texture (aka bump mapping ). 您还可以通过纹理(也称为凹凸贴图 )查看法线。 You will basically need to generate a normal map of your models in a 3D program and be using some kind of perpixel shading and bind your shades to use the normal texture. 基本上,您将需要在3D程序中生成模型的法线贴图,并使用某种基于像素的阴影并绑定阴影以使用法线纹理。

The advantage to doing it that way is you can have higher detail without increasing the number of polygons. 这样做的好处是您可以在不增加多边形数量的情况下获得更高的细节。 You can do things like generate a single grainy bumpy stone pattern on a single flat polygon. 您可以执行类似在单个平面多边形上生成单个粒状颠簸石图案的操作。

Also if you generate your normals procedurally you can't mix flat and smooth shading. 同样,如果您以程序方式生成法线,则不能混合使用平滑阴影。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM