Don Collins Posted March 8, 2015 Share Posted March 8, 2015 Hello, folks. I'm hoping to use Pixi to make some games with pixelated retro-style graphics. I'm using a scaled DisplayObjectContainer to accomplish this, but I've run into the problem that, if sprites have a non-integer position (or their anchor doesn't fall exactly on a pixel boundary), they are accordingly drawn offset slightly from the scaled pixel boundaries and so overlap pixels in an ugly way. This isn't acceptable for a retro aesthetic, of course, so I wanted a robust way to clamp positions to integer values. I hoped I would solve the problem by using the renderSession.roundPixels property (which promises "crisp pixel art" and seems intended for this purpose), but I found that it (1) doesn't seem to work at all on WebGL, and (2) works on canvas only when the offset is caused by the sprite's anchor rather than position. Hopefully an example will illustrate what I mean: http://don.nfshost.com/roundPixels-bug-demo/ (I've also attached the source as a zip file.) It shows a WebGL renderer with a sprite displaced via anchor, a Canvas renderer with a sprite displaced via anchor, and a Canvas renderer with a sprite displaced via position. The second of these is the only one in which roundPixels appears to be doing its job. Is this a bug, or am I just misusing roundPixels/misunderstanding what it's meant to accomplish? Thanks!roundPixels-bug-demo.zip Quote Link to comment Share on other sites More sharing options...
digibo Posted March 11, 2015 Share Posted March 11, 2015 I found out that renderSession.roundPixels is always false in the WebGL Renderer, so I edited the pixi sources a bit to add it as an option. As to why it only works for anchor and not position, I have no idea there ;/ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.