Jump to content
  • Advertisement
Sign in to follow this  
Trillian

OpenGL 2D pixel perfect scenegraph rendering

This topic is 3678 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

Hello, I've made a few attempts at making 2D games using 3D APIs (mostly opengl) and, while I've succeeding in coding the game itself, the graphics part never seemed right. Texture pixels were huh... shivering, when anything moved. I came to understand that 2D rendering could only look nice when pixel-perfect. A 32x32 texture should take precisely 32x32 pixels on screen, and the coordinates of these sprites should be rounded so that no pixels gets rendered at positions like (35.782, 203.439). With that in mind, how is it possible to build a 2D scenegraph system with hierarchic transformations of sprites that allow for translations, rotations and maybe scaling, or even just a camera that can zoom, without having a whole lot of pixel mapping artifacts? In the end, the coordinates must become whole pixel integers to have pixel-perfect rendering. How do complex 2D games manage this problem?

Share this post


Link to post
Share on other sites
Advertisement
As soon as you start transforming sprites (rotation, scaling, etc.) then obviously you're not going to be able to map each pixel to a single texel any more. You just have to make sure to use texture filtering and have good mipmaps (if you're scaling down) to get the best quality results.

Share this post


Link to post
Share on other sites
Can you still get it to "look good" even with trilinear filtering? I mean, if you take a sprite that was originally 32x32 pixels and display it as a 35x35 pixel quad rotated by 20 degrees, will it look good even with filtering?

So what is the approach of most 2D games, pixel-perfect rendering with no scaling/rotation effects or full effects with as much smoothing/filtering as possible to remove artifacts?

Share this post


Link to post
Share on other sites
Small scaling (like from 32x32->35x35) are a worst case, but it should still look good. It helps if you sprites are more vectory/cartoony rather than detailed pixel work, but you should get good results either way.

Personally I try and stick to pixel perfect drawing whenever possible (like for main character sprites, items and backgrounds) and use rotation and scaling for temporary, faster moving effects (like particles, explosions, debris, etc.) where the artifacts are less noticable. But it depends on your game really.

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!