Search code examples
openglfbo

OpenGL | Render Vertex at UV coordinate


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.

enter image description here

enter image description here

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:

enter image description here

…while it should should look like this:

enter image description here

It seems like it's scaled up. I dont know where the problem is.


Solution

  • Fixed the problem, I did not call gl viewport which was the reason the coordinate system wasn't applied to the fbo texture size