mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 07:12:02 +00:00
Fix sprite light bug
This commit is contained in:
parent
10e268ebc0
commit
832790f5ba
2 changed files with 249 additions and 323 deletions
File diff suppressed because it is too large
Load diff
|
@ -119,21 +119,27 @@ namespace swrenderer
|
|||
uint32_t one = ((0x80000000 + textureheight - 1) / textureheight) * 2 + 1;
|
||||
|
||||
// Shade constants
|
||||
__m128i dynlight = _mm_cvtsi32_si128(args.DynamicLight());
|
||||
dynlight = _mm_unpacklo_epi8(dynlight, _mm_setzero_si128());
|
||||
dynlight = _mm_shuffle_epi32(dynlight, _MM_SHUFFLE(1,0,1,0));
|
||||
int light = 256 - (args.Light() >> (FRACBITS - 8));
|
||||
__m128i mlight = _mm_set_epi16(256, light, light, light, 256, light, light, light);
|
||||
__m128i inv_light = _mm_set_epi16(0, 256 - light, 256 - light, 256 - light, 0, 256 - light, 256 - light, 256 - light);
|
||||
<? if ($isSimpleShade == false)
|
||||
<? if ($isSimpleShade)
|
||||
{ ?>
|
||||
mlight = _mm_min_epi16(_mm_add_epi16(mlight, dynlight), _mm_set1_epi16(256));
|
||||
<? }
|
||||
else
|
||||
{ ?>
|
||||
__m128i inv_light = _mm_set_epi16(0, 256 - light, 256 - light, 256 - light, 0, 256 - light, 256 - light, 256 - light);
|
||||
__m128i inv_desaturate = _mm_setr_epi16(256, 256 - shade_constants.desaturate, 256 - shade_constants.desaturate, 256 - shade_constants.desaturate, 256, 256 - shade_constants.desaturate, 256 - shade_constants.desaturate, 256 - shade_constants.desaturate);
|
||||
__m128i shade_fade = _mm_set_epi16(shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue, shade_constants.fade_alpha, shade_constants.fade_red, shade_constants.fade_green, shade_constants.fade_blue);
|
||||
shade_fade = _mm_mullo_epi16(shade_fade, inv_light);
|
||||
__m128i shade_light = _mm_set_epi16(shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue, shade_constants.light_alpha, shade_constants.light_red, shade_constants.light_green, shade_constants.light_blue);
|
||||
int desaturate = shade_constants.desaturate;
|
||||
|
||||
__m128i lightcontrib = _mm_min_epi16(_mm_add_epi16(mlight, dynlight), _mm_set1_epi16(256));
|
||||
lightcontrib = _mm_sub_epi16(lightcontrib, mlight);
|
||||
<? } ?>
|
||||
|
||||
__m128i dynlight = _mm_cvtsi32_si128(args.DynamicLight());
|
||||
dynlight = _mm_unpacklo_epi8(dynlight, _mm_setzero_si128());
|
||||
dynlight = _mm_shuffle_epi32(dynlight, _MM_SHUFFLE(1,0,1,0));
|
||||
|
||||
int count = args.Count();
|
||||
int pitch = RenderViewport::Instance()->RenderTarget->GetPitch();
|
||||
|
@ -281,14 +287,11 @@ namespace swrenderer
|
|||
|
||||
if ($isSimpleShade == true)
|
||||
{ ?>
|
||||
mlight = _mm_min_epi16(_mm_add_epi16(mlight, dynlight), _mm_set1_epi16(256));
|
||||
fgcolor = _mm_srli_epi16(_mm_mullo_epi16(fgcolor, mlight), 8);
|
||||
<? }
|
||||
else
|
||||
{ ?>
|
||||
__m128i lightcontrib = _mm_min_epi16(_mm_add_epi16(mlight, dynlight), _mm_set1_epi16(256));
|
||||
lightcontrib = _mm_sub_epi16(lightcontrib, mlight);
|
||||
lightcontrib = _mm_srli_epi16(_mm_mullo_epi16(fgcolor, lightcontrib), 8);
|
||||
__m128i lit_dynlight = _mm_srli_epi16(_mm_mullo_epi16(fgcolor, lightcontrib), 8);
|
||||
|
||||
int blue0 = BPART(ifgcolor[0]);
|
||||
int green0 = GPART(ifgcolor[0]);
|
||||
|
@ -307,7 +310,7 @@ namespace swrenderer
|
|||
fgcolor = _mm_srli_epi16(_mm_add_epi16(shade_fade, fgcolor), 8);
|
||||
fgcolor = _mm_srli_epi16(_mm_mullo_epi16(fgcolor, shade_light), 8);
|
||||
|
||||
fgcolor = _mm_add_epi16(fgcolor, lightcontrib);
|
||||
fgcolor = _mm_add_epi16(fgcolor, lit_dynlight);
|
||||
fgcolor = _mm_min_epi16(fgcolor, _mm_set1_epi16(256));
|
||||
<? }
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue