- Added new patch style "Overlay" for TEXTURES. This is the same as CopyAlpha, except it only

copies the patch's alpha channel where it has a higher alpha than what's underneath.

SVN r3638 (trunk)
This commit is contained in:
Randy Heit 2012-05-11 02:26:50 +00:00
parent b9c3f8db4f
commit 37001d3640
3 changed files with 11 additions and 1 deletions

View file

@ -206,6 +206,7 @@ static const CopyFunc copyfuncs[][9]={
COPY_FUNCS(bModulate), COPY_FUNCS(bModulate),
COPY_FUNCS(bCopyAlpha), COPY_FUNCS(bCopyAlpha),
COPY_FUNCS(bCopyNewAlpha), COPY_FUNCS(bCopyNewAlpha),
COPY_FUNCS(bOverlay),
COPY_FUNCS(bOverwrite) COPY_FUNCS(bOverwrite)
}; };
#undef COPY_FUNCS #undef COPY_FUNCS
@ -422,6 +423,7 @@ static const CopyPalettedFunc copypalettedfuncs[]=
iCopyPaletted<cBGRA, bModulate>, iCopyPaletted<cBGRA, bModulate>,
iCopyPaletted<cBGRA, bCopyAlpha>, iCopyPaletted<cBGRA, bCopyAlpha>,
iCopyPaletted<cBGRA, bCopyNewAlpha>, iCopyPaletted<cBGRA, bCopyNewAlpha>,
iCopyPaletted<cBGRA, bOverlay>,
iCopyPaletted<cBGRA, bOverwrite> iCopyPaletted<cBGRA, bOverwrite>
}; };

View file

@ -319,6 +319,7 @@ enum ECopyOp
OP_MODULATE, OP_MODULATE,
OP_COPYALPHA, OP_COPYALPHA,
OP_COPYNEWALPHA, OP_COPYNEWALPHA,
OP_OVERLAY,
OP_OVERWRITE OP_OVERWRITE
}; };
@ -359,6 +360,13 @@ struct bCopyAlpha
static __forceinline bool ProcessAlpha0() { return false; } static __forceinline bool ProcessAlpha0() { return false; }
}; };
struct bOverlay
{
static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = (s*a + d*(255-a))/255; }
static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = MAX(s,d); }
static __forceinline bool ProcessAlpha0() { return false; }
};
struct bBlend struct bBlend
{ {
static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = (d*i->invalpha + s*i->alpha) >> FRACBITS; } static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = (d*i->invalpha + s*i->alpha) >> FRACBITS; }

View file

@ -1180,7 +1180,7 @@ void FMultiPatchTexture::ParsePatch(FScanner &sc, TexPart & part, bool silent, i
} }
else if (sc.Compare("style")) else if (sc.Compare("style"))
{ {
static const char *styles[] = {"copy", "translucent", "add", "subtract", "reversesubtract", "modulate", "copyalpha", "copynewalpha", NULL }; static const char *styles[] = {"copy", "translucent", "add", "subtract", "reversesubtract", "modulate", "copyalpha", "copynewalpha", "overlay", NULL };
sc.MustGetString(); sc.MustGetString();
part.op = sc.MustMatchString(styles); part.op = sc.MustMatchString(styles);
bComplex |= (part.op != OP_COPY); bComplex |= (part.op != OP_COPY);