- Fixed sprites were not affected by dynamic lights on SoftPoly.

This commit is contained in:
Erick Vasquez Garcia 2021-02-14 18:06:05 -06:00 committed by Rachael Alexanderson
parent d23755f76b
commit 78c0ec0470
3 changed files with 49 additions and 2 deletions

View file

@ -292,6 +292,7 @@ void PolyRenderState::Apply()
constants.uAlphaThreshold = mAlphaThreshold; constants.uAlphaThreshold = mAlphaThreshold;
constants.uClipSplit = { mClipSplit[0], mClipSplit[1] }; constants.uClipSplit = { mClipSplit[0], mClipSplit[1] };
constants.uLightIndex = mLightIndex; constants.uLightIndex = mLightIndex;
constants.uDynLightColor = mStreamData.uDynLightColor; // [GEC]
mDrawCommands->PushStreamData(mStreamData, constants); mDrawCommands->PushStreamData(mStreamData, constants);
ApplyMatrices(); ApplyMatrices();

View file

@ -111,6 +111,7 @@ struct PolyPushConstants
// dynamic lights // dynamic lights
int uLightIndex; int uLightIndex;
FVector4 uDynLightColor; // [GEC]
}; };
class PolyInputAssembly class PolyInputAssembly

View file

@ -260,7 +260,23 @@ static void WriteLightArray(int y, int x0, int x1, const TriDrawTriangleArgs* ar
uint32_t b = vColorB[x]; uint32_t b = vColorB[x];
uint32_t a = vColorA[x]; uint32_t a = vColorA[x];
lightarray[x] = MAKEARGB(a, (r * l) >> 8, (g * l) >> 8, (b * l) >> 8); // [GEC] DynLightColor On Sprite
r = (r * l) >> 8;
g = (g * l) >> 8;
b = (b * l) >> 8;
if (constants->uLightIndex == -1)
{
r += (uint32_t)(constants->uDynLightColor.X * 255.0f);
g += (uint32_t)(constants->uDynLightColor.Y * 255.0f);
b += (uint32_t)(constants->uDynLightColor.Z * 255.0f);
r = MIN<uint32_t>(r, 255);
g = MIN<uint32_t>(g, 255);
b = MIN<uint32_t>(b, 255);
}
lightarray[x] = MAKEARGB(a, r, g, b);
lightpos += lightstep; lightpos += lightstep;
} }
} }
@ -275,7 +291,23 @@ static void WriteLightArray(int y, int x0, int x1, const TriDrawTriangleArgs* ar
uint32_t b = vColorB[x]; uint32_t b = vColorB[x];
uint32_t a = vColorA[x]; uint32_t a = vColorA[x];
lightarray[x] = MAKEARGB(a, (r * l) >> 8, (g * l) >> 8, (b * l) >> 8); // [GEC] DynLightColor On Sprite
r = (r * l) >> 8;
g = (g * l) >> 8;
b = (b * l) >> 8;
if (constants->uLightIndex == -1)
{
r += (uint32_t)(constants->uDynLightColor.X * 255.0f);
g += (uint32_t)(constants->uDynLightColor.Y * 255.0f);
b += (uint32_t)(constants->uDynLightColor.Z * 255.0f);
r = MIN<uint32_t>(r, 255);
g = MIN<uint32_t>(g, 255);
b = MIN<uint32_t>(b, 255);
}
lightarray[x] = MAKEARGB(a, r, g, b);
lightpos += lightstep; lightpos += lightstep;
} }
} }
@ -323,6 +355,19 @@ static void WriteLightArray(int y, int x0, int x1, const TriDrawTriangleArgs* ar
uint32_t r = thread->scanline.vColorR[x]; uint32_t r = thread->scanline.vColorR[x];
uint32_t g = thread->scanline.vColorG[x]; uint32_t g = thread->scanline.vColorG[x];
uint32_t b = thread->scanline.vColorB[x]; uint32_t b = thread->scanline.vColorB[x];
// [GEC] DynLightColor On Weapon
if (constants->uLightIndex == -1)
{
r += (uint32_t)(constants->uDynLightColor.X * 255.0f);
g += (uint32_t)(constants->uDynLightColor.Y * 255.0f);
b += (uint32_t)(constants->uDynLightColor.Z * 255.0f);
r = MIN<uint32_t>(r, 255);
g = MIN<uint32_t>(g, 255);
b = MIN<uint32_t>(b, 255);
}
lightarray[x] = MAKEARGB(a, r, g, b); lightarray[x] = MAKEARGB(a, r, g, b);
} }
} }