问题
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.
I came to the conclusion that:
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.
回答1:
Are you certain that your screen space spans -1 to 1 rather than -0.5 to 0.5?
Try just subtracting 0.5 from both x and y.
回答2:
Fixed the problem, I did not call gl viewport which was the reason the coordinate system wasn't applied to the fbo texture size
来源:https://stackoverflow.com/questions/41938722/opengl-render-vertex-at-uv-coordinate