Clamp vColor

This commit is contained in:
Magnus Norddahl 2019-12-08 00:41:24 +01:00
parent f365f6f433
commit cef3fd53ab

View file

@ -376,7 +376,7 @@ static void WriteVaryingColor(float pos, float step, int x0, int x1, const float
{ {
for (int x = x0; x < x1; x++) for (int x = x0; x < x1; x++)
{ {
varying[x] = (int)(pos * w[x] * 255.0f); varying[x] = clamp(static_cast<int>(pos * w[x] * 255.0f), 0, 255);
pos += step; pos += step;
} }
} }
@ -401,7 +401,7 @@ static void WriteVaryingColor(float pos, float step, int x0, int x1, const float
pos += ssecount * step; pos += ssecount * step;
for (int x = sseend; x < x1; x++) for (int x = sseend; x < x1; x++)
{ {
varying[x] = (int)(pos * w[x] * 255.0f); varying[x] = clamp(static_cast<int>(pos * w[x] * 255.0f), 0, 255);
pos += step; pos += step;
} }
} }