简体   繁体   English

如何在 3d Sphere 上绑定 2D 纹理

[英]how to bind 2D texture on 3d Sphere

I am done with my sphere,its movements and all .我已经完成了我的球体,它的运动和所有。 I am just struck on texture stuff.我只是对质地的东西感到震惊。 Not able to load even a simple texture.即使是简单的纹理也无法加载。 So anyone have any idea about it enlighten me.所以任何人都对它有任何想法启发我。

I would like to give u very basic Info:我想给你非常基本的信息:

First of all you need to learn about texture coordinates.首先,您需要了解纹理坐标。 It will have x and y components.Both components will range 0 to 1.它将有 x 和 y 分量。两个分量的范围都是 0 到 1。 基本纹理

To add texture to any mesh/object you need provide texture coords.For simple rectangle mesh with image, they will be (0,0),(1,0),(1,1),(0,1)要将纹理添加到任何网格/对象,您需要提供纹理坐标。对于带有图像的简单矩形网格,它们将是 (0,0),(1,0),(1,1),(0,1)

Like wise you need to calculate tex coords for your sphere also.同样,您还需要为您的球体计算 tex 坐标。 U can do the same while generating vertices for your sphere.你可以在为你的球体生成顶点时做同样的事情。 These generated tex coords which will have their X and Y components in range [0,1] and wrap given rectangular/square image around the sphere.这些生成的 tex 坐标的 X 和 Y 分量将在 [0,1] 范围内,并将给定的矩形/正方形图像包裹在球体周围。

Sample flow: tex corrds array -> vbo ->shader -> shader sampler -> pixel set to framebuffer示例流程:tex corrds 数组 -> vbo -> 着色器 -> 着色器采样器 -> 像素设置为帧缓冲区

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

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