- pass the shade through the 2D drawer, so that palette emulation can still use it.

This commit is contained in:
Christoph Oelckers 2020-06-07 14:50:12 +02:00
parent b6d204a88b
commit 4c6abe1bb9
7 changed files with 32 additions and 18 deletions

View file

@ -3075,8 +3075,19 @@ void twod_rotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t pic
auto ptr = &twod->mVertices[dg.mVertIndex]; auto ptr = &twod->mVertices[dg.mVertIndex];
float drawpoly_alpha = daalpha * (1.0f / 255.0f); float drawpoly_alpha = daalpha * (1.0f / 255.0f);
float alpha = GetAlphaFromBlend(method, dablend) * (1.f - drawpoly_alpha); // Hmmm... float alpha = GetAlphaFromBlend(method, dablend) * (1.f - drawpoly_alpha); // Hmmm...
PalEntry p;
if (!hw_useindexedcolortextures)
{
int light = clamp(scale((numshades - dashade), 255, numshades), 0, 255); int light = clamp(scale((numshades - dashade), 255, numshades), 0, 255);
auto p = PalEntry((uint8_t)(alpha * 255), light, light, light); p = PalEntry((uint8_t)(alpha * 255), light, light, light);
}
else
{
p = PalEntry((uint8_t)(alpha * 255), 255, 255, 255);
dg.mLightLevel = clamp(dashade, 0, numshades);
}
vec2_t const siz = { (int)dg.mTexture->GetDisplayWidth(), (int)dg.mTexture->GetDisplayHeight() }; vec2_t const siz = { (int)dg.mTexture->GetDisplayWidth(), (int)dg.mTexture->GetDisplayHeight() };
vec2_16_t ofs = { 0, 0 }; vec2_16_t ofs = { 0, 0 };

View file

@ -408,7 +408,7 @@ void F2DDrawer::AddTexture(FGameTexture* img, DrawParms& parms)
double u1, v1, u2, v2; double u1, v1, u2, v2;
PalEntry vertexcolor; PalEntry vertexcolor;
RenderCommand dg; RenderCommand dg = {};
dg.mType = DrawTypeTriangles; dg.mType = DrawTypeTriangles;
dg.mVertCount = 4; dg.mVertCount = 4;
@ -487,7 +487,7 @@ void F2DDrawer::AddShape(FGameTexture* img, DShape2D* shape, DrawParms& parms)
PalEntry vertexcolor; PalEntry vertexcolor;
RenderCommand dg; RenderCommand dg = {};
dg.mType = DrawTypeTriangles; dg.mType = DrawTypeTriangles;
dg.mVertCount = shape->mVertices.Size(); dg.mVertCount = shape->mVertices.Size();
@ -560,7 +560,7 @@ void F2DDrawer::AddPoly(FGameTexture *texture, FVector2 *points, int npoints,
DAngle rotation, const FColormap &colormap, PalEntry flatcolor, double fadelevel, DAngle rotation, const FColormap &colormap, PalEntry flatcolor, double fadelevel,
uint32_t *indices, size_t indexcount) uint32_t *indices, size_t indexcount)
{ {
RenderCommand poly; RenderCommand poly = {};
poly.mType = DrawTypeTriangles; poly.mType = DrawTypeTriangles;
poly.mTexture = texture; poly.mTexture = texture;
@ -698,7 +698,7 @@ void F2DDrawer::AddFlatFill(int left, int top, int right, int bottom, FGameTextu
{ {
float fU1, fU2, fV1, fV2; float fU1, fU2, fV1, fV2;
RenderCommand dg; RenderCommand dg = {};
dg.mType = DrawTypeTriangles; dg.mType = DrawTypeTriangles;
dg.mRenderStyle = DefaultRenderStyle(); dg.mRenderStyle = DefaultRenderStyle();
@ -817,7 +817,7 @@ void F2DDrawer::AddFlatFill(int left, int top, int right, int bottom, FGameTextu
void F2DDrawer::AddColorOnlyQuad(int x1, int y1, int w, int h, PalEntry color, FRenderStyle *style, bool prepend) void F2DDrawer::AddColorOnlyQuad(int x1, int y1, int w, int h, PalEntry color, FRenderStyle *style, bool prepend)
{ {
RenderCommand dg; RenderCommand dg = {};
dg.mType = DrawTypeTriangles; dg.mType = DrawTypeTriangles;
dg.mVertCount = 4; dg.mVertCount = 4;
@ -856,7 +856,7 @@ void F2DDrawer::AddLine(double x1, double y1, double x2, double y2, int clipx1,
PalEntry p = (PalEntry)color; PalEntry p = (PalEntry)color;
p.a = alpha; p.a = alpha;
RenderCommand dg; RenderCommand dg = {};
if (clipx1 > 0 || clipy1 > 0 || clipx2 < GetWidth()- 1 || clipy2 < GetHeight() - 1) if (clipx1 > 0 || clipy1 > 0 || clipx2 < GetWidth()- 1 || clipy2 < GetHeight() - 1)
{ {
@ -900,7 +900,7 @@ void F2DDrawer::AddThickLine(int x1, int y1, int x2, int y2, double thickness, u
DVector2 corner2 = point1 + perp; DVector2 corner2 = point1 + perp;
DVector2 corner3 = point1 - perp; DVector2 corner3 = point1 - perp;
RenderCommand dg; RenderCommand dg = {};
dg.mType = DrawTypeTriangles; dg.mType = DrawTypeTriangles;
dg.mVertCount = 4; dg.mVertCount = 4;
@ -928,7 +928,7 @@ void F2DDrawer::AddPixel(int x1, int y1, uint32_t color)
PalEntry p = (PalEntry)color; PalEntry p = (PalEntry)color;
p.a = 255; p.a = 255;
RenderCommand dg; RenderCommand dg = {};
dg.mType = DrawTypePoints; dg.mType = DrawTypePoints;
dg.mRenderStyle = LegacyRenderStyles[STYLE_Translucent]; dg.mRenderStyle = LegacyRenderStyles[STYLE_Translucent];

View file

@ -132,6 +132,7 @@ public:
FRenderStyle mRenderStyle; FRenderStyle mRenderStyle;
PalEntry mColor1; // Overlay color PalEntry mColor1; // Overlay color
ETexMode mDrawMode; ETexMode mDrawMode;
uint8_t mLightLevel;
uint8_t mFlags; uint8_t mFlags;
RenderCommand() RenderCommand()
@ -152,6 +153,7 @@ public:
mRenderStyle == other.mRenderStyle && mRenderStyle == other.mRenderStyle &&
mDrawMode == other.mDrawMode && mDrawMode == other.mDrawMode &&
mFlags == other.mFlags && mFlags == other.mFlags &&
mLightLevel == other.mLightLevel &&
mColor1.d == other.mColor1.d; mColor1.d == other.mColor1.d;
} }

View file

@ -73,7 +73,7 @@ int HWViewpointBuffer::Bind(FRenderState &di, unsigned int index)
return index; return index;
} }
void HWViewpointBuffer::Set2D(FRenderState &di, int width, int height) void HWViewpointBuffer::Set2D(FRenderState &di, int width, int height, int pll)
{ {
if (width != m2DWidth || height != m2DHeight) if (width != m2DWidth || height != m2DHeight)
{ {
@ -83,7 +83,7 @@ void HWViewpointBuffer::Set2D(FRenderState &di, int width, int height)
matrices.mNormalViewMatrix.loadIdentity(); matrices.mNormalViewMatrix.loadIdentity();
matrices.mViewHeight = 0; matrices.mViewHeight = 0;
matrices.mGlobVis = 1.f; matrices.mGlobVis = 1.f;
matrices.mPalLightLevels = 0; matrices.mPalLightLevels = pll;
matrices.mClipLine.X = -10000000.0f; matrices.mClipLine.X = -10000000.0f;
matrices.mShadowmapFilter = gl_shadowmap_filter; matrices.mShadowmapFilter = gl_shadowmap_filter;

View file

@ -28,7 +28,7 @@ public:
~HWViewpointBuffer(); ~HWViewpointBuffer();
void Clear(); void Clear();
int Bind(FRenderState &di, unsigned int index); int Bind(FRenderState &di, unsigned int index);
void Set2D(FRenderState &di, int width, int height); void Set2D(FRenderState &di, int width, int height, int pll = 0);
int SetViewpoint(FRenderState &di, HWViewpointUniforms *vp); int SetViewpoint(FRenderState &di, HWViewpointUniforms *vp);
unsigned int GetBlockSize() const { return mBlockSize; } unsigned int GetBlockSize() const { return mBlockSize; }
}; };

View file

@ -105,7 +105,7 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
void GLInstance::Draw2D(F2DDrawer *drawer) void GLInstance::Draw2D(F2DDrawer *drawer)
{ {
VSMatrix mat(0); VSMatrix mat(0);
screen->mViewpoints->Set2D(OpenGLRenderer::gl_RenderState, xdim, ydim); screen->mViewpoints->Set2D(OpenGLRenderer::gl_RenderState, xdim, ydim, numshades);
SetViewport(0, 0, xdim, ydim); SetViewport(0, 0, xdim, ydim);
EnableDepthTest(false); EnableDepthTest(false);
EnableMultisampling(false); EnableMultisampling(false);
@ -167,8 +167,8 @@ void GLInstance::Draw2D(F2DDrawer *drawer)
{ {
auto tex = cmd.mTexture; auto tex = cmd.mTexture;
SetFadeDisable(true); SetFadeDisable(cmd.mLightLevel == 0);
SetShade(0, numshades); SetShade(cmd.mLightLevel, numshades);
SetTexture(TileFiles.GetTileIndex(tex), tex, cmd.mTranslationId, cmd.mFlags & F2DDrawer::DTF_Wrap ? CLAMP_NONE : CLAMP_XY); SetTexture(TileFiles.GetTileIndex(tex), tex, cmd.mTranslationId, cmd.mFlags & F2DDrawer::DTF_Wrap ? CLAMP_NONE : CLAMP_XY);
EnableBlend(!(cmd.mRenderStyle.Flags & STYLEF_Alpha1)); EnableBlend(!(cmd.mRenderStyle.Flags & STYLEF_Alpha1));

View file

@ -197,7 +197,8 @@ void main()
} }
palettedColor.a = color.r == 0.0? 0.0 : 1.0;// 1.0-floor(color.r); palettedColor.a = color.r == 0.0? 0.0 : 1.0;// 1.0-floor(color.r);
color = palettedColor; color.rgb = palettedColor.rgb * v_color.rgb;
color.a = palettedColor.a;
} }
else else
{ {