Bug fix in invulnerability in Doom Software Render Mode and True Color SW Render in SoftPoly.

This commit is contained in:
Erick Vasquez Garcia 2021-03-21 15:27:43 -06:00 committed by Christoph Oelckers
parent 4d353318d9
commit bf3018cc84

View file

@ -538,12 +538,13 @@ static void MainFP(int x0, int x1, PolyTriangleThreadData* thread)
// frag = frag * vColor; // frag = frag * vColor;
// frag.rgb = frag.rgb + uFogColor.rgb; // frag.rgb = frag.rgb + uFogColor.rgb;
uint32_t startR = (int)((thread->mainVertexShader.Data.uObjectColor.r) * 255.0f); // [GEC] I leave the default floating values.
uint32_t startG = (int)((thread->mainVertexShader.Data.uObjectColor.g) * 255.0f); float startR = thread->mainVertexShader.Data.uObjectColor.r;
uint32_t startB = (int)((thread->mainVertexShader.Data.uObjectColor.b) * 255.0f); float startG = thread->mainVertexShader.Data.uObjectColor.g;
uint32_t rangeR = (int)((thread->mainVertexShader.Data.uAddColor.r) * 255.0f) - startR; float startB = thread->mainVertexShader.Data.uObjectColor.b;
uint32_t rangeG = (int)((thread->mainVertexShader.Data.uAddColor.g) * 255.0f) - startG; float rangeR = thread->mainVertexShader.Data.uAddColor.r - startR;
uint32_t rangeB = (int)((thread->mainVertexShader.Data.uAddColor.b) * 255.0f) - startB; float rangeG = thread->mainVertexShader.Data.uAddColor.g - startG;
float rangeB = thread->mainVertexShader.Data.uAddColor.b - startB;
for (int x = x0; x < x1; x++) for (int x = x0; x < x1; x++)
{ {
@ -555,15 +556,22 @@ static void MainFP(int x0, int x1, PolyTriangleThreadData* thread)
uint32_t gray = (r * 77 + g * 143 + b * 37) >> 8; uint32_t gray = (r * 77 + g * 143 + b * 37) >> 8;
gray += (gray >> 7); // gray*=256/255 gray += (gray >> 7); // gray*=256/255
r = (startR + ((gray * rangeR) >> 8)) << 1; // [GEC] I use the same method as in shaders using floating values.
g = (startG + ((gray * rangeG) >> 8)) << 1; // This avoids errors in the invulneravility colormap in Doom and Heretic.
b = (startB + ((gray * rangeB) >> 8)) << 1; float fgray = (float)(gray / 255.f);
float fr = (startR + (fgray * rangeR)) * 2;
float fg = (startG + (fgray * rangeG)) * 2;
float fb = (startB + (fgray * rangeB)) * 2;
r = MIN(r, (uint32_t)255); fr = clamp<float>(fr, 0.0f, 1.0f);
g = MIN(g, (uint32_t)255); fg = clamp<float>(fg, 0.0f, 1.0f);
b = MIN(b, (uint32_t)255); fb = clamp<float>(fb, 0.0f, 1.0f);
fragcolor[x] = MAKEARGB(a, r, g, b); r = (uint32_t)(fr * 255.f);
g = (uint32_t)(fg * 255.f);
b = (uint32_t)(fb * 255.f);
fragcolor[x] = MAKEARGB(a, (uint8_t)r, (uint8_t)g, (uint8_t)b);
} }
} }
else else