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

Author Topic: SetSmooth - default to false  (Read 8267 times)

0 Members and 1 Guest are viewing this topic.

renton_django

  • Newbie
  • *
  • Posts: 8
    • View Profile
SetSmooth - default to false
« on: March 03, 2011, 06:22:14 pm »
More of a minor config request than a feature request.

I think the Image SetSmooth feature should default to false. Most 2d developers try to be pixel perfect with their sprites and graphics, so trying to figure out why their sprites are blurry and scaled can be a bit of an obstacle to developers that are trying to learn SFML. Searching "SetSmooth" on the forums shows many cases of these issues.

It's an amazing feature, but I think it is too case specific to be turned on by default.

Lupinius

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
SetSmooth - default to false
« Reply #1 on: March 03, 2011, 06:39:34 pm »
Signed. Wanted to post the same thing just now actually  :lol:
Also why does the smoothing even make the edges of sprites visible?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SetSmooth - default to false
« Reply #2 on: March 03, 2011, 07:10:42 pm »
Quote
I think the Image SetSmooth feature should default to false. Most 2d developers try to be pixel perfect with their sprites and graphics, so trying to figure out why their sprites are blurry and scaled can be a bit of an obstacle to developers that are trying to learn SFML

I'm not sure it is the majority of developers. I guess I should open a poll, and see the results.

Quote
Also why does the smoothing even make the edges of sprites visible?

I'm not sure, but maybe it is fixed in SFML 2.
Laurent Gomila - SFML developer

devlin

  • Full Member
  • ***
  • Posts: 128
    • View Profile
SetSmooth - default to false
« Reply #3 on: March 03, 2011, 07:33:11 pm »
Quote from: "Lupinius"
Also why does the smoothing even make the edges of sprites visible?

You usually get that effect when using bilinear filtering and not having wrapping mode set to "gl_clamp" (i.e. gl_repeat or gl_clamp_to_border with a border-color set to a visible color) (if the texcoords go outside the 0.0 - 1.0 range or you rotate/scale the sprite)

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
SetSmooth - default to false
« Reply #4 on: March 03, 2011, 08:52:22 pm »
Quote from: "Laurent"
Quote
I think the Image SetSmooth feature should default to false. Most 2d developers try to be pixel perfect with their sprites and graphics, so trying to figure out why their sprites are blurry and scaled can be a bit of an obstacle to developers that are trying to learn SFML

I'm not sure it is the majority of developers. I guess I should open a poll, and see the results.
I agree with renton_django. There are again and again SFML users who stumble upon this (examples: 1 2  3 4 5 6 7 8 9, and that's just a small part I've found). In my opinion, the default behaviour should try to render 1:1, without applying any filters. In fact, I have mostly disabled SetSmooth() myself.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SetSmooth - default to false
« Reply #5 on: March 03, 2011, 11:14:27 pm »
Quote
There are again and again SFML users who stumble upon this (examples: 1 2 3 4 5 6 7 8 9, and that's just a small part I've found)

Ok but we don't how many there would be (asking for smoothing by default) if I changed. Could be more.

Quote
In my opinion, the default behaviour should try to render 1:1, without applying any filters.

The problem is that when you rotate or scale, it quickly becomes ugly without bilinear filtering.

And most of the topics you're referring to have the border problem, which is (normally) solved in SFML 2, without disabling smoothing.
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
SetSmooth - default to false
« Reply #6 on: March 04, 2011, 03:19:38 am »
Quote from: "Laurent"
Ok but we don't how many there would be (asking for smoothing by default) if I changed. Could be more.
This is of course true, however the status quo is an indication that the semantics of SetSmooth() are not very intuitive for beginners. Even if they remain the same, you should probably emphasize them in the tutorials and documentation.

Quote from: "Laurent"
And most of the topics you're referring to have the border problem, which is (normally) solved in SFML 2, without disabling smoothing.
Okay, that's good to hear :)

We have already had a discussion about pixel-perfect rendering some time ago, is it somehow related to the smooth filter? Do rotated sprites become ugly when either the smooth filter or the pixel interpolation is deactivated?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SetSmooth - default to false
« Reply #7 on: March 04, 2011, 07:47:02 am »
Quote
We have already had a discussion about pixel-perfect rendering some time ago, is it somehow related to the smooth filter?

Yes it is. I had a lot of fun trying to find an algorithm that makes both smoothed and non-smoothed sprites look good.

Quote
Do rotated sprites become ugly when either the smooth filter or the pixel interpolation is deactivated?

I don't use pixel interpolation anymore, I was getting unexpected bad results.
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
SetSmooth - default to false
« Reply #8 on: March 04, 2011, 11:56:37 am »
Does that mean that the rendering of sprites with disabled smooth filter is actually pixel-perfect? Or are there other factors coming into play?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SetSmooth - default to false
« Reply #9 on: March 04, 2011, 12:09:11 pm »
Since I've disabled pixel interpolation, you can get pixel-perfect rendering only if the sprites's coordinates are aligned with pixels. And in any case, if you scale or rotate it you can't get pixel-perfect results; except in special cases like scaling by an integer factor, or rotating by a multiple of 90 degrees.

By the way, it's more "pixel alignment" than "pixel interpolation" ;)
In fact we can say that pixel interpolation happens when I disable pixel alignment. I just realized that it was probably confusing in my previous posts.
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
SetSmooth - default to false
« Reply #10 on: March 04, 2011, 02:18:18 pm »
I have understood pixel interpolation like this: If a white point on a black background is offset by 0.5 (i.e. non-integral coordinate), you see two gray pixels. The other way would be rounding (aligning?) to integral coordinates, so that you see a single white pixel.

And I thought you would currently use "interpolation" (according to my above definition), right? Sorry for the confusion :)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SetSmooth - default to false
« Reply #11 on: March 04, 2011, 02:22:37 pm »
Ok yes, you're right. I've disabled my custom pixel rounding algorithm, now texels are interpolated if they fall in between two pixels -- this is the default OpenGL rasterization behaviour.

Hope everything's clear now :)
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
SetSmooth - default to false
« Reply #12 on: March 04, 2011, 03:08:04 pm »
Yes, thank you :)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: