diff --git a/src/hardware/hw_drv.h b/src/hardware/hw_drv.h index 8cbb53de6d0303b85ea713ba8da5934fca3b40dc..c6b3ec804848dad33a5bf792cfc784c91778cf52 100644 --- a/src/hardware/hw_drv.h +++ b/src/hardware/hw_drv.h @@ -75,7 +75,7 @@ EXPORT void HWRAPI(SetShaderInfo) (hwdshaderinfo_t info, INT32 value); EXPORT void HWRAPI(LoadCustomShader) (int number, char *shader, size_t size, boolean fragment); EXPORT void HWRAPI(InitCustomShaders) (void); -EXPORT void HWRAPI(LevelSurfaceLighting) (UINT8 lightlevel, FConvertedColormap *pColormap, UINT8 opacity); +EXPORT void HWRAPI(LevelSurfaceLighting) (UINT16 lightlevel, FConvertedColormap *pColormap, UINT8 opacity); EXPORT void HWRAPI(ModelLighting) (float red, float green, float blue, float opacity); // ========================================================================== diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 7be0e0c0bc17d761e59e3e158a2b4cc337c3662f..73f188132c9b98d8d9070cf233eab3b43b0b5a41 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -167,7 +167,7 @@ typedef struct INT32 texnum; walltype_t walltype; extracolormap_t *colormap; // Doing the lighting in HWR_RenderWall now for correct fog after sorting - UINT8 lightlevel; + UINT16 lightlevel; UINT8 opacity; } wallinfo_t; @@ -200,7 +200,7 @@ typedef struct sector_t *FOFSector; planetype_t planetype; extracolormap_t *colormap; - UINT8 lightlevel; + UINT16 lightlevel; UINT8 opacity; } planeinfo_t; @@ -232,14 +232,14 @@ static FConvertedColormap ConvertColormap(extracolormap_t *colormap) return cc; } -void HWR_Lighting(UINT8 lightlevel, extracolormap_t *colormap, UINT8 opacity, hwdshader_t shader) +void HWR_Lighting(UINT16 lightlevel, extracolormap_t *colormap, UINT8 opacity, hwdshader_t shader) { FConvertedColormap cc = ConvertColormap(colormap); HWD.pfnSetShader(shader); HWD.pfnLevelSurfaceLighting(lightlevel, &cc, opacity); } -void HWR_ModelLighting(UINT8 lightlevel, extracolormap_t *colormap, UINT8 opacity) { +void HWR_ModelLighting(UINT16 lightlevel, extracolormap_t *colormap, UINT8 opacity) { FConvertedColormap cc = ConvertColormap(colormap); //crappy color mixing based on colormaps (treats both low intensity colormaps and strong white colormaps as white light) float red = cc.tint_color.s.red/255.0f; @@ -290,7 +290,7 @@ UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap) // Let's see if return surfcolor.s.alpha; } -static UINT8 HWR_CalcWallLight(FUINT lightnum, fixed_t v1x, fixed_t v1y, fixed_t v2x, fixed_t v2y) +static UINT16 HWR_CalcWallLight(FUINT lightnum, fixed_t v1x, fixed_t v1y, fixed_t v2x, fixed_t v2y) { INT16 finallight = lightnum; @@ -326,10 +326,10 @@ static UINT8 HWR_CalcWallLight(FUINT lightnum, fixed_t v1x, fixed_t v1y, fixed_t } } - return (UINT8)finallight; + return (UINT16)finallight; } -static UINT8 HWR_CalcSlopeLight(FUINT lightnum, angle_t dir, fixed_t delta) +static UINT16 HWR_CalcSlopeLight(FUINT lightnum, angle_t dir, fixed_t delta) { INT16 finallight = lightnum; @@ -370,7 +370,7 @@ static UINT8 HWR_CalcSlopeLight(FUINT lightnum, angle_t dir, fixed_t delta) } } - return (UINT8)finallight; + return (UINT16)finallight; } static void HWR_RenderSurface(const FOutVector *pOutVerts, FUINT iNumPts, hwdblendmode_t blendmode, EPolyFlags polyflags) { @@ -606,7 +606,7 @@ static void HWR_RenderPlane(const planeinfo_t *plane) // for horizontal / vertical / diagonal // note: try to get the same visual feel as the original - UINT8 newLightlevel; + UINT16 newLightlevel; #ifdef ESLOPE if (slope) @@ -797,7 +797,7 @@ static void HWR_AddWallNode(const wallinfo_t *wall); // // HWR_ProjectWall // -static void HWR_ProjectWall(FOutVector *wallVerts, UINT8 lightlevel, extracolormap_t *colormap) +static void HWR_ProjectWall(FOutVector *wallVerts, UINT16 lightlevel, extracolormap_t *colormap) { HWR_Lighting(lightlevel, colormap, 0xFF, HWD_SHADER_WALL); //opacity can be wrongly set here HWR_RenderSurface(wallVerts, 4, HWD_BLEND_MASKED, PF_Occlude); @@ -877,8 +877,8 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, INT32 solid, i; lightlist_t * list = sector->lightlist; - //UINT8 lightlevel = HWR_CalcWallLight(sector->lightlevel, v1x, v1y, v2x, v2y); - UINT8 lightlevel; + //UINT16 lightlevel = HWR_CalcWallLight(sector->lightlevel, v1x, v1y, v2x, v2y); + UINT16 lightlevel; extracolormap_t *colormap = NULL; realtop = top = wallVerts[3].y; @@ -1154,7 +1154,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom fixed_t hS, lS; #endif - UINT8 wallLightlevel; + UINT16 wallLightlevel; extracolormap_t *wallColormap; gr_sidedef = gr_curline->sidedef; @@ -3200,7 +3200,7 @@ static void HWR_AddPolyPlane(polyobj_t *polyobject, EPlaneSide pside) INT32 lightindex = R_GetPlaneLight(gr_frontsector, fixedheight, true); - UINT8 lightlevel; + UINT16 lightlevel; extracolormap_t *colormap; if(lightindex == -1) { @@ -3275,7 +3275,7 @@ static void HWR_AddPolyObjectPlanes(void) static void HWR_AddFOFPlane(size_t num, ffloor_t *rover, EPlaneSide pside, INT32 lightindex) { sector_t *FOFSector = rover->master->frontsector; - UINT8 lightlevel = *gr_frontsector->lightlist[lightindex].lightlevel; + UINT16 lightlevel = *gr_frontsector->lightlist[lightindex].lightlevel; extracolormap_t *colormap = *gr_frontsector->lightlist[lightindex].extra_colormap; levelflat_t *levelflat; @@ -4051,7 +4051,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) FSurfaceInfo Surf = {}; const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)spr->mobj->skin)->flags & SF_HIRES); extracolormap_t *colormap; - UINT8 lightlevel; + UINT16 lightlevel; UINT8 opacity; INT32 i; @@ -4483,7 +4483,7 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) { sector_t *sector = spr->mobj->subsector->sector; extracolormap_t *colormap = sector->extra_colormap; - UINT8 lightlevel = 0xFF; + UINT16 lightlevel = 0xFF; UINT8 opacity; if (!(spr->mobj->frame & FF_FULLBRIGHT)) @@ -4575,7 +4575,7 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr) { sector_t *sector = spr->mobj->subsector->sector; extracolormap_t *colormap = sector->extra_colormap; - UINT8 lightlevel = 0xFF; + UINT16 lightlevel = 0xFF; UINT8 opacity; if (sector->numlights) diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 9111565b3aa3aacef1cdc4bfeecd30e5803ff096..bcf56e0f13ae98cd01aeb8dbe16a1603f82d4a9d 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -65,8 +65,8 @@ void HWR_MakeScreenFinalTexture(void); void HWR_DrawScreenFinalTexture(int width, int height); // This stuff is put here so MD2's can use them -void HWR_Lighting(UINT8 lightlevel, extracolormap_t *colormap, UINT8 opacity, hwdshader_t shader); -void HWR_ModelLighting(UINT8 lightlevel, extracolormap_t *colormap, UINT8 opacity); +void HWR_Lighting(UINT16 lightlevel, extracolormap_t *colormap, UINT8 opacity, hwdshader_t shader); +void HWR_ModelLighting(UINT16 lightlevel, extracolormap_t *colormap, UINT8 opacity); UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap); // Let's see if this can work void HWR_ReadShaders(UINT16 wadnum, boolean PK3); diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index d1cf450a22082e372113c6c5ae826330a69eaa0e..a0ba90cbb56cd188850edb5cf517d4a718d8c2b6 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1200,7 +1200,7 @@ boolean HWR_DrawModel(gr_vissprite_t *spr) { sector_t *sector = spr->mobj->subsector->sector; extracolormap_t *colormap = NULL; - UINT8 lightlevel = 0xFF; + UINT16 lightlevel = 0xFF; UINT8 opacity; if (sector->numlights) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 4a02946010402a7dc989ede1fa977ba2048ed94b..c416c6aa6e603d0dd1e56ca11b5525c56c633e00 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1862,7 +1862,7 @@ static void Shader_SetUniforms(mapSurfaceParams_t *p) } //needs a better name too -EXPORT void HWRAPI(LevelSurfaceLighting) (UINT8 lightlevel, FConvertedColormap *pColormap, UINT8 opacity) +EXPORT void HWRAPI(LevelSurfaceLighting) (UINT16 lightlevel, FConvertedColormap *pColormap, UINT8 opacity) { mapSurfaceParams_t p = { .opacity = byte2float[opacity], @@ -1890,8 +1890,7 @@ EXPORT void HWRAPI(LevelSurfaceLighting) (UINT8 lightlevel, FConvertedColormap * average_tint.alpha = p.tint_color[3]; //TODO: implement fade_start and fade_end - float light = lightlevel; - float modlight = min(light*light/65535.0, 1.0); + float modlight = min(lightlevel*lightlevel/65535.0f, 1.0f); primary[0] = average_tint.red * modlight + p.fade_color[0]*(1.0-modlight); primary[1] = average_tint.green * modlight + p.fade_color[1]*(1.0-modlight); primary[2] = average_tint.blue * modlight + p.fade_color[2]*(1.0-modlight);