mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 15:22:16 +00:00
Fix blending modes
This commit is contained in:
parent
42138a6ab9
commit
204c037017
3 changed files with 18 additions and 10 deletions
|
@ -168,6 +168,7 @@ bool DrawColumnCodegen::IsPaletteInput(DrawColumnVariant variant)
|
|||
SSAVec4i DrawColumnCodegen::ProcessPixel(SSAInt sample_index, SSAVec4i bgcolor, DrawColumnVariant variant, bool isSimpleShade)
|
||||
{
|
||||
SSAInt alpha, inv_alpha;
|
||||
SSAVec4i fg;
|
||||
switch (variant)
|
||||
{
|
||||
default:
|
||||
|
@ -177,24 +178,30 @@ SSAVec4i DrawColumnCodegen::ProcessPixel(SSAInt sample_index, SSAVec4i bgcolor,
|
|||
return blend_copy(Shade(Sample(sample_index), isSimpleShade));
|
||||
case DrawColumnVariant::DrawAdd:
|
||||
case DrawColumnVariant::DrawAddClamp:
|
||||
return blend_add(Shade(Sample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha);
|
||||
fg = Shade(Sample(sample_index), isSimpleShade);
|
||||
return blend_add(fg, bgcolor, srcalpha, calc_blend_bgalpha(fg, destalpha));
|
||||
case DrawColumnVariant::DrawShaded:
|
||||
alpha = SSAInt::MAX(SSAInt::MIN(ColormapSample(sample_index), SSAInt(64)), SSAInt(0)) * 4;
|
||||
inv_alpha = 256 - alpha;
|
||||
return blend_add(color, bgcolor, alpha, inv_alpha);
|
||||
case DrawColumnVariant::DrawSubClamp:
|
||||
return blend_sub(Shade(Sample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha);
|
||||
fg = Shade(Sample(sample_index), isSimpleShade);
|
||||
return blend_sub(fg, bgcolor, srcalpha, calc_blend_bgalpha(fg, destalpha));
|
||||
case DrawColumnVariant::DrawRevSubClamp:
|
||||
return blend_revsub(Shade(Sample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha);
|
||||
fg = Shade(Sample(sample_index), isSimpleShade);
|
||||
return blend_revsub(fg, bgcolor, srcalpha, calc_blend_bgalpha(fg, destalpha));
|
||||
case DrawColumnVariant::DrawTranslated:
|
||||
return blend_copy(Shade(TranslateSample(sample_index), isSimpleShade));
|
||||
case DrawColumnVariant::DrawTlatedAdd:
|
||||
case DrawColumnVariant::DrawAddClampTranslated:
|
||||
return blend_add(Shade(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha);
|
||||
fg = Shade(TranslateSample(sample_index), isSimpleShade);
|
||||
return blend_add(fg, bgcolor, srcalpha, calc_blend_bgalpha(fg, destalpha));
|
||||
case DrawColumnVariant::DrawSubClampTranslated:
|
||||
return blend_sub(Shade(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha);
|
||||
fg = Shade(TranslateSample(sample_index), isSimpleShade);
|
||||
return blend_sub(fg, bgcolor, srcalpha, calc_blend_bgalpha(fg, destalpha));
|
||||
case DrawColumnVariant::DrawRevSubClampTranslated:
|
||||
return blend_revsub(Shade(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha);
|
||||
fg = Shade(TranslateSample(sample_index), isSimpleShade);
|
||||
return blend_revsub(fg, bgcolor, srcalpha, calc_blend_bgalpha(fg, destalpha));
|
||||
case DrawColumnVariant::Fill:
|
||||
return blend_copy(color);
|
||||
case DrawColumnVariant::FillAdd:
|
||||
|
|
|
@ -55,8 +55,9 @@ SSAVec4i DrawerCodegen::shade_pal_index_advanced(SSAInt index, SSAInt light, con
|
|||
|
||||
SSAVec4i DrawerCodegen::shade_bgra_simple(SSAVec4i color, SSAInt light)
|
||||
{
|
||||
SSAInt alpha = color[3];
|
||||
color = color * light / 256;
|
||||
return color.insert(3, 255);
|
||||
return color.insert(3, alpha);
|
||||
}
|
||||
|
||||
SSAVec4i DrawerCodegen::shade_bgra_advanced(SSAVec4i color, SSAInt light, const SSAShadeConstants &constants)
|
||||
|
|
|
@ -182,10 +182,10 @@ SSAVec4i DrawWallCodegen::Blend(SSAVec4i fg, SSAVec4i bg, DrawWallVariant varian
|
|||
return blend_alpha_blend(fg, bg);
|
||||
case DrawWallVariant::Add:
|
||||
case DrawWallVariant::AddClamp:
|
||||
return blend_add(fg, bg, srcalpha, destalpha);
|
||||
return blend_add(fg, bg, srcalpha, calc_blend_bgalpha(fg, destalpha));
|
||||
case DrawWallVariant::SubClamp:
|
||||
return blend_sub(fg, bg, srcalpha, destalpha);
|
||||
return blend_sub(fg, bg, srcalpha, calc_blend_bgalpha(fg, destalpha));
|
||||
case DrawWallVariant::RevSubClamp:
|
||||
return blend_revsub(fg, bg, srcalpha, destalpha);
|
||||
return blend_revsub(fg, bg, srcalpha, calc_blend_bgalpha(fg, destalpha));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue