SFML community forums
Help => Graphics => Topic started by: BesomeGames on April 21, 2013, 06:21:01 am
-
Hello there,
I've run into an issue I am not sure how to fix and figured I should ask for some input. I am currently working on a 2D tile based game. Everything is designed and coded for 1920x1080 resolution and I use a View to adjust to different resolutions. I load tileset images and create the tiles from subrects. I had an issue previously with ugly borders on transparent images which I fixed by using a nearly black color as the alpha channel.
When I run the game in 1920x1080 everything looks great, as expected. The problem comes when I use lower resolutions. For example, my monitor is 1440x900, which would result in a downscale. With smoothing on the everything looks great, except I get black borders on some tiles:
(http://www.noblesland.com/images/alpha/smooth.jpg)
I have researched this and from what I have found the issue has to do with smoothing. If I disable it, the lines are no longer there but the tiles look awful:
(http://www.noblesland.com/images/alpha/no_smooth.jpg)
What exactly can I do in this situation? I have considered upgrading to SFML 2.0 and using RenderTexture to draw everything to an off screen buffer then applying smoothing to that, but from what I read nearly all Intel GPUs don't support that. I have also read I could potentially scale and cache the tiles at run time but I am unsure exactly how that would work. I also read something about the view potentially using floating point numbers, and I could remove the lines by down scaling and maintaining aspect ratio.
-
With enabled smoothing, pixels (or rather texels) outside the actual texture rect are also considered for rendering. One possibility would be to create a border around each texture rect with the same color, but it's rather a workaround.
The idea to use sf::RenderTexture is a good one. It's not true that it works on almost no Intel GPUs -- I have an integrated Intel card on my notebook, too, and it works flawlessly. Render textures are also useful if you want to apply global effects (shaders) to the whole scene.
And you should upgrade to SFML 2 anyway, it is much better (https://github.com/SFML/SFML/wiki/FAQ#wiki-grl-version) than 1.6.
-
Thanks for the great reply.
I agree, although adding a pixel border around the tiles would fix the problem it is rather hackish. I've put off upgrading to SFML 2.0 simply because the workload for the project is so high I haven't wanted to take the time.
For RenderTexture I was referencing this post:
http://en.sfml-dev.org/forums/index.php?topic=7407.0
I haven't found any news about better compatibility.