From d5026558668de14b4f58fa798132e00b0d4c4bce Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 22 Sep 2009 04:21:27 +0000 Subject: [PATCH] - For hardware 2D, apply fixed colormaps when copying to video memory instead of doing it directly during the rendering, in order to improve visual fidelity for colormaps that aren't grayscale. SVN r1866 (trunk) --- docs/rh-log.txt | 3 +++ src/r_main.cpp | 15 ++++++++++++++- src/r_main.h | 1 + src/r_things.cpp | 4 ++-- src/win32/fb_d3d9.cpp | 20 ++++++++++++++++---- src/win32/win32iface.h | 2 +- 6 files changed, 37 insertions(+), 8 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 4b809f315..d53617049 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,7 @@ September 21, 2009 +- For hardware 2D, apply fixed colormaps when copying to video memory instead + of doing it directly during the rendering, in order to improve visual + fidelity for colormaps that aren't grayscale. - Added support for defining the full color range of a special colormap. - Moved the code for specialcolormap and colormapstyle in D3DFB::SetStyle() at the end of the normally-colored block so that they get all the proper diff --git a/src/r_main.cpp b/src/r_main.cpp index ea3936768..e5caada3d 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -140,6 +140,7 @@ int validcount = 1; // increment every time a check is made FDynamicColormap*basecolormap; // [RH] colormap currently drawing with int fixedlightlev; lighttable_t *fixedcolormap; +FSpecialColormap *realfixedcolormap; float WallTMapScale; float WallTMapScale2; @@ -1158,6 +1159,7 @@ void R_SetupFrame (AActor *actor) } } + realfixedcolormap = NULL; fixedcolormap = NULL; fixedlightlev = -1; @@ -1165,7 +1167,18 @@ void R_SetupFrame (AActor *actor) { if (player->fixedcolormap >= 0 && player->fixedcolormap < (int)SpecialColormaps.Size()) { - fixedcolormap = SpecialColormaps[player->fixedcolormap].Colormap; + realfixedcolormap = &SpecialColormaps[player->fixedcolormap]; + if (RenderTarget == screen && (DFrameBuffer *)screen->Accel2D) + { + // Render everything fullbright. The copy to video memory will + // apply the special colormap, so it won't be restricted to the + // palette. + fixedcolormap = realcolormaps; + } + else + { + fixedcolormap = SpecialColormaps[player->fixedcolormap].Colormap; + } } else if (player->fixedlightlevel >= 0 && player->fixedlightlevel < NUMCOLORMAPS) { diff --git a/src/r_main.h b/src/r_main.h index f6948a545..e633404e1 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -121,6 +121,7 @@ extern int extralight, r_actualextralight; extern bool foggy; extern int fixedlightlev; extern lighttable_t* fixedcolormap; +extern FSpecialColormap*realfixedcolormap; // diff --git a/src/r_things.cpp b/src/r_things.cpp index 8a938ef9b..3e9b8b0b3 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1648,9 +1648,9 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, fixed_t sx, fixed_ } } - if (fixedcolormap != NULL) + if (realfixedcolormap != NULL) { // fixed color - vis->colormap = fixedcolormap; + vis->colormap = realfixedcolormap->Colormap; } else { diff --git a/src/win32/fb_d3d9.cpp b/src/win32/fb_d3d9.cpp index 82fc19f45..0cf47e9a6 100644 --- a/src/win32/fb_d3d9.cpp +++ b/src/win32/fb_d3d9.cpp @@ -61,7 +61,7 @@ #include "v_pfx.h" #include "stats.h" #include "doomerrors.h" -#include "r_draw.h" +#include "r_main.h" #include "r_translate.h" #include "f_wipe.h" #include "st_stuff.h" @@ -1074,19 +1074,30 @@ void D3DFB::Draw3DPart(bool copy3d) SetTexture (0, FBTexture); SetPaletteTexture(PaletteTexture, 256, BorderColor); - SetPixelShader(Shaders[SHADER_NormalColorPal]); D3DDevice->SetFVF (D3DFVF_FBVERTEX); memset(Constant, 0, sizeof(Constant)); SetAlphaBlend(D3DBLENDOP(0)); EnableAlphaTest(FALSE); + SetPixelShader(Shaders[SHADER_NormalColorPal]); if (copy3d) { FBVERTEX verts[4]; D3DCOLOR color0, color1; if (Accel2D) { - color0 = 0; - color1 = 0xFFFFFFF; + if (realfixedcolormap == NULL) + { + color0 = 0; + color1 = 0xFFFFFFF; + } + else + { + color0 = D3DCOLOR_COLORVALUE(realfixedcolormap->ColorizeStart[0]/2, + realfixedcolormap->ColorizeStart[1]/2, realfixedcolormap->ColorizeStart[2]/2, 0); + color1 = D3DCOLOR_COLORVALUE(realfixedcolormap->ColorizeEnd[0]/2, + realfixedcolormap->ColorizeEnd[1]/2, realfixedcolormap->ColorizeEnd[2]/2, 1); + SetPixelShader(Shaders[SHADER_SpecialColormapPal]); + } } else { @@ -1096,6 +1107,7 @@ void D3DFB::Draw3DPart(bool copy3d) CalcFullscreenCoords(verts, Accel2D, false, color0, color1); D3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, verts, sizeof(FBVERTEX)); } + SetPixelShader(Shaders[SHADER_NormalColorPal]); } //========================================================================== diff --git a/src/win32/win32iface.h b/src/win32/win32iface.h index 26d8bf91d..785664abd 100644 --- a/src/win32/win32iface.h +++ b/src/win32/win32iface.h @@ -310,7 +310,7 @@ private: SHADER_VertexColor, SHADER_SpecialColormap, - SHADER_SpecialColorMapPal, + SHADER_SpecialColormapPal, SHADER_InGameColormap, SHADER_InGameColormapDesat,