Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

extra pixels around edges of objects (Real Studio games Mailinglist archive)

Back to the thread list
Previous thread: Re: REALbasic-Games Digest #191
Next thread: SpriteSurface VS RB3D in oS X.3


Re: explosions   -   Jeff Quan
  extra pixels around edges of objects   -   Jeremy Smoler
   Re: extra pixels around edges of objects   -   Frank C.
    Re: extra pixels around edges of objects   -   Jeremy Smoler
     Re: extra pixels around edges of objects   -   Joseph J. Strout
   Re: extra pixels around edges of objects   -   Jeff Quan

extra pixels around edges of objects
Date: 25.01.04 03:45 (Sat, 24 Jan 2004 21:45:45 -0500)
From: Jeremy Smoler
I wrote in a few weeks ago about a problem I'm having: I'm using RB3D
to display 2D sprite graphics. Many of my sprites display with extra
pixels around their edges. These pixels follow the rectangular border
of the sprite image, but are not in the original image.

Joe suggested I try duplicating the problem in a simpler project.
Here's what I have now. I create a new RB project, put a new RB3DSpace
control in the default window, and put the following code in the
control's Open event handler:

Dim p As Picture
Dim obj As Object3D

p = NewPicture(16, 16, 24)
p.Graphics.ForeColor = &c000000
p.Graphics.FillRect 0, 0, p.Width, p.Height
p.Graphics.ForeColor = &c00FF00
p.Graphics.FillRect 4, 4, 12, 12

obj = New Object3D
obj.AddShapePicture p, 1

RB3DSpace1.SkyColor = &c000000
RB3DSpace1.AmbientLight = 90
RB3DSpace1.Objects.Append obj
RB3DSpace1.Camera.Position.Z = 100

Then I run the project. I see a green square on a black background, as
expected. I also see thin green lines above and to the left of the
square, and a faint green dot near the square's upper-left corner.
These last I do not expect to see. Any ideas where they are coming
from?

I am using REALbasic 5.2.4, Quesa 1.6d18, and OSX 10.3.2, on an iMac G4.

- - -
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: extra pixels around edges of objects
Date: 25.01.04 06:05 (Sun, 25 Jan 2004 00:05:52 -0500)
From: Frank C.
On 24-Jan-04, at 9:45 PM, Jeremy Smoler wrote:

> I wrote in a few weeks ago about a problem I'm having: I'm using RB3D
> to display 2D sprite graphics. Many of my sprites display with extra
> pixels around their edges. These pixels follow the rectangular border
> of the sprite image, but are not in the original image.

I've seen this often, even in commercial games (especially with font
textures), and it's actually normal behaviour, but can be prevented by
properly formatting your artwork.

The texture is being filtered by OpenGL, which is creating some extra
pixels (you'll notice it appears anti-aliased along hard edges) these
pixels are wrapping around to the opposite edges. The only way to
really "fix" this in code is to turn off the filtering - which can be
done with declares - but textures will look _really_ pixelated.

The best thing to do is to take this into account when creating
textures, and leave a few pixels from each edge either a solid colour
or totally transparent. If you reduce the green rectangle to 4, 4, 11,
11, you'll see it looks correct - 1 pixel makes a huge difference.

Frank.

- - -
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: extra pixels around edges of objects
Date: 25.01.04 21:48 (Sun, 25 Jan 2004 15:48:49 -0500)
From: Jeremy Smoler
On Jan 25, 2004, at 9:00 AM, REALbasic Games wrote:

> The best thing to do is to take this into account when creating
> textures, and leave a few pixels from each edge either a solid colour
> or totally transparent. If you reduce the green rectangle to 4, 4, 11,
> 11, you'll see it looks correct - 1 pixel makes a huge difference.

I had tried that fix before, but I guess I hadn't gone far enough --
once I get up to a 50 pixel margin, the extra pixels seem to disappear
from my game. Thanks. Seems a bit much, though, adding 100 pixels in
each dimension to images that are often shorter than 20 pixels.

One interesting thing is that in my game, I'm not actually seeing
wraparound: the extra pixels often don't correspond to any color in the
sprite texture (although they do seem to match colors in the texture
images of OTHER sprites).

- - -
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: extra pixels around edges of objects
Date: 25.01.04 22:34 (Sun, 25 Jan 2004 15:34:28 -0600)
From: Joseph J. Strout
At 3:48 PM -0500 1/25/04, Jeremy Smoler wrote:

>>11, you'll see it looks correct - 1 pixel makes a huge difference.
>
>I had tried that fix before, but I guess I hadn't gone far enough --
>once I get up to a 50 pixel margin, the extra pixels seem to
>disappear from my game. Thanks. Seems a bit much, though, adding 100
>pixels in each dimension to images that are often shorter than 20
>pixels.

I agree. Can you make a simple example where adding more than a
pixel or two is required?

>One interesting thing is that in my game, I'm not actually seeing
>wraparound: the extra pixels often don't correspond to any color in
>the sprite texture (although they do seem to match colors in the
>texture images of OTHER sprites).

It does sound like something funny is going on there, possibly
different from the effect Frank described (and which your first
example demonstrated).

Best,
- Joe

Re: extra pixels around edges of objects
Date: 25.01.04 23:51 (Sun, 25 Jan 2004 14:51:02 -0800)
From: Jeff Quan
> Subject: extra pixels around edges of objects
> From: "Jeremy Smoler" <<email address removed>>
> Date: Sat, 24 Jan 2004 21:45:45 -0500
>
> Then I run the project. I see a green square on a black background, as
> expected. I also see thin green lines above and to the left of the
> square, and a faint green dot near the square's upper-left corner.
> These last I do not expect to see. Any ideas where they are coming
> from?

To add one more suggestion to Frank's, try using a larger texture size.
This way Quesa/OpenGL has less to filter as it scales your picture.
I've found that the lowest I can get away with before I see too many
artifacts is at the 32x32 texture size.

=Jeff Quan
<email address removed>

- - -
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>