#83170 - Zed0 - Sat May 13, 2006 5:32 pm
Hi there,
I'm fairly new here (well I've been lurking a while, but only just got the equipment for homebrew) so I was wondering if you would mind helping me out.
Basically I am looking to make textures with transparency (Alpha or palette is good). So far the only way I have found that works is in the demo that came with devkitPro called "Paletted_Cube" which uses two bin files (.tex and .pal converted I think) but I have no idea how to:
A: get texture that gives a .tex and .pal file
B: convert them to .bin (all the converters I've seen transform from .bmp, .jpg, .png etc).
Having had a search around I found the below post here and was wondering if anyone oculd enlighten me as to the "4 lines of code" or point me in the direction of a more efficient way of making transparent textures.
Any help is appreciated
Zed0
dovoto wrote: |
Peyj wrote: |
I'd like to know how to create a binary file of an image.
I see in the ndsLib example that they load a binary image with his palette. How can we creat such file ?
thanks
|
I just exported it to raw from jasc and made my own 4 lines of code converter for tha demo. I recomend you grab gfx2gba from www.gbadev.org tools.
Or libnds has functions for directly loading an 8 bit pcx file. You can use this to load in graphics but i dont remember if i stuck in code to put the graphics into tile form as i was mainly using it for textures at the time.
|
#83241 - Sausage Boy - Sun May 14, 2006 11:33 am
I'm currently writing an exporter for The Gimp which is supposed to have support for all the documented DS textures. You either wait for that (or some other tool) or write your own, information on the texture formats can be found at http://dualis.1emulation.com/dsti.html#lcdioteximgparam
I'd also assume that the person who wrote paletted cube has some sort of converter as well, WinterMute might be able to help you with this.
_________________
"no offense, but this is the gayest game ever"
#85095 - lazmike - Sat May 27, 2006 12:50 am
As far as I know, the only way to achieve a transparent texture is to change the polyfmt for the polys that have that texture. only polys with a different poly alpha ID will blend together, either on or off. Someone please correct me if there is a way for variable polygon alpha.
_________________
-laZmike-
http://lazmike.nintendev.com
#85184 - Sausage Boy - Sat May 27, 2006 6:19 pm
The DS has 7 texture modes. mode 1-4 and 6 are paletted, 5 is compressed and not documented yet, 7 is direct color.
In all the paletted mode, color 0 can be used for transparency if you pass the correct option in your program.
Mode 1 and 6 can be semi transparent, mode 1 has 32 colors and 8 alpha values, mode 6 has 8 colors and 32 alpha values.
You can choose which mode you want to use seperately on all the textures you use.
_________________
"no offense, but this is the gayest game ever"
#85193 - Valmond - Sat May 27, 2006 8:05 pm
Don't know if this is what you are looking for, but I just
change the .bmp (or whatever I want to load) to .bin
This is handled by the makefile in some examples coming
with devkitPro so afterwards you just "include" the file in
the program :
test.bmp -> renamed to test.bin
then :
#include "test_bin.h"
and access the data with this var :
test_bin
HTH
/Valmond
#85206 - tepples - Sat May 27, 2006 9:03 pm
Sausage Boy wrote: |
The DS has 7 texture modes. mode 1-4 and 6 are paletted, 5 is compressed and not documented yet |
I seem to remember that the DS uses something like S3 texture compression, which in turn is based on RPZA video compression. Each 4x4 block of pixels has a 16-bit low color, a 16-bit high color, and then 2 bits per pixel where one value is fully low, one is high, and the others are either intermediate values or one intermediate and one transparent.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#85215 - Sausage Boy - Sat May 27, 2006 9:55 pm
Would you mind coding a compressor? ;)
_________________
"no offense, but this is the gayest game ever"
#85269 - loading - Sun May 28, 2006 10:39 am
well i can do decoding (without alpha but that should not be hard to add)
basicly there are 3 files one contayning palette one containing tileid->pal information and on containing the actual compressed data. It is like yes i's similar to s3tc:
this is from my software decoder probably not perfect but working
Code: |
u32 Derive4x4(u32 c0, u32 c1, int a0, int a1)
{
u8 d1 = (a0*(c0&0xff) + a1*(c1&0xff))/6;
u8 d2 = (a0*((c0>>8)&0xff) + a1*((c1>>8)&0xff))/6;
u8 d3 = (a0*((c0>>16)&0xff) + a1*((c1>>16)&0xff))/6;
return (d3<<16)|(d2<<8)|(d1);
}
void CreateNTF4x4(u8 data[], u16 pal[], u16 cdata[],int cols, int rows)
{
ResetImage(cols*8, rows*8,TYPERGBA);
u32 *dat = (u32*) data;
u32 c[4];
u16 tileid;
for(int m=0; m<rows*2; m++)
for(int p=0; p<cols*2; p++)
{
// colorcode start
tileid=((*cdata++)&0x3FF)*2;
c[0]=(((pal[tileid] >> 10) & 0x1f) <<19) | (((pal[tileid] >> 5) & 0x1F) <<11) | ((pal[tileid] & 0x1F) <<3);
c[1]=(((pal[tileid+1] >> 10) & 0x1f) <<19) | (((pal[tileid+1] >> 5) & 0x1F) <<11) | ((pal[tileid+1] & 0x1F) <<3);
c[2]=Derive4x4(c[0], c[1], 4, 2);
c[3]=Derive4x4(c[0], c[1], 2, 4);
c[0]|=0xff000000;
c[1]|=0xff000000;
c[2]|=0xff000000;
c[3]|=0xff000000;
u32 Pixels= *(dat++);
for(int j=0; j<16; j++)
SetPixelA(p*4-(j%4)+3,3-(j>>2)+m*4,c[(Pixels>>(30-(j*2)))&0x3]);
}
}
|
compressing will be quite complicated if you want good results
#87243 - Sausage Boy - Mon Jun 12, 2006 8:34 pm
Ok, if I understand correctly, the palette consists of pairs of colors, with a maximum palette size of 1024 color pairs. Every square selects one pair. Is this correct?
So far so good, but I wonder where all this data is supposed to be copied on the ds? Isn't there only locations for texture data and palette? Perhaps the data and cdata is loaded from the same place?
I would be very thankful if you could clear things up for me. Aside from the separation of compressed data and color data, and the palettedness, this format seems very similar to s3tc dxt1, perhaps one could modify the output of such a converter to get one for the DS? I'll look into that.
_________________
"no offense, but this is the gayest game ever"
#87258 - loading - Mon Jun 12, 2006 10:31 pm
yes modding s3tc textures -> ds compressed will be more simple than writing an own encoder. all you'd need to do is separate the color and the block data. and so it seems to me at least the nds format does not care if the higher color value or the lower one is first (which is different according to the s3tc spec)
i don't know how to actually use compressed textures on ds tho :(
#87371 - parrot_ - Tue Jun 13, 2006 4:52 pm
Valmond wrote: |
Don't know if this is what you are looking for, but I just
change the .bmp (or whatever I want to load) to .bin
This is handled by the makefile in some examples coming
with devkitPro so afterwards you just "include" the file in
the program :
test.bmp -> renamed to test.bin
then :
#include "test_bin.h"
and access the data with this var :
test_bin
HTH
/Valmond |
That only works with BMPs because the DS (AFAIK) supports BMP formatted images. Any other format shouldn't work.
_________________
Squak! etc.
My Blog
#87415 - LiraNuna - Tue Jun 13, 2006 9:00 pm
parrot_ wrote: |
That only works with BMPs because the DS (AFAIK) supports BMP formatted images. Any other format shouldn't work. |
No it's not...
Quote: |
but I just
change the .bmp (or whatever I want to load) to .bin |
Dude, Are you sure you are coding for the DS?!
use gfx2gba...
#87426 - sajiimori - Tue Jun 13, 2006 9:45 pm
The confusion seems to be about the difference between the general concept of a bit-mapped image (sometimes called a "bitmap" for short) and the BMP file format designed by Microsoft.
#87548 - Valmond - Wed Jun 14, 2006 1:00 pm
To LiraLuna:
Yes I do, and thats the way the examples you get
with devkitPro Include the data (whatever data
you got) into the project.
And I still think that thats the right answer for the question B...
You didn't read it huh ;-)
/Valmond
ps. there are (obviusly) better ways to include resources, but thats not the question.
#87582 - silent_code - Wed Jun 14, 2006 5:49 pm
you include .bmp files as .bin and load it with your own loader code, don't you? i'm confused...
#87586 - Dark Knight ez - Wed Jun 14, 2006 5:55 pm
Maybe PCX2Tex will help? It will take a 256 colours PCX file and convert it to a bin file (having looked through its code) with the alpha bit on.
See the tools section of Ethos' site.
http://ethos.oddigytitanium.com/
edit:
Unlike the "just renamed" explenation given by Valmon below,
the conversion to .bin I suggested here should give you a .bin file
with contents already appropriate for the DS such as in the examples.
Last edited by Dark Knight ez on Thu Jun 15, 2006 4:07 pm; edited 1 time in total
#87749 - Valmond - Thu Jun 15, 2006 2:51 pm
Just to clarify (I'll try anyway), the .bin used in
the examples from devKitPro are just renamed files.
Just an extension rename.
This makes the makefile include them into the project.
(if they are in the data directory)
Now, you surely don't want to include windows bitmap files
as there are headers and they don't have the data stored
in a nice DS/GBA like manner, but you can if you want.
This is one way that gets you'r files on the DS:(If you use the makefile from the examples)
1) Convert the data (gfx2gba, PCX2Tex, wavConvert, etc. or convert on the DS or write you'r own tools)
2) Change the extention .ext (or whatever .xxx) to .bin
3) put the file in the 'data' directory
the makefile will at next compile make a foobar.h file that contains a pointer to the data.
I know, you all know this already, it wast just to clarify :p
/Valmond
[edit to not bump] Yes :p [/edit]
Last edited by Valmond on Tue Jun 27, 2006 4:20 pm; edited 1 time in total
#87787 - silent_code - Thu Jun 15, 2006 6:13 pm
sure we know ;)
the tool i use (usenti - sweet piece of software!) exports to .bin. that is, it writes raw binary data. the header file generated by the makefile will contain everything (e.g. size of the file) to work with it.
raw binary data rulez ;)
thanks for trying to clarify it, anyway! though i don't get your posts saying:
"Now, you surely don't want to include windows bitmap files
as there are headers and they don't have the data stored
in a nice DS/GBA like manner, but you can if you want. "
after you said:
"Don't know if this is what you are looking for, but I just
change the .bmp (or whatever I want to load) to .bin "
? i think you mean that in a more open, general sense - like "how to include files in your rom".
:) never mind! :)