问题描述
我正在使用OpenGL,需要在顶点的UV坐标下将3D模型的顶点渲染为FBO.为此,我首先必须将UV坐标空间转换为屏幕空间.
I'm using OpenGL and I need to render the vertecies of a 3D model to a FBO at the UV coordinate of the vertex. To do that, I first have to convert the UV coordinate space to the screen space.
我得出的结论是:
uv.x * 2 - 1
uv.y * 2 - 1
...应该可以解决问题.
…should do the trick.
我在顶点着色器中使用它来将顶点放置在这些新位置.结果看起来像这样:
I used that in my vertex shader to place the vertex at those new positions. The result looks like this:
…它应该看起来像这样:
…while it should should look like this:
似乎已扩大规模.我不知道问题出在哪里.
It seems like it's scaled up. I dont know where the problem is.
推荐答案
解决了该问题,我没有调用gl视口,这是坐标系未应用于fbo纹理大小的原因
Fixed the problem, I did not call gl viewport which was the reason the coordinate system wasn't applied to the fbo texture size
这篇关于OpenGL |在UV坐标处渲染顶点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!