gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Help! Transparent Sprites

#132073 - yellowstar - Sat Jun 23, 2007 3:05 am

I have two questions:

1.

I need some help with sprites.

I am trying to use transparent sprites.(sprites that have some pixels
transparent.)

But, it(the NDS) will only display non-transparent sprites.(my sprites)

In other words,
It(the NDS) will only display sprites(my sprites) with white behind it.(the sprite)

It looks the same on an emulator.

Messing with the palette didn't do anything.

It dosen't matter if the converted image(bmp/png) had an alpha channel
or not.

I am using gbAmp to convert the image, in paletted tile mode.

I used gfx2gba to convert the palette.

2.

What option do I use with gfx2gba to output tiles?(for sprites.)

#132076 - mml - Sat Jun 23, 2007 3:47 am

a) on sprites and most of your backgrounds, palette index 0 is your transparency, so transparent parts of your sprite graphic should be using palette index 0. (it doesn't matter what colour is actually stored in the palette at this position.)

b) on the bottom-most background (don't remember offhand if this is bg3 or bg0, the internets will know), palette index 0 is the backdrop colour.

c) transparent pixels in sprites and the other backgrounds will show the nearest (in terms of rendering order) opaque pixel below them, or fall back to the backdrop colour if there aren't any.

#132137 - yellowstar - Sat Jun 23, 2007 8:39 pm

I found the index of the sprite's background color palette index.

I can change the background color of the sprite,
but when I try to set the color to transparent,
it dosen't do anything.

In other words,
the sprite still isn't transparent,.

I used to have the backgrounds in 16 bit mode,
but I switched them to 8 bit mode.
But now when I try to draw anything to the main bg,
it won't draw anything, it just displays stuff on the bottom part of
the screen.
(It displays stuff on the bottom part of the top screen.)

I am not using 16 bit writes, I am using 8 bit writes.

I am drawing to the backgrounds in a for loop.

#132142 - tepples - Sat Jun 23, 2007 9:22 pm

yellowstar wrote:
I am not using 16 bit writes, I am using 8 bit writes.

If you are writing to palette memory, VRAM, or OAM, you must use 16-bit or 32-bit writes, or the byte will be replicated into the low and high order bytes of a 16-bit unit.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#132154 - yellowstar - Sat Jun 23, 2007 10:37 pm

For the 8 bit writes,
I meant only Backgrounds.

For the palette, I am using normal 16 bit writes.

#132158 - tepples - Sat Jun 23, 2007 11:01 pm

Backgrounds are in VRAM. I stated 2 posts ago that VRAM does not like 8-bit writes.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#132212 - yellowstar - Sun Jun 24, 2007 6:21 pm

I got the background color for the main screen
to display correctly.

But it still won't display the sprite the way I want it to.

#132556 - yellowstar - Wed Jun 27, 2007 8:10 pm

Thanks, It works now!

I finally figured out that you
meant that the hardware doesn't
render pixels, on sprites which has
palette index 0!

For setting the pixels that were supposed to be
transparent in code,
I was manually setting it with code after it loaded
the image.
But for some reason,
it would not get rid of all the white pixels
which were supposed to be transparent.

I gave up on that method,
and wrote a PC program that
would convert the white pixels
that are supposed to be transparent,
to palette index 0, so they would be transparent.

That worked!!!