Archived

This topic is now archived and is closed to further replies.

Transparency in VGA

This topic is 6606 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

To do full fledged alpha blending in 8-bit color you'd essentially need a 256x256 CLUT
for each transparency level (I.e. a table that for each possible source and destination pair hold the new pixel color for each possible alpha value). This amounts to 256x256x256 = 16MB of CLUT. If you're looking to do a 50/50 blend, a single 256x256 clut is sufficient.

Obviously tradeoffs can be made. For example, ordering your palette so that colors that "nearly match" are close to each other, you can treat them as identical when blending, reducing each CLUT to e.g. 64x64 entries (Entry 0 covers colors 0,1,2 and 3, Entry 1 covers 4,5,6 and 7). Limiting the amount of alpha levels also help. 16 levels or less is enough for some applications. I.e. 64x64x16=64K of CLUT.

Finally, may I suggest that true color IS the only way to get the really "crisp" look.

/Niels

Share this post


Link to post
Share on other sites
I am creating a VGA game in DJGGP and are wondering how I could efficiently do transparency. I don't really know how to make the palette to do this. This is the code I have written.

#include
#include
#include
#include
#include

typedef unsigned char byte;
byte *vram;
int i;

void SetGraphMode();
void DisplayVram();
void spalette(int colour,int red,int green,int blue);

void SetGraphMode(){
__dpmi_regs regs;
regs.x.ax = 0x13;
__dpmi_int(0x10,®s);
};

void DisplayVram(){
dosmemput(vram,64000,0xa0000);
}

void main(){
SetGraphMode();
vram = (byte*)malloc(64000);
memset(vram,0,64000);
for(i=0;i<10;i++){
spalette(i,int(6.1*i),0,0);
}
for(i=0;i<10;i++){
spalette(i+10,0,int(6.1*i),0);
}
for(i=0;i<10;i++){
spalette(i+20,0,0,int(6.1*i));
}
for(i=0;i<10;i++){
spalette(i+30,int(6.1*i),int(6.1*i),0);
}
for(i=0;i<10;i++){
spalette(i+40,int(6.1*i),0,int(6.1*i));
}
for(i=0;i<10;i++){
spalette(i+50,0,int(6.1*i),int(6.1*i));
}
for(i=0;i<60;i++){
spalette(i+60,int(6.1*i),int(6.1*i),int(6.1*i));
}
for(i = 0;i<80;i++){
vram[i]=i;
}
DisplayVram();
bioskey(0);
}

void spalette(int colour,int red,int green,int blue){
__dpmi_regs regs;
regs.x.ax=0x1010;
regs.x.bx=colour;
regs.h.dh=red;
regs.h.ch=green;
regs.h.cl=blue;
__dpmi_int(0x10,®s);
}

If ne1 could suggest a good way plz reply

Share this post


Link to post
Share on other sites