Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: setSmooth, seams on tiles.  (Read 2145 times)

0 Members and 1 Guest are viewing this topic.

bobblehat

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
setSmooth, seams on tiles.
« on: July 09, 2013, 02:14:59 am »
So, I've been working on a simple tile engine for a 2D platformer today. There's an odd issue I keep having.

Essentially my program renders a subsection of a spritesheet as a texture for each tile, by putting them into sprites and then iterating over a collection of sprites. I then move around the map using sf::View.

However, at no regular interval but frequent enough I have this happen:
http://imgur.com/K8vPPZd

This is a screenshot with setSmooth enabled for the tileTexture to show what I mean (I understand these artifacts with this enabled - some blurring between tiles of the spritesheet would be inevitable) -- but the problem is that it happens without it.

My view is the same size as the screen resolution, but centered on the ball sprite.

I'm assuming I can get around this by using a RenderTexture to draw the level into memory, and redrawing that as a single texture/sprite every frame, but it seems strange as to why this is happening.

It just crops up for a single frame, and then disappears.

Any help would be greatly appreciated.

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: setSmooth, seams on tiles.
« Reply #1 on: July 09, 2013, 02:50:27 am »
Back to C++ gamedev with SFML in May 2023

bobblehat

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: setSmooth, seams on tiles.
« Reply #2 on: July 09, 2013, 10:28:24 am »
The logic in that post does make sense - I'll have to convert to vertices instead.

Is there any reason Sprites don't take a FloatRect in their constructor, or automatically account for this? The comments in the code state that the IntRect in the constructor is to only show a specific part of the texture, which is exactly what I'm trying to do -- it just seems slightly silly that more pixels get displayed than I need, and a bit inconsistently.


eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: setSmooth, seams on tiles.
« Reply #3 on: July 10, 2013, 01:13:55 pm »
You should make sure that your view position are integers and since this can still lead to problems, I'd add a 1px wide border, only where the color should keep going, around the textures you're using.

It's a known issue with SFML and there hasn't really been a clean solution yet (that I know of).
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/