Rendering 2D sprites in a 3D world?

后端 未结 7 1167
情深已故
情深已故 2021-01-03 01:17

How do I render 2D sprites in OpenGL given that I have a png of the sprite? See images as an example of the effect I\'d like to achieve. Also I would like to overlay weapo

7条回答
  •  伪装坚强ぢ
    2021-01-03 01:36

    a) For the first case:

    That's not really 2D sprites. Those men seem to be rendered as single quads with a texture with some kind of transparency (either alpha test or alpha blending).

    Anyway, even a single quad can still be considered a 3D object, so for such situation you might want to treat it as one: track its translation and rotation and render it in the same way as any other 3D object.

    b) For the second case:

    If you want the gun (a 2D picture, I pressume) to be rendered in the same place without any perspective transformation, then you can use the same technique one uses for drawing the GUI (etc). Have a look at my post here:

    2D overlay on a 3D scene

提交回复
热议问题