mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 06:53:58 +00:00
Merge branch 'master' of https://github.com/coelckers/gzdoom
This commit is contained in:
commit
c4c2b440fc
14 changed files with 217 additions and 238 deletions
|
@ -140,3 +140,62 @@ void PolyDrawArgs::DrawArray(const TriVertex *vertices, int vcount, PolyDrawMode
|
|||
mDrawMode = mode;
|
||||
PolyRenderer::Instance()->DrawQueue->Push<DrawPolyTrianglesCommand>(*this, PolyTriangleDrawer::is_mirror());
|
||||
}
|
||||
|
||||
void PolyDrawArgs::SetStyle(const FRenderStyle &renderstyle, double alpha, uint32_t fillcolor, uint32_t translationID, FTexture *tex, bool fullbright)
|
||||
{
|
||||
bool forcePal = (renderstyle == LegacyRenderStyles[STYLE_Shaded] || renderstyle == LegacyRenderStyles[STYLE_AddShaded]);
|
||||
SetTexture(tex, translationID, forcePal);
|
||||
|
||||
if (renderstyle == LegacyRenderStyles[STYLE_Normal] || (r_drawfuzz == 0 && renderstyle == LegacyRenderStyles[STYLE_OptFuzzy]))
|
||||
{
|
||||
SetStyle(Translation() ? TriBlendMode::TranslatedAdd : TriBlendMode::TextureAdd, 1.0, 0.0);
|
||||
}
|
||||
else if (renderstyle == LegacyRenderStyles[STYLE_Add] && fullbright && alpha == 1.0 && !Translation())
|
||||
{
|
||||
SetStyle(TriBlendMode::TextureAddSrcColor, 1.0, 1.0);
|
||||
}
|
||||
else if (renderstyle == LegacyRenderStyles[STYLE_Add])
|
||||
{
|
||||
SetStyle(Translation() ? TriBlendMode::TranslatedAdd : TriBlendMode::TextureAdd, alpha, 1.0);
|
||||
}
|
||||
else if (renderstyle == LegacyRenderStyles[STYLE_Subtract])
|
||||
{
|
||||
SetStyle(Translation() ? TriBlendMode::TranslatedRevSub : TriBlendMode::TextureRevSub, alpha, 1.0);
|
||||
}
|
||||
else if (renderstyle == LegacyRenderStyles[STYLE_SoulTrans])
|
||||
{
|
||||
SetStyle(Translation() ? TriBlendMode::TranslatedAdd : TriBlendMode::TextureAdd, transsouls, 1.0 - transsouls);
|
||||
}
|
||||
else if (renderstyle == LegacyRenderStyles[STYLE_Fuzzy] || (r_drawfuzz == 2 && renderstyle == LegacyRenderStyles[STYLE_OptFuzzy]))
|
||||
{ // NYI - Fuzzy - for now, just a copy of "Shadow"
|
||||
SetStyle(Translation() ? TriBlendMode::TranslatedAdd : TriBlendMode::TextureAdd, 0.0, 160 / 255.0);
|
||||
}
|
||||
else if (renderstyle == LegacyRenderStyles[STYLE_Shadow] || (r_drawfuzz == 1 && renderstyle == LegacyRenderStyles[STYLE_OptFuzzy]))
|
||||
{
|
||||
SetStyle(Translation() ? TriBlendMode::TranslatedAdd : TriBlendMode::TextureAdd, 0.0, 160 / 255.0);
|
||||
}
|
||||
else if (renderstyle == LegacyRenderStyles[STYLE_TranslucentStencil])
|
||||
{
|
||||
SetColor(0xff000000 | fillcolor, fillcolor >> 24);
|
||||
SetStyle(TriBlendMode::Stencil, alpha, 1.0 - alpha);
|
||||
}
|
||||
else if (renderstyle == LegacyRenderStyles[STYLE_AddStencil])
|
||||
{
|
||||
SetColor(0xff000000 | fillcolor, fillcolor >> 24);
|
||||
SetStyle(TriBlendMode::AddStencil, alpha, 1.0);
|
||||
}
|
||||
else if (renderstyle == LegacyRenderStyles[STYLE_Shaded])
|
||||
{
|
||||
SetColor(0xff000000 | fillcolor, fillcolor >> 24);
|
||||
SetStyle(TriBlendMode::Shaded, alpha, 1.0 - alpha);
|
||||
}
|
||||
else if (renderstyle == LegacyRenderStyles[STYLE_AddShaded])
|
||||
{
|
||||
SetColor(0xff000000 | fillcolor, fillcolor >> 24);
|
||||
SetStyle(TriBlendMode::AddShaded, alpha, 1.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetStyle(Translation() ? TriBlendMode::TranslatedAdd : TriBlendMode::TextureAdd, alpha, 1.0 - alpha);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ public:
|
|||
void SetWriteSubsectorDepth(bool enable) { mWriteSubsector = enable; }
|
||||
void SetFaceCullCCW(bool counterclockwise) { mFaceCullCCW = counterclockwise; }
|
||||
void SetStyle(TriBlendMode blendmode, double srcalpha = 1.0, double destalpha = 1.0) { mBlendMode = blendmode; mSrcAlpha = (uint32_t)(srcalpha * 256.0 + 0.5); mDestAlpha = (uint32_t)(destalpha * 256.0 + 0.5); }
|
||||
void SetStyle(const FRenderStyle &renderstyle, double alpha, uint32_t fillcolor, uint32_t translationID, FTexture *texture, bool fullbright);
|
||||
void SetTransform(const TriMatrix *objectToClip) { mObjectToClip = objectToClip; }
|
||||
void SetColor(uint32_t bgra, uint8_t palindex);
|
||||
void DrawArray(const TriVertex *vertices, int vcount, PolyDrawMode mode = PolyDrawMode::Triangles);
|
||||
|
|
|
@ -92,13 +92,13 @@ public:
|
|||
ScreenTriangleStepVariables start;
|
||||
gradientX.W = FindGradientX(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w);
|
||||
gradientY.W = FindGradientY(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w);
|
||||
gradientX.U = FindGradientX(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.u * v1.w, v2.u * v2.w, v3.u * v3.w);
|
||||
gradientY.U = FindGradientY(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.u * v1.w, v2.u * v2.w, v3.u * v3.w);
|
||||
gradientX.V = FindGradientX(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.v * v1.w, v2.v * v2.w, v3.v * v3.w);
|
||||
gradientY.V = FindGradientY(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.v * v1.w, v2.v * v2.w, v3.v * v3.w);
|
||||
start.W = v1.w + gradientX.W * (startX - v1.x) + gradientY.W * (startY - v1.y);
|
||||
for (int i = 0; i < TriVertex::NumVarying; i++)
|
||||
{
|
||||
gradientX.Varying[i] = FindGradientX(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w);
|
||||
gradientY.Varying[i] = FindGradientY(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w);
|
||||
start.Varying[i] = v1.varying[i] * v1.w + gradientX.Varying[i] * (startX - v1.x) + gradientY.Varying[i] * (startY - v1.y);
|
||||
}
|
||||
start.U = v1.u * v1.w + gradientX.U * (startX - v1.x) + gradientY.U * (startY - v1.y);
|
||||
start.V = v1.v * v1.w + gradientX.V * (startX - v1.x) + gradientY.V * (startY - v1.y);
|
||||
|
||||
// Output
|
||||
uint32_t * RESTRICT destOrg = (uint32_t*)args->dest;
|
||||
|
@ -157,17 +157,16 @@ public:
|
|||
|
||||
ScreenTriangleStepVariables blockPosY;
|
||||
blockPosY.W = start.W + gradientX.W * (span.X - startX) + gradientY.W * (span.Y - startY);
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
blockPosY.Varying[j] = start.Varying[j] + gradientX.Varying[j] * (span.X - startX) + gradientY.Varying[j] * (span.Y - startY);
|
||||
blockPosY.U = start.U + gradientX.U * (span.X - startX) + gradientY.U * (span.Y - startY);
|
||||
blockPosY.V = start.V + gradientX.V * (span.X - startX) + gradientY.V * (span.Y - startY);
|
||||
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
ScreenTriangleStepVariables blockPosX = blockPosY;
|
||||
|
||||
float rcpW = 0x01000000 / blockPosX.W;
|
||||
int32_t varyingPos[TriVertex::NumVarying];
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
varyingPos[j] = (int32_t)(blockPosX.Varying[j] * rcpW);
|
||||
int32_t posU = (int32_t)(blockPosX.U * rcpW);
|
||||
int32_t posV = (int32_t)(blockPosX.V * rcpW);
|
||||
|
||||
fixed_t lightpos = FRACUNIT - (int)(clamp(shade - MIN(24.0f / 32.0f, globVis * blockPosY.W), 0.0f, 31.0f / 32.0f) * (float)FRACUNIT);
|
||||
lightpos = (lightpos & lightmask) | ((light << 8) & ~lightmask);
|
||||
|
@ -175,16 +174,14 @@ public:
|
|||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
blockPosX.W += gradientX.W * 8;
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
blockPosX.Varying[j] += gradientX.Varying[j] * 8;
|
||||
blockPosX.U += gradientX.U * 8;
|
||||
blockPosX.V += gradientX.V * 8;
|
||||
|
||||
rcpW = 0x01000000 / blockPosX.W;
|
||||
int32_t varyingStep[TriVertex::NumVarying];
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
{
|
||||
int32_t nextPos = (int32_t)(blockPosX.Varying[j] * rcpW);
|
||||
varyingStep[j] = (nextPos - varyingPos[j]) / 8;
|
||||
}
|
||||
int32_t nextU = (int32_t)(blockPosX.U * rcpW);
|
||||
int32_t nextV = (int32_t)(blockPosX.V * rcpW);
|
||||
int32_t stepU = (nextU - posU) / 8;
|
||||
int32_t stepV = (nextV - posV) / 8;
|
||||
|
||||
fixed_t lightnext = FRACUNIT - (fixed_t)(clamp(shade - MIN(24.0f / 32.0f, globVis * blockPosX.W), 0.0f, 31.0f / 32.0f) * (float)FRACUNIT);
|
||||
fixed_t lightstep = (lightnext - lightpos) / 8;
|
||||
|
@ -201,15 +198,15 @@ public:
|
|||
|
||||
// Sample fgcolor
|
||||
unsigned int ifgcolor[2], ifgshade[2];
|
||||
ifgcolor[0] = Sample<FilterModeT>(varyingPos[0], varyingPos[1], texPixels, texWidth, texHeight, oneU, oneV, color, translation);
|
||||
ifgshade[0] = SampleShade(varyingPos[0], varyingPos[1], texPixels, texWidth, texHeight);
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
varyingPos[j] += varyingStep[j];
|
||||
ifgcolor[0] = Sample<FilterModeT>(posU, posV, texPixels, texWidth, texHeight, oneU, oneV, color, translation);
|
||||
ifgshade[0] = SampleShade(posU, posV, texPixels, texWidth, texHeight);
|
||||
posU += stepU;
|
||||
posV += stepV;
|
||||
|
||||
ifgcolor[1] = Sample<FilterModeT>(varyingPos[0], varyingPos[1], texPixels, texWidth, texHeight, oneU, oneV, color, translation);
|
||||
ifgshade[1] = SampleShade(varyingPos[0], varyingPos[1], texPixels, texWidth, texHeight);
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
varyingPos[j] += varyingStep[j];
|
||||
ifgcolor[1] = Sample<FilterModeT>(posU, posV, texPixels, texWidth, texHeight, oneU, oneV, color, translation);
|
||||
ifgshade[1] = SampleShade(posU, posV, texPixels, texWidth, texHeight);
|
||||
posU += stepU;
|
||||
posV += stepV;
|
||||
|
||||
// Setup light
|
||||
int lightpos0 = lightpos >> 8;
|
||||
|
@ -240,8 +237,8 @@ public:
|
|||
}
|
||||
|
||||
blockPosY.W += gradientY.W;
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
blockPosY.Varying[j] += gradientY.Varying[j];
|
||||
blockPosY.U += gradientY.U;
|
||||
blockPosY.V += gradientY.V;
|
||||
|
||||
dest += pitch;
|
||||
}
|
||||
|
@ -253,8 +250,8 @@ public:
|
|||
|
||||
ScreenTriangleStepVariables blockPosY;
|
||||
blockPosY.W = start.W + gradientX.W * (block.X - startX) + gradientY.W * (block.Y - startY);
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
blockPosY.Varying[j] = start.Varying[j] + gradientX.Varying[j] * (block.X - startX) + gradientY.Varying[j] * (block.Y - startY);
|
||||
blockPosY.U = start.U + gradientX.U * (block.X - startX) + gradientY.U * (block.Y - startY);
|
||||
blockPosY.V = start.V + gradientX.V * (block.X - startX) + gradientY.V * (block.Y - startY);
|
||||
|
||||
uint32_t *dest = destOrg + block.X + block.Y * pitch;
|
||||
uint32_t mask0 = block.Mask0;
|
||||
|
@ -266,24 +263,21 @@ public:
|
|||
ScreenTriangleStepVariables blockPosX = blockPosY;
|
||||
|
||||
float rcpW = 0x01000000 / blockPosX.W;
|
||||
int32_t varyingPos[TriVertex::NumVarying];
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
varyingPos[j] = (int32_t)(blockPosX.Varying[j] * rcpW);
|
||||
int32_t posU = (int32_t)(blockPosX.U * rcpW);
|
||||
int32_t posV = (int32_t)(blockPosX.V * rcpW);
|
||||
|
||||
fixed_t lightpos = FRACUNIT - (fixed_t)(clamp(shade - MIN(24.0f / 32.0f, globVis * blockPosY.W), 0.0f, 31.0f / 32.0f) * (float)FRACUNIT);
|
||||
lightpos = (lightpos & lightmask) | ((light << 8) & ~lightmask);
|
||||
|
||||
blockPosX.W += gradientX.W * 8;
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
blockPosX.Varying[j] += gradientX.Varying[j] * 8;
|
||||
blockPosX.U += gradientX.U * 8;
|
||||
blockPosX.V += gradientX.V * 8;
|
||||
|
||||
rcpW = 0x01000000 / blockPosX.W;
|
||||
int32_t varyingStep[TriVertex::NumVarying];
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
{
|
||||
int32_t nextPos = (int32_t)(blockPosX.Varying[j] * rcpW);
|
||||
varyingStep[j] = (nextPos - varyingPos[j]) / 8;
|
||||
}
|
||||
int32_t nextU = (int32_t)(blockPosX.U * rcpW);
|
||||
int32_t nextV = (int32_t)(blockPosX.V * rcpW);
|
||||
int32_t stepU = (nextU - posU) / 8;
|
||||
int32_t stepV = (nextV - posV) / 8;
|
||||
|
||||
fixed_t lightnext = FRACUNIT - (fixed_t)(clamp(shade - MIN(24.0f / 32.0f, globVis * blockPosX.W), 0.0f, 31.0f / 32.0f) * (float)FRACUNIT);
|
||||
fixed_t lightstep = (lightnext - lightpos) / 8;
|
||||
|
@ -304,15 +298,15 @@ public:
|
|||
|
||||
// Sample fgcolor
|
||||
unsigned int ifgcolor[2], ifgshade[2];
|
||||
ifgcolor[0] = Sample<FilterModeT>(varyingPos[0], varyingPos[1], texPixels, texWidth, texHeight, oneU, oneV, color, translation);
|
||||
ifgshade[0] = SampleShade(varyingPos[0], varyingPos[1], texPixels, texWidth, texHeight);
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
varyingPos[j] += varyingStep[j];
|
||||
ifgcolor[0] = Sample<FilterModeT>(posU, posV, texPixels, texWidth, texHeight, oneU, oneV, color, translation);
|
||||
ifgshade[0] = SampleShade(posU, posV, texPixels, texWidth, texHeight);
|
||||
posU += stepU;
|
||||
posV += stepV;
|
||||
|
||||
ifgcolor[1] = Sample<FilterModeT>(varyingPos[0], varyingPos[1], texPixels, texWidth, texHeight, oneU, oneV, color, translation);
|
||||
ifgshade[1] = SampleShade(varyingPos[0], varyingPos[1], texPixels, texWidth, texHeight);
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
varyingPos[j] += varyingStep[j];
|
||||
ifgcolor[1] = Sample<FilterModeT>(posU, posV, texPixels, texWidth, texHeight, oneU, oneV, color, translation);
|
||||
ifgshade[1] = SampleShade(posU, posV, texPixels, texWidth, texHeight);
|
||||
posU += stepU;
|
||||
posV += stepV;
|
||||
|
||||
// Setup light
|
||||
int lightpos0 = lightpos >> 8;
|
||||
|
@ -346,8 +340,8 @@ public:
|
|||
}
|
||||
|
||||
blockPosY.W += gradientY.W;
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
blockPosY.Varying[j] += gradientY.Varying[j];
|
||||
blockPosY.U += gradientY.U;
|
||||
blockPosY.V += gradientY.V;
|
||||
|
||||
dest += pitch;
|
||||
}
|
||||
|
@ -358,24 +352,21 @@ public:
|
|||
ScreenTriangleStepVariables blockPosX = blockPosY;
|
||||
|
||||
float rcpW = 0x01000000 / blockPosX.W;
|
||||
int32_t varyingPos[TriVertex::NumVarying];
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
varyingPos[j] = (int32_t)(blockPosX.Varying[j] * rcpW);
|
||||
int32_t posU = (int32_t)(blockPosX.U * rcpW);
|
||||
int32_t posV = (int32_t)(blockPosX.V * rcpW);
|
||||
|
||||
fixed_t lightpos = FRACUNIT - (fixed_t)(clamp(shade - MIN(24.0f / 32.0f, globVis * blockPosY.W), 0.0f, 31.0f / 32.0f) * (float)FRACUNIT);
|
||||
lightpos = (lightpos & lightmask) | ((light << 8) & ~lightmask);
|
||||
|
||||
blockPosX.W += gradientX.W * 8;
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
blockPosX.Varying[j] += gradientX.Varying[j] * 8;
|
||||
blockPosX.U += gradientX.U * 8;
|
||||
blockPosX.V += gradientX.V * 8;
|
||||
|
||||
rcpW = 0x01000000 / blockPosX.W;
|
||||
int32_t varyingStep[TriVertex::NumVarying];
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
{
|
||||
int32_t nextPos = (int32_t)(blockPosX.Varying[j] * rcpW);
|
||||
varyingStep[j] = (nextPos - varyingPos[j]) / 8;
|
||||
}
|
||||
int32_t nextU = (int32_t)(blockPosX.U * rcpW);
|
||||
int32_t nextV = (int32_t)(blockPosX.V * rcpW);
|
||||
int32_t stepU = (nextU - posU) / 8;
|
||||
int32_t stepV = (nextV - posV) / 8;
|
||||
|
||||
fixed_t lightnext = FRACUNIT - (fixed_t)(clamp(shade - MIN(24.0f / 32.0f, globVis * blockPosX.W), 0.0f, 31.0f / 32.0f) * (float)FRACUNIT);
|
||||
fixed_t lightstep = (lightnext - lightpos) / 8;
|
||||
|
@ -396,15 +387,15 @@ public:
|
|||
|
||||
// Sample fgcolor
|
||||
unsigned int ifgcolor[2], ifgshade[2];
|
||||
ifgcolor[0] = Sample<FilterModeT>(varyingPos[0], varyingPos[1], texPixels, texWidth, texHeight, oneU, oneV, color, translation);
|
||||
ifgshade[0] = SampleShade(varyingPos[0], varyingPos[1], texPixels, texWidth, texHeight);
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
varyingPos[j] += varyingStep[j];
|
||||
ifgcolor[0] = Sample<FilterModeT>(posU, posV, texPixels, texWidth, texHeight, oneU, oneV, color, translation);
|
||||
ifgshade[0] = SampleShade(posU, posV, texPixels, texWidth, texHeight);
|
||||
posU += stepU;
|
||||
posV += stepV;
|
||||
|
||||
ifgcolor[1] = Sample<FilterModeT>(varyingPos[0], varyingPos[1], texPixels, texWidth, texHeight, oneU, oneV, color, translation);
|
||||
ifgshade[1] = SampleShade(varyingPos[0], varyingPos[1], texPixels, texWidth, texHeight);
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
varyingPos[j] += varyingStep[j];
|
||||
ifgcolor[1] = Sample<FilterModeT>(posU, posV, texPixels, texWidth, texHeight, oneU, oneV, color, translation);
|
||||
ifgshade[1] = SampleShade(posU, posV, texPixels, texWidth, texHeight);
|
||||
posU += stepU;
|
||||
posV += stepV;
|
||||
|
||||
// Setup light
|
||||
int lightpos0 = lightpos >> 8;
|
||||
|
@ -438,8 +429,8 @@ public:
|
|||
}
|
||||
|
||||
blockPosY.W += gradientY.W;
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
blockPosY.Varying[j] += gradientY.Varying[j];
|
||||
blockPosY.U += gradientY.U;
|
||||
blockPosY.V += gradientY.V;
|
||||
|
||||
dest += pitch;
|
||||
}
|
||||
|
|
|
@ -54,13 +54,13 @@ public:
|
|||
ScreenTriangleStepVariables start;
|
||||
gradientX.W = FindGradientX(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w);
|
||||
gradientY.W = FindGradientY(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.w, v2.w, v3.w);
|
||||
gradientX.U = FindGradientX(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.u * v1.w, v2.u * v2.w, v3.u * v3.w);
|
||||
gradientY.U = FindGradientY(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.u * v1.w, v2.u * v2.w, v3.u * v3.w);
|
||||
gradientX.V = FindGradientX(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.v * v1.w, v2.v * v2.w, v3.v * v3.w);
|
||||
gradientY.V = FindGradientY(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.v * v1.w, v2.v * v2.w, v3.v * v3.w);
|
||||
start.W = v1.w + gradientX.W * (startX - v1.x) + gradientY.W * (startY - v1.y);
|
||||
for (int i = 0; i < TriVertex::NumVarying; i++)
|
||||
{
|
||||
gradientX.Varying[i] = FindGradientX(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w);
|
||||
gradientY.Varying[i] = FindGradientY(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, v1.varying[i] * v1.w, v2.varying[i] * v2.w, v3.varying[i] * v3.w);
|
||||
start.Varying[i] = v1.varying[i] * v1.w + gradientX.Varying[i] * (startX - v1.x) + gradientY.Varying[i] * (startY - v1.y);
|
||||
}
|
||||
start.U = v1.u * v1.w + gradientX.U * (startX - v1.x) + gradientY.U * (startY - v1.y);
|
||||
start.V = v1.v * v1.w + gradientX.V * (startX - v1.x) + gradientY.V * (startY - v1.y);
|
||||
|
||||
// Output
|
||||
uint8_t * RESTRICT destOrg = args->dest;
|
||||
|
@ -89,17 +89,16 @@ public:
|
|||
|
||||
ScreenTriangleStepVariables blockPosY;
|
||||
blockPosY.W = start.W + gradientX.W * (span.X - startX) + gradientY.W * (span.Y - startY);
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
blockPosY.Varying[j] = start.Varying[j] + gradientX.Varying[j] * (span.X - startX) + gradientY.Varying[j] * (span.Y - startY);
|
||||
blockPosY.U = start.U + gradientX.U * (span.X - startX) + gradientY.U * (span.Y - startY);
|
||||
blockPosY.V = start.V + gradientX.V * (span.X - startX) + gradientY.V * (span.Y - startY);
|
||||
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
ScreenTriangleStepVariables blockPosX = blockPosY;
|
||||
|
||||
float rcpW = 0x01000000 / blockPosX.W;
|
||||
int32_t varyingPos[TriVertex::NumVarying];
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
varyingPos[j] = (int32_t)(blockPosX.Varying[j] * rcpW);
|
||||
int32_t posU = (int32_t)(blockPosX.U * rcpW);
|
||||
int32_t posV = (int32_t)(blockPosX.V * rcpW);
|
||||
|
||||
fixed_t lightpos = FRACUNIT - (int)(clamp(shade - MIN(24.0f / 32.0f, globVis * blockPosY.W), 0.0f, 31.0f / 32.0f) * (float)FRACUNIT);
|
||||
lightpos = (lightpos & lightmask) | ((light << 8) & ~lightmask);
|
||||
|
@ -107,16 +106,14 @@ public:
|
|||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
blockPosX.W += gradientX.W * 8;
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
blockPosX.Varying[j] += gradientX.Varying[j] * 8;
|
||||
blockPosX.U += gradientX.U * 8;
|
||||
blockPosX.V += gradientX.V * 8;
|
||||
|
||||
rcpW = 0x01000000 / blockPosX.W;
|
||||
int32_t varyingStep[TriVertex::NumVarying];
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
{
|
||||
int32_t nextPos = (int32_t)(blockPosX.Varying[j] * rcpW);
|
||||
varyingStep[j] = (nextPos - varyingPos[j]) / 8;
|
||||
}
|
||||
int32_t nextU = (int32_t)(blockPosX.U * rcpW);
|
||||
int32_t nextV = (int32_t)(blockPosX.V * rcpW);
|
||||
int32_t stepU = (nextU - posU) / 8;
|
||||
int32_t stepV = (nextV - posV) / 8;
|
||||
|
||||
fixed_t lightnext = FRACUNIT - (fixed_t)(clamp(shade - MIN(24.0f / 32.0f, globVis * blockPosX.W), 0.0f, 31.0f / 32.0f) * (float)FRACUNIT);
|
||||
fixed_t lightstep = (lightnext - lightpos) / 8;
|
||||
|
@ -126,18 +123,18 @@ public:
|
|||
{
|
||||
int lightshade = lightpos >> 8;
|
||||
uint8_t bgcolor = dest[x * 8 + ix];
|
||||
uint8_t fgcolor = Sample(varyingPos[0], varyingPos[1], texPixels, texWidth, texHeight, color, translation);
|
||||
uint32_t fgshade = SampleShade(varyingPos[0], varyingPos[1], texPixels, texWidth, texHeight);
|
||||
uint8_t fgcolor = Sample(posU, posV, texPixels, texWidth, texHeight, color, translation);
|
||||
uint32_t fgshade = SampleShade(posU, posV, texPixels, texWidth, texHeight);
|
||||
dest[x * 8 + ix] = ShadeAndBlend(fgcolor, bgcolor, fgshade, lightshade, colormaps, srcalpha, destalpha);
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
varyingPos[j] += varyingStep[j];
|
||||
posU += stepU;
|
||||
posV += stepV;
|
||||
lightpos += lightstep;
|
||||
}
|
||||
}
|
||||
|
||||
blockPosY.W += gradientY.W;
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
blockPosY.Varying[j] += gradientY.Varying[j];
|
||||
blockPosY.U += gradientY.U;
|
||||
blockPosY.V += gradientY.V;
|
||||
|
||||
dest += pitch;
|
||||
}
|
||||
|
@ -149,8 +146,8 @@ public:
|
|||
|
||||
ScreenTriangleStepVariables blockPosY;
|
||||
blockPosY.W = start.W + gradientX.W * (block.X - startX) + gradientY.W * (block.Y - startY);
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
blockPosY.Varying[j] = start.Varying[j] + gradientX.Varying[j] * (block.X - startX) + gradientY.Varying[j] * (block.Y - startY);
|
||||
blockPosY.U = start.U + gradientX.U * (block.X - startX) + gradientY.U * (block.Y - startY);
|
||||
blockPosY.V = start.V + gradientX.V * (block.X - startX) + gradientY.V * (block.Y - startY);
|
||||
|
||||
uint8_t *dest = destOrg + block.X + block.Y * pitch;
|
||||
uint32_t mask0 = block.Mask0;
|
||||
|
@ -162,24 +159,21 @@ public:
|
|||
ScreenTriangleStepVariables blockPosX = blockPosY;
|
||||
|
||||
float rcpW = 0x01000000 / blockPosX.W;
|
||||
int32_t varyingPos[TriVertex::NumVarying];
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
varyingPos[j] = (int32_t)(blockPosX.Varying[j] * rcpW);
|
||||
int32_t posU = (int32_t)(blockPosX.U * rcpW);
|
||||
int32_t posV = (int32_t)(blockPosX.V * rcpW);
|
||||
|
||||
fixed_t lightpos = FRACUNIT - (fixed_t)(clamp(shade - MIN(24.0f / 32.0f, globVis * blockPosY.W), 0.0f, 31.0f / 32.0f) * (float)FRACUNIT);
|
||||
lightpos = (lightpos & lightmask) | ((light << 8) & ~lightmask);
|
||||
|
||||
blockPosX.W += gradientX.W * 8;
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
blockPosX.Varying[j] += gradientX.Varying[j] * 8;
|
||||
blockPosX.U += gradientX.U * 8;
|
||||
blockPosX.V += gradientX.V * 8;
|
||||
|
||||
rcpW = 0x01000000 / blockPosX.W;
|
||||
int32_t varyingStep[TriVertex::NumVarying];
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
{
|
||||
int32_t nextPos = (int32_t)(blockPosX.Varying[j] * rcpW);
|
||||
varyingStep[j] = (nextPos - varyingPos[j]) / 8;
|
||||
}
|
||||
int32_t nextU = (int32_t)(blockPosX.U * rcpW);
|
||||
int32_t nextV = (int32_t)(blockPosX.V * rcpW);
|
||||
int32_t stepU = (nextU - posU) / 8;
|
||||
int32_t stepV = (nextV - posV) / 8;
|
||||
|
||||
fixed_t lightnext = FRACUNIT - (fixed_t)(clamp(shade - MIN(24.0f / 32.0f, globVis * blockPosX.W), 0.0f, 31.0f / 32.0f) * (float)FRACUNIT);
|
||||
fixed_t lightstep = (lightnext - lightpos) / 8;
|
||||
|
@ -191,21 +185,21 @@ public:
|
|||
{
|
||||
int lightshade = lightpos >> 8;
|
||||
uint8_t bgcolor = dest[x];
|
||||
uint8_t fgcolor = Sample(varyingPos[0], varyingPos[1], texPixels, texWidth, texHeight, color, translation);
|
||||
uint32_t fgshade = SampleShade(varyingPos[0], varyingPos[1], texPixels, texWidth, texHeight);
|
||||
uint8_t fgcolor = Sample(posU, posV, texPixels, texWidth, texHeight, color, translation);
|
||||
uint32_t fgshade = SampleShade(posU, posV, texPixels, texWidth, texHeight);
|
||||
dest[x] = ShadeAndBlend(fgcolor, bgcolor, fgshade, lightshade, colormaps, srcalpha, destalpha);
|
||||
}
|
||||
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
varyingPos[j] += varyingStep[j];
|
||||
posU += stepU;
|
||||
posV += stepV;
|
||||
lightpos += lightstep;
|
||||
|
||||
mask0 <<= 1;
|
||||
}
|
||||
|
||||
blockPosY.W += gradientY.W;
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
blockPosY.Varying[j] += gradientY.Varying[j];
|
||||
blockPosY.U += gradientY.U;
|
||||
blockPosY.V += gradientY.V;
|
||||
|
||||
dest += pitch;
|
||||
}
|
||||
|
@ -216,24 +210,21 @@ public:
|
|||
ScreenTriangleStepVariables blockPosX = blockPosY;
|
||||
|
||||
float rcpW = 0x01000000 / blockPosX.W;
|
||||
int32_t varyingPos[TriVertex::NumVarying];
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
varyingPos[j] = (int32_t)(blockPosX.Varying[j] * rcpW);
|
||||
int32_t posU = (int32_t)(blockPosX.U * rcpW);
|
||||
int32_t posV = (int32_t)(blockPosX.V * rcpW);
|
||||
|
||||
fixed_t lightpos = FRACUNIT - (fixed_t)(clamp(shade - MIN(24.0f / 32.0f, globVis * blockPosY.W), 0.0f, 31.0f / 32.0f) * (float)FRACUNIT);
|
||||
lightpos = (lightpos & lightmask) | ((light << 8) & ~lightmask);
|
||||
|
||||
blockPosX.W += gradientX.W * 8;
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
blockPosX.Varying[j] += gradientX.Varying[j] * 8;
|
||||
blockPosX.U += gradientX.U * 8;
|
||||
blockPosX.V += gradientX.V * 8;
|
||||
|
||||
rcpW = 0x01000000 / blockPosX.W;
|
||||
int32_t varyingStep[TriVertex::NumVarying];
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
{
|
||||
int32_t nextPos = (int32_t)(blockPosX.Varying[j] * rcpW);
|
||||
varyingStep[j] = (nextPos - varyingPos[j]) / 8;
|
||||
}
|
||||
int32_t nextU = (int32_t)(blockPosX.U * rcpW);
|
||||
int32_t nextV = (int32_t)(blockPosX.V * rcpW);
|
||||
int32_t stepU = (nextU - posU) / 8;
|
||||
int32_t stepV = (nextV - posV) / 8;
|
||||
|
||||
fixed_t lightnext = FRACUNIT - (fixed_t)(clamp(shade - MIN(24.0f / 32.0f, globVis * blockPosX.W), 0.0f, 31.0f / 32.0f) * (float)FRACUNIT);
|
||||
fixed_t lightstep = (lightnext - lightpos) / 8;
|
||||
|
@ -245,21 +236,21 @@ public:
|
|||
{
|
||||
int lightshade = lightpos >> 8;
|
||||
uint8_t bgcolor = dest[x];
|
||||
uint8_t fgcolor = Sample(varyingPos[0], varyingPos[1], texPixels, texWidth, texHeight, color, translation);
|
||||
uint32_t fgshade = SampleShade(varyingPos[0], varyingPos[1], texPixels, texWidth, texHeight);
|
||||
uint8_t fgcolor = Sample(posU, posV, texPixels, texWidth, texHeight, color, translation);
|
||||
uint32_t fgshade = SampleShade(posU, posV, texPixels, texWidth, texHeight);
|
||||
dest[x] = ShadeAndBlend(fgcolor, bgcolor, fgshade, lightshade, colormaps, srcalpha, destalpha);
|
||||
}
|
||||
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
varyingPos[j] += varyingStep[j];
|
||||
posU += stepU;
|
||||
posV += stepV;
|
||||
lightpos += lightstep;
|
||||
|
||||
mask1 <<= 1;
|
||||
}
|
||||
|
||||
blockPosY.W += gradientY.W;
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
blockPosY.Varying[j] += gradientY.Varying[j];
|
||||
blockPosY.U += gradientY.U;
|
||||
blockPosY.V += gradientY.V;
|
||||
|
||||
dest += pitch;
|
||||
}
|
||||
|
|
|
@ -232,13 +232,12 @@ void PolyTriangleDrawer::draw_shaded_triangle(const ShadedTriVertex *vert, bool
|
|||
// Keep varyings in -128 to 128 range if possible
|
||||
if (numclipvert > 0)
|
||||
{
|
||||
for (int j = 0; j < TriVertex::NumVarying; j++)
|
||||
float newOriginU = floorf(clippedvert[0].u * 0.1f) * 10.0f;
|
||||
float newOriginV = floorf(clippedvert[0].v * 0.1f) * 10.0f;
|
||||
for (int i = 0; i < numclipvert; i++)
|
||||
{
|
||||
float newOrigin = floorf(clippedvert[0].varying[j] * 0.1f) * 10.0f;
|
||||
for (int i = 0; i < numclipvert; i++)
|
||||
{
|
||||
clippedvert[i].varying[j] -= newOrigin;
|
||||
}
|
||||
clippedvert[i].u -= newOriginU;
|
||||
clippedvert[i].v -= newOriginV;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -424,8 +423,8 @@ int PolyTriangleDrawer::clipedge(const ShadedTriVertex *verts, TriVertex *clippe
|
|||
v.y += verts[w].y * weight;
|
||||
v.z += verts[w].z * weight;
|
||||
v.w += verts[w].w * weight;
|
||||
for (int iv = 0; iv < TriVertex::NumVarying; iv++)
|
||||
v.varying[iv] += verts[w].varying[iv] * weight;
|
||||
v.u += verts[w].u * weight;
|
||||
v.v += verts[w].v * weight;
|
||||
}
|
||||
}
|
||||
return inputverts;
|
||||
|
|
|
@ -61,11 +61,10 @@ struct WorkerThreadData
|
|||
struct TriVertex
|
||||
{
|
||||
TriVertex() { }
|
||||
TriVertex(float x, float y, float z, float w, float u, float v) : x(x), y(y), z(z), w(w) { varying[0] = u; varying[1] = v; }
|
||||
TriVertex(float x, float y, float z, float w, float u, float v) : x(x), y(y), z(z), w(w), u(u), v(v) { }
|
||||
|
||||
enum { NumVarying = 2 };
|
||||
float x, y, z, w;
|
||||
float varying[NumVarying];
|
||||
float u, v;
|
||||
};
|
||||
|
||||
struct TriDrawTriangleArgs
|
||||
|
@ -126,8 +125,7 @@ public:
|
|||
|
||||
struct ScreenTriangleStepVariables
|
||||
{
|
||||
float W;
|
||||
float Varying[TriVertex::NumVarying];
|
||||
float W, U, V;
|
||||
};
|
||||
|
||||
namespace TriScreenDrawerModes
|
||||
|
|
|
@ -199,7 +199,7 @@ ShadedTriVertex TriMatrix::operator*(TriVertex v) const
|
|||
ShadedTriVertex sv;
|
||||
_mm_storeu_ps(&sv.x, mv);
|
||||
#endif
|
||||
for (int i = 0; i < TriVertex::NumVarying; i++)
|
||||
sv.varying[i] = v.varying[i];
|
||||
sv.u = v.u;
|
||||
sv.v = v.v;
|
||||
return sv;
|
||||
}
|
||||
|
|
|
@ -123,10 +123,10 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, const PolyClipPlane &
|
|||
vertices[i].y = (float)p.Y;
|
||||
vertices[i].z = (float)(zpos + spriteHeight * offsets[i].second - spriteHeight * 0.5);
|
||||
vertices[i].w = 1.0f;
|
||||
vertices[i].varying[0] = (float)(offsets[i].first * tex->Scale.X);
|
||||
vertices[i].varying[1] = (float)((1.0f - offsets[i].second) * tex->Scale.Y);
|
||||
vertices[i].u = (float)(offsets[i].first * tex->Scale.X);
|
||||
vertices[i].v = (float)((1.0f - offsets[i].second) * tex->Scale.Y);
|
||||
if (flipTextureX)
|
||||
vertices[i].varying[0] = 1.0f - vertices[i].varying[0];
|
||||
vertices[i].u = 1.0f - vertices[i].u;
|
||||
}
|
||||
|
||||
bool fullbrightSprite = (decal->RenderFlags & RF_FULLBRIGHT) == RF_FULLBRIGHT;
|
||||
|
@ -134,10 +134,9 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, const PolyClipPlane &
|
|||
|
||||
PolyDrawArgs args;
|
||||
args.SetLight(GetColorTable(front->Colormap), lightlevel, PolyRenderer::Instance()->Light.WallGlobVis(foggy), fullbrightSprite);
|
||||
args.SetTexture(tex, decal->Translation, true);
|
||||
args.SetSubsectorDepth(subsectorDepth);
|
||||
args.SetColor(0xff000000 | decal->AlphaColor, decal->AlphaColor >> 24);
|
||||
args.SetStyle(TriBlendMode::Shaded, decal->Alpha, 1.0 - decal->Alpha); // R_SetPatchStyle (decal->RenderStyle, (float)decal->Alpha, decal->Translation, decal->AlphaColor);
|
||||
args.SetStyle(decal->RenderStyle, decal->Alpha, decal->AlphaColor, decal->Translation, tex, false);
|
||||
args.SetTransform(&worldToClip);
|
||||
args.SetFaceCullCCW(true);
|
||||
args.SetStencilTestValue(stencilValue);
|
||||
|
|
|
@ -66,8 +66,8 @@ void RenderPolyParticle::Render(const TriMatrix &worldToClip, const PolyClipPlan
|
|||
vertices[i].y = (float)p.Y;
|
||||
vertices[i].z = (float)(zpos + psize * (2.0 * offsets[i].second - 1.0));
|
||||
vertices[i].w = 1.0f;
|
||||
vertices[i].varying[0] = (float)(offsets[i].first);
|
||||
vertices[i].varying[1] = (float)(1.0f - offsets[i].second);
|
||||
vertices[i].u = (float)(offsets[i].first);
|
||||
vertices[i].v = (float)(1.0f - offsets[i].second);
|
||||
}
|
||||
|
||||
bool fullbrightSprite = particle->bright != 0;
|
||||
|
|
|
@ -410,8 +410,8 @@ TriVertex RenderPolyPlane::PlaneVertex(vertex_t *v1, double height, const UVTran
|
|||
v.y = (float)v1->fPos().Y;
|
||||
v.z = (float)height;
|
||||
v.w = 1.0f;
|
||||
v.varying[0] = transform.GetU(v.x, v.y);
|
||||
v.varying[1] = transform.GetV(v.x, v.y);
|
||||
v.u = transform.GetU(v.x, v.y);
|
||||
v.v = transform.GetV(v.x, v.y);
|
||||
return v;
|
||||
}
|
||||
|
||||
|
|
|
@ -139,8 +139,8 @@ TriVertex PolySkyDome::SetVertexXYZ(float xx, float yy, float zz, float uu, floa
|
|||
v.y = zz;
|
||||
v.z = yy;
|
||||
v.w = 1.0f;
|
||||
v.varying[0] = uu;
|
||||
v.varying[1] = vv;
|
||||
v.u = uu;
|
||||
v.v = vv;
|
||||
return v;
|
||||
}
|
||||
|
||||
|
|
|
@ -128,10 +128,10 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const PolyClipPlane
|
|||
vertices[i].y = (float)p.Y;
|
||||
vertices[i].z = (float)(pos.Z + spriteHeight * offsets[i].second);
|
||||
vertices[i].w = 1.0f;
|
||||
vertices[i].varying[0] = (float)(offsets[i].first * tex->Scale.X);
|
||||
vertices[i].varying[1] = (float)((1.0f - offsets[i].second) * tex->Scale.Y);
|
||||
vertices[i].u = (float)(offsets[i].first * tex->Scale.X);
|
||||
vertices[i].v = (float)((1.0f - offsets[i].second) * tex->Scale.Y);
|
||||
if (flipTextureX)
|
||||
vertices[i].varying[0] = 1.0f - vertices[i].varying[0];
|
||||
vertices[i].u = 1.0f - vertices[i].u;
|
||||
}
|
||||
|
||||
bool fullbrightSprite = ((thing->renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT));
|
||||
|
@ -144,67 +144,8 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const PolyClipPlane
|
|||
args.SetFaceCullCCW(true);
|
||||
args.SetStencilTestValue(stencilValue);
|
||||
args.SetWriteStencil(true, stencilValue);
|
||||
args.SetTexture(tex, thing->Translation);
|
||||
args.SetClipPlane(clipPlane);
|
||||
|
||||
if (thing->RenderStyle == LegacyRenderStyles[STYLE_Normal] ||
|
||||
(r_drawfuzz == 0 && thing->RenderStyle == LegacyRenderStyles[STYLE_OptFuzzy]))
|
||||
{
|
||||
args.SetStyle(args.Translation() ? TriBlendMode::TranslatedAdd : TriBlendMode::TextureAdd, 1.0, 0.0);
|
||||
}
|
||||
else if (thing->RenderStyle == LegacyRenderStyles[STYLE_Add] && fullbrightSprite && thing->Alpha == 1.0 && !args.Translation())
|
||||
{
|
||||
args.SetStyle(TriBlendMode::TextureAddSrcColor, 1.0, 1.0);
|
||||
}
|
||||
else if (thing->RenderStyle == LegacyRenderStyles[STYLE_Add])
|
||||
{
|
||||
args.SetStyle(args.Translation() ? TriBlendMode::TranslatedAdd : TriBlendMode::TextureAdd, thing->Alpha, 1.0);
|
||||
}
|
||||
else if (thing->RenderStyle == LegacyRenderStyles[STYLE_Subtract])
|
||||
{
|
||||
args.SetStyle(args.Translation() ? TriBlendMode::TranslatedRevSub : TriBlendMode::TextureRevSub, thing->Alpha, 1.0);
|
||||
}
|
||||
else if (thing->RenderStyle == LegacyRenderStyles[STYLE_SoulTrans])
|
||||
{
|
||||
args.SetStyle(args.Translation() ? TriBlendMode::TranslatedAdd : TriBlendMode::TextureAdd, transsouls, 1.0 - transsouls);
|
||||
}
|
||||
else if (thing->RenderStyle == LegacyRenderStyles[STYLE_Fuzzy] ||
|
||||
(r_drawfuzz == 2 && thing->RenderStyle == LegacyRenderStyles[STYLE_OptFuzzy]))
|
||||
{ // NYI - Fuzzy - for now, just a copy of "Shadow"
|
||||
args.SetStyle(args.Translation() ? TriBlendMode::TranslatedAdd : TriBlendMode::TextureAdd, 0.0, 160 / 255.0);
|
||||
}
|
||||
else if (thing->RenderStyle == LegacyRenderStyles[STYLE_Shadow] ||
|
||||
(r_drawfuzz == 1 && thing->RenderStyle == LegacyRenderStyles[STYLE_OptFuzzy]))
|
||||
{
|
||||
args.SetStyle(args.Translation() ? TriBlendMode::TranslatedAdd : TriBlendMode::TextureAdd, 0.0, 160 / 255.0);
|
||||
}
|
||||
else if (thing->RenderStyle == LegacyRenderStyles[STYLE_TranslucentStencil])
|
||||
{
|
||||
args.SetColor(0xff000000 | thing->fillcolor, thing->fillcolor >> 24);
|
||||
args.SetStyle(TriBlendMode::Stencil, thing->Alpha, 1.0 - thing->Alpha);
|
||||
}
|
||||
else if (thing->RenderStyle == LegacyRenderStyles[STYLE_AddStencil])
|
||||
{
|
||||
args.SetColor(0xff000000 | thing->fillcolor, thing->fillcolor >> 24);
|
||||
args.SetStyle(TriBlendMode::AddStencil, thing->Alpha, 1.0);
|
||||
}
|
||||
else if (thing->RenderStyle == LegacyRenderStyles[STYLE_Shaded])
|
||||
{
|
||||
args.SetColor(0xff000000 | thing->fillcolor, thing->fillcolor >> 24);
|
||||
args.SetStyle(TriBlendMode::Shaded, thing->Alpha, 1.0 - thing->Alpha);
|
||||
args.SetTexture(tex, thing->Translation, true);
|
||||
}
|
||||
else if (thing->RenderStyle == LegacyRenderStyles[STYLE_AddShaded])
|
||||
{
|
||||
args.SetColor(0xff000000 | thing->fillcolor, thing->fillcolor >> 24);
|
||||
args.SetStyle(TriBlendMode::AddShaded, thing->Alpha, 1.0);
|
||||
args.SetTexture(tex, thing->Translation, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
args.SetStyle(args.Translation() ? TriBlendMode::TranslatedAdd : TriBlendMode::TextureAdd, thing->Alpha, 1.0 - thing->Alpha);
|
||||
}
|
||||
|
||||
args.SetStyle(thing->RenderStyle, thing->Alpha, thing->fillcolor, thing->Translation, tex, fullbrightSprite);
|
||||
args.SetSubsectorDepthTest(true);
|
||||
args.SetWriteSubsectorDepth(false);
|
||||
args.SetWriteStencil(false);
|
||||
|
|
|
@ -230,14 +230,14 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip, const PolyClipPlane &c
|
|||
if (tex)
|
||||
{
|
||||
PolyWallTextureCoords texcoords(tex, LineSeg, Line, Side, Texpart, TopZ, BottomZ, UnpeggedCeil);
|
||||
vertices[0].varying[0] = (float)texcoords.u1;
|
||||
vertices[0].varying[1] = (float)texcoords.v1;
|
||||
vertices[1].varying[0] = (float)texcoords.u2;
|
||||
vertices[1].varying[1] = (float)texcoords.v1;
|
||||
vertices[2].varying[0] = (float)texcoords.u2;
|
||||
vertices[2].varying[1] = (float)texcoords.v2;
|
||||
vertices[3].varying[0] = (float)texcoords.u1;
|
||||
vertices[3].varying[1] = (float)texcoords.v2;
|
||||
vertices[0].u = (float)texcoords.u1;
|
||||
vertices[0].v = (float)texcoords.v1;
|
||||
vertices[1].u = (float)texcoords.u2;
|
||||
vertices[1].v = (float)texcoords.v1;
|
||||
vertices[2].u = (float)texcoords.u2;
|
||||
vertices[2].v = (float)texcoords.v2;
|
||||
vertices[3].u = (float)texcoords.u1;
|
||||
vertices[3].v = (float)texcoords.v2;
|
||||
}
|
||||
|
||||
// Masked walls clamp to the 0-1 range (no texture repeat)
|
||||
|
@ -294,8 +294,8 @@ void RenderPolyWall::ClampHeight(TriVertex &v1, TriVertex &v2)
|
|||
{
|
||||
float top = v1.z;
|
||||
float bottom = v2.z;
|
||||
float texv1 = v1.varying[1];
|
||||
float texv2 = v2.varying[1];
|
||||
float texv1 = v1.v;
|
||||
float texv2 = v2.v;
|
||||
float delta = (texv2 - texv1);
|
||||
|
||||
float t1 = texv1 < 0.0f ? -texv1 / delta : 0.0f;
|
||||
|
@ -304,10 +304,10 @@ void RenderPolyWall::ClampHeight(TriVertex &v1, TriVertex &v2)
|
|||
float inv_t2 = 1.0f - t2;
|
||||
|
||||
v1.z = top * inv_t1 + bottom * t1;
|
||||
v1.varying[1] = texv1 * inv_t1 + texv2 * t1;
|
||||
v1.v = texv1 * inv_t1 + texv2 * t1;
|
||||
|
||||
v2.z = top * inv_t2 + bottom * t2;
|
||||
v2.varying[1] = texv1 * inv_t2 + texv2 * t2;
|
||||
v2.v = texv1 * inv_t2 + texv2 * t2;
|
||||
}
|
||||
|
||||
FTexture *RenderPolyWall::GetTexture()
|
||||
|
|
|
@ -90,10 +90,10 @@ void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, const PolyClipPl
|
|||
vertices[i].y = (float)p.Y;
|
||||
vertices[i].z = (float)(pos.Z + spriteHeight * offsets[i].second);
|
||||
vertices[i].w = 1.0f;
|
||||
vertices[i].varying[0] = (float)(offsets[i].first * tex->Scale.X);
|
||||
vertices[i].varying[1] = (float)((1.0f - offsets[i].second) * tex->Scale.Y);
|
||||
vertices[i].u = (float)(offsets[i].first * tex->Scale.X);
|
||||
vertices[i].v = (float)((1.0f - offsets[i].second) * tex->Scale.Y);
|
||||
if (flipTextureX)
|
||||
vertices[i].varying[0] = 1.0f - vertices[i].varying[0];
|
||||
vertices[i].u = 1.0f - vertices[i].u;
|
||||
}
|
||||
|
||||
bool fullbrightSprite = ((thing->renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT));
|
||||
|
|
Loading…
Reference in a new issue