Color keying with PVR
-
- DCEmu Fast Newbie
- Posts: 20
- https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
- Joined: Thu Feb 03, 2005 1:59 pm
- Has thanked: 0
- Been thanked: 0
- Contact:
Color keying with PVR
Hi,
first off, I'm new on this board, and I'm also pretty new with coding on the DC (having moved in from low-level PSX coding). I hope to have a pleasant stay here
Right now I'm coding a simple "bouncing sprite" thingie with KOS. Because I couldn't get the Linux dev environment to work, I'm using some sort of integrated package using Dev-C++ that I found somewhere, it comes with KOS 1.2.0. After wading thru the absence of documentation on the PowerVR functions, I finally succeeded in displaying a background in the OP "layer" and a sprite on top of that in the TR "layer". Basically what I'm trying to do is define a specific colour in the sprite as "see-through", i.e. 100% transparent. My sprite is in PNG format, and I'm using png_to_texture() to load it. Now what would be the best way to implement this?
Thanks in advance!
first off, I'm new on this board, and I'm also pretty new with coding on the DC (having moved in from low-level PSX coding). I hope to have a pleasant stay here
Right now I'm coding a simple "bouncing sprite" thingie with KOS. Because I couldn't get the Linux dev environment to work, I'm using some sort of integrated package using Dev-C++ that I found somewhere, it comes with KOS 1.2.0. After wading thru the absence of documentation on the PowerVR functions, I finally succeeded in displaying a background in the OP "layer" and a sprite on top of that in the TR "layer". Basically what I'm trying to do is define a specific colour in the sprite as "see-through", i.e. 100% transparent. My sprite is in PNG format, and I'm using png_to_texture() to load it. Now what would be the best way to implement this?
Thanks in advance!
I am not really from outer space.
-
- DC Developer
- Posts: 9951
- Joined: Sun Dec 30, 2001 9:02 am
- Has thanked: 0
- Been thanked: 1 time
The best way is to get an image editor that can handle alpha channels, use those for transparency. Basically, you create an alpha channel where transparent pixels have an alpha value of 0 (black), and opaque pixels have an alpha value of 255 (white). You can also use intermediate values for varying levels of transparency - 128 is 50% transparent, for example.
Once you've done that, you need to render the image using the transparent display list. It should automatically have transparencies.
Once you've done that, you need to render the image using the transparent display list. It should automatically have transparencies.
-
- DCEmu Fast Newbie
- Posts: 20
- Joined: Thu Feb 03, 2005 1:59 pm
- Has thanked: 0
- Been thanked: 0
- Contact:
Well, I'm not really trying to mimic it, I'm just looking for "boolean" transparency. But I'll fiddle around with the PNG some more, I havent got it to work yet though.toastman wrote:PNGs support transparency, what you are attempting is to mimic core functionality of the file format.
I am not really from outer space.
- GyroVorbis
- Elysian Shadows Developer
- Posts: 1874
- Joined: Mon Mar 22, 2004 4:55 pm
- Location: #%^&*!!!11one Super Sonic
- Has thanked: 81 times
- Been thanked: 64 times
- Contact:
What BA suggests here is DEFINATELY the way to go.BlackAura wrote:The best way is to get an image editor that can handle alpha channels, use those for transparency. Basically, you create an alpha channel where transparent pixels have an alpha value of 0 (black), and opaque pixels have an alpha value of 255 (white). You can also use intermediate values for varying levels of transparency - 128 is 50% transparent, for example.
Once you've done that, you need to render the image using the transparent display list. It should automatically have transparencies.
-
- Damn Dirty Ape
- Posts: 5031
- Joined: Thu Nov 07, 2002 11:11 pm
- Location: Saugerties, NY
- Has thanked: 0
- Been thanked: 0
It shouldn't be that hard to do with raw pixel data if I undertand things properly. If you can steal some of the PNG code and modify it so after you load the pixel data into a buffer, you can manipulate it a bit before loading it into texture memory, you could set the alpha channel based on the R, G, and B values - if it's a given color, make that pixel transparent. Otherwise, set it to fully opaque.AntiPasta wrote:Well, I'm not really trying to mimic it, I'm just looking for "boolean" transparency. But I'll fiddle around with the PNG some more, I havent got it to work yet though.toastman wrote:PNGs support transparency, what you are attempting is to mimic core functionality of the file format.
Or, just do what BlackAura said and save yourself the trouble. I think the GIMP will do the job if you need something that's both good and free.
-
- DC Developer
- Posts: 80
- Joined: Wed Oct 17, 2001 7:44 pm
- Location: Sweden
- Has thanked: 0
- Been thanked: 1 time
1) Open the GIMP.AntiPasta wrote:OK thanks once more, I tried the GIMP but for some reason the area I want to be transparent is white instead and the rest of the picture has only the Red channel it seems... how exactly do I go about in GIMP? All I want is to set RGB(0,0,0) to 100% transparent.
2) Open your picture.
3) Right click on the picture and choose "Picture -> alpha -> add alpha channel" (if possible)
4) Right click on the picture and choose "Select -> by color"
5) left click the color you want selected
6) Right click on the picture and choose "Edit -> empty" or press CTRL+K. A black and gray chessboard pattern should appear where your selected color used to be.
7) Done
-
- DCEmu Fast Newbie
- Posts: 20
- Joined: Thu Feb 03, 2005 1:59 pm
- Has thanked: 0
- Been thanked: 0
- Contact:
Thanks, that's exactly what I needed to know
At first it still didnt work (sprite is in all red with a light blue background) but I hazarded a guess and chanced the pvr_poly_cxt_txr() argument to PVR_TXRFMT_ARGB1555 (it was RGB565) and now the background is gone - but the sprite was still displayed with messed up colours. After some more messing around I got it to work fine when using PVR_TXRFMT_ARGB4444
Is this really required btw? Is there a way to have the PNG loaded to RGB1555 instead of 4444 to keep more colourspace available to the primary colours?
At first it still didnt work (sprite is in all red with a light blue background) but I hazarded a guess and chanced the pvr_poly_cxt_txr() argument to PVR_TXRFMT_ARGB1555 (it was RGB565) and now the background is gone - but the sprite was still displayed with messed up colours. After some more messing around I got it to work fine when using PVR_TXRFMT_ARGB4444
Is this really required btw? Is there a way to have the PNG loaded to RGB1555 instead of 4444 to keep more colourspace available to the primary colours?
I am not really from outer space.