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

Categories

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

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

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...