如何在GLGravity Teapot iphone 中应用纹理图像?
对于 openGl 示例,Xcode 给出了一个项目 GlGravity。但是如何在没有纹理坐标的情况下应用纹理图像而不是显示黄色?
For openGl expample, Xcode given a project GlGravity. But Instead of showing yellow color how to apply a Texture image without textureCoordinates?.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要某种纹理坐标,否则纹理的整个概念就没有意义:纹理是将一组 n 坐标映射到由样本数据定义的某个值(深度、亮度、alpha、颜色或这些值的组合)的函数取自并插值。
您可以从网格静态生成纹理坐标,也可以在顶点着色器中生成纹理坐标。或者您直接向他们提供。但是您需要一些纹理坐标才能完成这项工作。一个非常便宜且简单的纹理坐标生成器是使用顶点位置作为纹理坐标;这会将您的纹理沿着坐标轴投影到模型上。因此,如果您有 2D 纹理,它将应用于 XY 平面,就好像在坐标 (0,0,\无穷大) 处有一个平行投影幻灯片投影仪一样。
You need some kind of texture coordinate, otherwise the whole concept of textures makes no sense: A texture is a function mapping a set of n coordinates to some value (depth, luminance, alpha, colour or combination of those) defined by data the samples are taken from and interpolated.
You can generate the texture coordinates, either statically from your mesh, or in the vertex shader. Or you supply them directly. But you need some texture coordinates to make this work. A very cheap and simple texture coordinate generator is using the vertex position as texture coordinate; this will project your texture along the coordinates axes onto the model. So if you've got a 2D texture it will be applied in the XY plane, as if there were a parallel projecting slide projector at coordinates (0,0,\infinity).