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

Author Topic: Black outline when rendering sprite  (Read 10025 times)

0 Members and 1 Guest are viewing this topic.

nonexistent

  • Newbie
  • *
  • Posts: 14
    • View Profile
Black outline when rendering sprite
« on: March 09, 2010, 10:36:33 pm »
Hi, I'm getting a black outline on a sprite when rendering in SFML.  The original grass image looks like:



and rendered in SFML looks like:



The sprite is loaded into an Image, stuck in a Sprite, and rendered with RenderWindow's Draw().  I haven't calling any resizing or scaling functions on the sprite.

I'm guessing this is some sort of side effect of the alpha blending in the sprite blend mode.  Any ideas to minimize this unwanted outline?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Black outline when rendering sprite
« Reply #1 on: March 09, 2010, 11:14:58 pm »
You can try this:
Code: [Select]
image.SetSmooth(false);
Laurent Gomila - SFML developer

nonexistent

  • Newbie
  • *
  • Posts: 14
    • View Profile
Black outline when rendering sprite
« Reply #2 on: March 10, 2010, 02:36:08 am »
Calling SetSmooth(false) on the image resulted in no graphical difference unfortunately  :(  None of the sprite Blend Modes aside from Alpha seem to allow transparency, so that's no good either.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Black outline when rendering sprite
« Reply #3 on: March 10, 2010, 08:26:52 am »
Is the first image that you posted the original one? If not, can you upload it?
Laurent Gomila - SFML developer

nonexistent

  • Newbie
  • *
  • Posts: 14
    • View Profile
Black outline when rendering sprite
« Reply #4 on: March 10, 2010, 08:59:57 am »
Yes, that is the exact image I am loading from file.  Thanks for the quick replies so far!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Black outline when rendering sprite
« Reply #5 on: March 10, 2010, 09:12:50 am »
I've tested the image and can't see any outline.

Quote
I haven't calling any resizing or scaling functions on the sprite

What about your window, is it resized after creation?
Do you use a view?
Laurent Gomila - SFML developer

nonexistent

  • Newbie
  • *
  • Posts: 14
    • View Profile
Black outline when rendering sprite
« Reply #6 on: March 12, 2010, 03:40:29 am »
Hmm, very interesting.  I made a mistake posting the original image, that's not the one I am loading in my file.  I extended the image size to the closest powers of 2 to make it 256x64.  The loaded 256x64 image displays the black outline problem, but loading the original 224x43 image renders correctly.

Does SFML do something special internally w/ power of 2 textures?  I've been manually image editing all my textures to be powers of 2 to account for older graphics cards.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Black outline when rendering sprite
« Reply #7 on: March 12, 2010, 07:55:04 am »
Quote
Does SFML do something special internally w/ power of 2 textures?

No, it should make no difference.

Quote
I've been manually image editing all my textures to be powers of 2 to account for older graphics cards.

You don't have to do that, this is automatically handled by SFML.

Can you upload the 256x64 image that causes the problem?
Laurent Gomila - SFML developer

nonexistent

  • Newbie
  • *
  • Posts: 14
    • View Profile
Black outline when rendering sprite
« Reply #8 on: March 12, 2010, 08:10:20 pm »
Here is the 256x64 image


It is the same as the original except padded w/ additional transparent pixels.

Trass3r

  • Jr. Member
  • **
  • Posts: 91
    • View Profile
Black outline when rendering sprite
« Reply #9 on: March 13, 2010, 04:46:42 am »
I've had the same problem for quite a while. Disabling smoothing indeed solves the outline problem but it makes the graphics look more pixelated (cause they are from an old game) :(

with smoothing (standard):


disabled smoothing:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Black outline when rendering sprite
« Reply #10 on: March 13, 2010, 10:36:35 am »
I see.

This is the kind of problems that you can expect with SFML 1 (unfortunately), but this is already fixed in SFML 2.
Laurent Gomila - SFML developer

Trass3r

  • Jr. Member
  • **
  • Posts: 91
    • View Profile
Black outline when rendering sprite
« Reply #11 on: March 13, 2010, 11:58:38 am »
No. I'm using (D)SFML2  :wink:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Black outline when rendering sprite
« Reply #12 on: March 13, 2010, 04:23:32 pm »
Quote from: "Trass3r"
No. I'm using (D)SFML2  :wink:

Ah... you should have said it before ;)
Can you send me your tileset?
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Black outline when rendering sprite
« Reply #13 on: March 13, 2010, 04:56:02 pm »
I have no problem with your tiles. Make sure that your coordinates are properly aligned with the pixels of the window (no decimal coordinates).
Laurent Gomila - SFML developer

Sivak

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Black outline when rendering sprite
« Reply #14 on: March 18, 2010, 12:15:25 am »
Hey all.  Sorry to jump in, but I've gotten graphics to display and I wondered if there's a way to have EVERY image loaded with setsmooth to false?  It fixed 2 problems I had with what I was going for displaying.

 

anything