Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
406 views
in Technique[技术] by (71.8m points)

fbo - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...