Jump to content
  • Advertisement
Sign in to follow this  
Apollonio

OpenGL Rotate point sprite given a texture atlas

This topic is 835 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone

given:
- a textured point sprite (a circle) in 3D space with a normal
- a texture atlas with each sprite being a different rotation of that circle along X/Y axes (Z useless). first row all Y rotation, first column all X, and all the other combinations along the sheet.

I'd like to offset the right sprite for the point from the texture atlas given the position of the camera in the world.
I want to use textured sprites instead of quads for achieve maximum performance and given that i'm using VBO all the work must be done in vertex/fragment shader.
I'm bumping into several problems and would like to ask about some hints on this.
biggrin-new.png




(READ THIS ONLY AS AN EXTRA AND IF YOU HAVE TIME)

I write here some of the approaches I've thinked of and tryed.

- build a solidal system of axes to the normal (being the positive Z-axis, 1,0,0 for example). Get the angles between normal and the projection of the camera vector (from camera to the point, all in 3D) in the x-z plane, and y-z plane. These represent my rotation around Y and X axis (not properly, a sort of approximation).
problem -> this system works only on some cases and if you keep looking at the point (obviously). For example if you move near the X-Y plane looking at the point, you will get values not representative of the current rotation.

- given an X-Y-Z plane like up here, where Z is the normal vector, compute in which part of the unit circle the camera vector falls...then just map a sector to a sprite (i don't need many rotations...). 
In this case i don't have any idea about how to check in which sector on the sphere the point falls, nor mapping efficiently without an horrible if if if else....

Share this post


Link to post
Share on other sites
Advertisement
  • Relatively large sprites of a three-dimensional object as seen from a particular direction are usually employed as billboards with a normal that faces the camera. Seen from up close, billboards look bad because it becomes apparent that they are flat and "painted".
  • If each of your "circles" has its own arbitrary facing instead, they are going to look bad from most camera positions, not only close ones, because they are askew.
  • I want to use textured sprites instead of quads

    No, you are going to draw the sprites from your atlas as one quad (or one or two triangles), which is cheaper than a proper 3D geometry with more vertices, overdrawn pixels and less trivial fragment shaders than basic texture mapping.

You should post code (either of your lookup attempts could be correct, or quite close) and pictures of your spritesheet and of how your scenes look bad; there's no evidence of technical issues apart from trying a technique that is too cheap to look good for your needs.

Share this post


Link to post
Share on other sites

hi there

ty for replying
 

I'm not sure to have understood your answer.
My sprites are not gonna be seen up close as they represent vertices of a bigger 3d model...

I'm attaching a part of the sprite sheet to better illustrate my idea.

 

Immagine a 3d model...say a sphere (made of thousands of points). For each vertex (point sprite) I'll offset the right 'little circle' from the sheet to texture it, simulating the rotation that billboards don't allow...

Hope to have explained myself better.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!