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

Author Topic: Texture rendering issues (SFML .Net)  (Read 122 times)

0 Members and 1 Guest are viewing this topic.

Kirtsata

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Texture rendering issues (SFML .Net)
« on: September 02, 2019, 09:08:42 am »
To keep this short, I'll give a very brief explanation of the problem:
I am making a little game project, however something with the transparency goes wrong around the edges.

Textures that have their Smooth factor set to false, sometimes end up looking a little, distorted.


Textures that have their Smooth factor set to true, while fixing the previous problem now sometimes have some artifacts around the edges.


While this issue is not in effect at all times, it happens when the player is moving at specific places.

Some additional info: I tried adding ContextSettings with AntialiasingLevel set to 8, which didn't seem to change anything.

Any help will be greatly appreciated ;D

Hapax

  • Hero Member
  • *****
  • Posts: 2765
  • My number of posts is shown in hexadecimal.
    • View Profile
Re: Texture rendering issues (SFML .Net)
« Reply #1 on: September 04, 2019, 12:51:56 am »
Setting anti-aliasing for a context only applies to edges of triangles, not the textures themselves.

Without smooth, there can be slight 'distortions' in the texture. This is when rows or columns of pixels of the texture are doubled (or more) or missing due to resizing. Remember that if you stretch a texture so that it is one pixel larger, one of the lines of pixels must be doubled to fill that space.

With smooth, the problem mention above are gone but since it achieves smoothness by using pixels around the one it actually wants, it will tend to 'pull in' some of the image around the texture rectangle (the part you want).
A couple of quick solutions for this are:
1) add a pixel width border around each texture section that you use. This border should duplicate the pixels of the texture so that the outer edge of pixels is now twice as thick.
2) bring in the texture rectangle slightly so that when it 'looks further', it will still be within the wanted part. How far you have to 'bring it in' could be affected by a few things but a single pixel on each edge should be fine.

It tends to happen more often when the position too is not set to an integer value. Other things like size, scale etc. should also end up with the texture being at integer values to remove any chance of artifacts.
Selba Ward - SFML drawables
Kairos - Timing Library
Rectangular Boundary Collision - Rectangular SAT Collision

@Hapaxiation - Hapaxia on Twitter

Kirtsata

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: Texture rendering issues (SFML .Net)
« Reply #2 on: September 04, 2019, 06:15:20 pm »
It tends to happen more often when the position too is not set to an integer value.
This. Thanks a bunch for the heads up!

Hapax

  • Hero Member
  • *****
  • Posts: 2765
  • My number of posts is shown in hexadecimal.
    • View Profile
Re: Texture rendering issues (SFML .Net)
« Reply #3 on: September 04, 2019, 06:24:02 pm »
I should just clarify that by those values should map to integer values for pixels. A view can also move integer values 'off pixel'.
Selba Ward - SFML drawables
Kairos - Timing Library
Rectangular Boundary Collision - Rectangular SAT Collision

@Hapaxiation - Hapaxia on Twitter

 

anything