refactor postimg stuff so it can be combined with each other better

thx much indev! <3
everything now works with encore!
software now also supports screen effects in splitscreen!
This commit is contained in:
Alug 2024-10-22 01:17:57 +02:00 committed by NepDisk
parent 28eafd639e
commit fe30efacdd
11 changed files with 156 additions and 194 deletions

View file

@ -131,7 +131,6 @@ boolean devparm = false; // started game with -devparm
boolean singletics = false; // timedemo
boolean lastdraw = false;
postimg_t postimgtype[MAXSPLITSCREENPLAYERS];
INT32 postimgparam[MAXSPLITSCREENPLAYERS];
// These variables are in effect
@ -368,8 +367,7 @@ static void D_RenderLevel(void)
{
R_ApplyViewMorph(i);
if (postimgtype[i])
V_DoPostProcessor(i, postimgtype[i], postimgparam[i]);
V_DoPostProcessor(i, &players[displayplayers[i]], postimgparam[i]);
}
}

View file

@ -505,6 +505,8 @@ struct player_t
// See pflags_t, above.
pflags_t pflags;
UINT16 postimgflags;
// playing animation.
panim_t panim;

View file

@ -180,7 +180,6 @@ extern INT32 window_y;
extern boolean nodrawers;
extern boolean noblit;
extern boolean lastdraw;
extern postimg_t postimgtype[MAXSPLITSCREENPLAYERS];
extern INT32 postimgparam[MAXSPLITSCREENPLAYERS];
extern INT32 viewwindowx, viewwindowy;

View file

@ -342,14 +342,12 @@ typedef union FColorRGBA RGBA_t;
typedef enum
{
postimg_none,
postimg_water,
postimg_motion,
postimg_flip,
postimg_heat,
postimg_mirror,
postimg_mirrorflip
} postimg_t;
POSTIMG_WATER = 1, // Underwater screen effect.
POSTIMG_MOTION = 1<<1, // Unused motion blur effect.
POSTIMG_FLIP = 1<<2, // Flipcam screen effect.
POSTIMG_HEAT = 1<<3, // Heatwave screen effect.
POSTIMG_MIRROR = 1<<4, // encore screen effect.
} postimgflag_t;
typedef UINT32 lumpnum_t; // 16 : 16 unsigned long (wad num: lump num)
#define LUMPERROR UINT32_MAX

View file

@ -5663,17 +5663,6 @@ static void HWR_DrawSkyBackground(player_t *player)
{
FTransform dometransform;
const float fpov = FIXED_TO_FLOAT(cv_fov[viewssnum].value+player->fovadd);
postimg_t *type = &postimgtype[0];
SINT8 i;
for (i = r_splitscreen; i >= 0; i--)
{
if (player == &players[displayplayers[i]])
{
type = &postimgtype[i];
break;
}
}
memset(&dometransform, 0x00, sizeof(FTransform));
@ -5682,20 +5671,17 @@ static void HWR_DrawSkyBackground(player_t *player)
HWR_SetTransformAiming(&dometransform, player, false);
dometransform.angley = (float)((viewangle-ANGLE_270)>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES);
if (*type == postimg_flip)
dometransform.flip = false;
if ((player->postimgflags & POSTIMG_FLIP) && !(player->postimgflags & POSTIMG_MIRROR))
dometransform.flip = true;
else
dometransform.flip = false;
if (*type == postimg_mirror)
dometransform.mirror = false;
if ((player->postimgflags & POSTIMG_MIRROR) && !(player->postimgflags & POSTIMG_FLIP))
dometransform.mirror = true;
else
dometransform.mirror = false;
if (*type == postimg_mirrorflip)
dometransform.mirrorflip = false;
if ((player->postimgflags & POSTIMG_FLIP) && (player->postimgflags & POSTIMG_MIRROR))
dometransform.mirrorflip = true;
else
dometransform.mirrorflip = false;
dometransform.scalex = 1;
dometransform.scaley = (float)vid.width/vid.height;
@ -5941,7 +5927,6 @@ static void HWR_ClearClipper(void)
void HWR_RenderSkyboxView(player_t *player)
{
const float fpov = FIXED_TO_FLOAT(cv_fov[viewssnum].value+player->fovadd);
postimg_t *type = &postimgtype[viewssnum];
{
// do we really need to save player (is it not the same)?
@ -5982,15 +5967,17 @@ void HWR_RenderSkyboxView(player_t *player)
gl_viewludsin = FIXED_TO_FLOAT(FINECOSINE(gl_aimingangle>>ANGLETOFINESHIFT));
gl_viewludcos = FIXED_TO_FLOAT(-FINESINE(gl_aimingangle>>ANGLETOFINESHIFT));
if (*type == postimg_flip)
atransform.flip = false;
if ((player->postimgflags & POSTIMG_FLIP) && !(player->postimgflags & POSTIMG_MIRROR))
atransform.flip = true;
else
atransform.flip = false;
if (*type == postimg_mirror)
atransform.mirror = false;
if ((player->postimgflags & POSTIMG_MIRROR) && !(player->postimgflags & POSTIMG_FLIP))
atransform.mirror = true;
else
atransform.mirror = false;
atransform.mirrorflip = false;
if ((player->postimgflags & POSTIMG_FLIP) && (player->postimgflags & POSTIMG_MIRROR))
atransform.mirrorflip = true;
atransform.x = gl_viewx; // FIXED_TO_FLOAT(viewx)
atransform.y = gl_viewy; // FIXED_TO_FLOAT(viewy)
@ -6090,7 +6077,6 @@ void HWR_RenderPlayerView(void)
player_t * player = &players[displayplayers[viewssnum]];
const float fpov = FIXED_TO_FLOAT(cv_fov[viewssnum].value+player->fovadd);
postimg_t *type = &postimgtype[viewssnum];
const boolean skybox = (skyboxmo[0] && cv_skybox.value); // True if there's a skybox object and skyboxes are on
@ -6166,20 +6152,17 @@ void HWR_RenderPlayerView(void)
gl_viewludsin = FIXED_TO_FLOAT(FINECOSINE(gl_aimingangle>>ANGLETOFINESHIFT));
gl_viewludcos = FIXED_TO_FLOAT(-FINESINE(gl_aimingangle>>ANGLETOFINESHIFT));
if (*type == postimg_flip)
atransform.flip = false;
if ((player->postimgflags & POSTIMG_FLIP) && !(player->postimgflags & POSTIMG_MIRROR))
atransform.flip = true;
else
atransform.flip = false;
if (*type == postimg_mirror)
atransform.mirror = false;
if ((player->postimgflags & POSTIMG_MIRROR) && !(player->postimgflags & POSTIMG_FLIP))
atransform.mirror = true;
else
atransform.mirror = false;
if (*type == postimg_mirrorflip)
atransform.mirrorflip = false;
if ((player->postimgflags & POSTIMG_FLIP) && (player->postimgflags & POSTIMG_MIRROR))
atransform.mirrorflip = true;
else
atransform.mirrorflip = false;
atransform.x = gl_viewx; // FIXED_TO_FLOAT(viewx)
atransform.y = gl_viewy; // FIXED_TO_FLOAT(viewy)
@ -6545,20 +6528,8 @@ INT32 HWR_GetTextureUsed(void)
void HWR_DoPostProcessor(player_t *player)
{
postimg_t *type = &postimgtype[0];
SINT8 i;
HWD.pfnUnSetShader();
for (i = r_splitscreen; i >= 0; i--)
{
if (player == &players[displayplayers[i]])
{
type = &postimgtype[i];
break;
}
}
// Armageddon Blast Flash!
// Could this even be considered postprocessor?
if (player->flashcount)
@ -6592,7 +6563,7 @@ void HWR_DoPostProcessor(player_t *player)
return;
// Drunken vision! WooOOooo~
if (*type == postimg_water || *type == postimg_heat)
if (player->postimgflags & POSTIMG_WATER || player->postimgflags & POSTIMG_HEAT)
{
// 10 by 10 grid. 2 coordinates (xy)
float v[SCREENVERTS][SCREENVERTS][2];
@ -6604,7 +6575,7 @@ void HWR_DoPostProcessor(player_t *player)
INT32 FREQUENCY;
// Modifies the wave.
if (*type == postimg_water)
if (player->postimgflags & POSTIMG_WATER)
{
WAVELENGTH = 5;
AMPLITUDE = 40;

View file

@ -3547,50 +3547,50 @@ void P_DestroyRobots(void)
void P_CalcChasePostImg(player_t *player, camera_t *thiscam)
{
boolean flipcam = (player->pflags & PF_FLIPCAM && player->mo->eflags & MFE_VERTICALFLIP);
postimg_t postimg = postimg_none;
UINT16 postimgflags = 0;
UINT8 i;
// This can happen when joining
if (thiscam->subsector == NULL || thiscam->subsector->sector == NULL)
return;
if (encoremode && !flipcam)
postimg = postimg_mirror;
else if (!encoremode && flipcam)
postimg = postimg_flip;
else if (encoremode && flipcam)
postimg = postimg_mirrorflip;
else if (player->awayviewtics && player->awayviewmobj && !P_MobjWasRemoved(player->awayviewmobj)) // Camera must obviously exist
if (encoremode)
postimgflags |= POSTIMG_MIRROR;
if (flipcam)
postimgflags |= POSTIMG_FLIP;
if (player->awayviewtics && player->awayviewmobj && !P_MobjWasRemoved(player->awayviewmobj)) // Camera must obviously exist
{
camera_t dummycam;
dummycam.subsector = player->awayviewmobj->subsector;
dummycam.x = player->awayviewmobj->x;
dummycam.y = player->awayviewmobj->y;
dummycam.z = player->awayviewmobj->z;
//dummycam.height = 40*FRACUNIT; // alt view height is 20*FRACUNIT
dummycam.height = 0; // Why? Remote viewpoint cameras have no height.
// Are we in water?
if (P_CameraCheckWater(&dummycam))
postimg = postimg_water;
else if (P_CameraCheckHeat(&dummycam))
postimg = postimg_heat;
postimgflags |= POSTIMG_WATER;
if (P_CameraCheckHeat(&dummycam))
postimgflags |= POSTIMG_HEAT;
}
else
{
// Are we in water?
if (P_CameraCheckWater(thiscam))
postimg = postimg_water;
else if (P_CameraCheckHeat(thiscam))
postimg = postimg_heat;
postimgflags |= POSTIMG_WATER;
if (P_CameraCheckHeat(thiscam))
postimgflags |= POSTIMG_HEAT;
}
if (postimg != postimg_none)
for (i = 0; i <= splitscreen; i++)
{
for (i = 0; i <= r_splitscreen; i++)
{
if (player == &players[displayplayers[i]])
postimgtype[i] = postimg;
}
if (player != &players[displayplayers[i]])
continue;
players[displayplayers[i]].postimgflags = postimgflags;
}
}
@ -3599,13 +3599,18 @@ void P_CalcChasePostImg(player_t *player, camera_t *thiscam)
// Process the mobj-ish required functions of the camera
boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled)
{
// This can happen when joining
if (thiscam->subsector == NULL || thiscam->subsector->sector == NULL)
return true;
P_CalcChasePostImg(player, thiscam);
if (thiscam->momx || thiscam->momy)
{
if (!P_TryCameraMove(thiscam->x + thiscam->momx, thiscam->y + thiscam->momy, thiscam)) // Thanks for the greatly improved camera, Lach -- Sev
{ // Never fails for 2D mode.
{
mobj_t dummy;
dummy.thinker.function.acp1 = (actionf_p1)P_MobjThinker;
dummy.subsector = thiscam->subsector;
dummy.x = thiscam->x;

View file

@ -8441,9 +8441,6 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
P_InitLevelSettings(reloadinggamestate);
for (i = 0; i <= r_splitscreen; i++)
postimgtype[i] = postimg_none;
// Initial height of PointOfView
// will be set by player think.
players[consoleplayer].viewz = 1;
@ -8818,11 +8815,6 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
G_CopyTiccmd(&players[i].cmd, &netcmds[buf][i], 1);
}
}
for (i = 0; i <= r_splitscreen; i++)
{
postimgtype[i] = postimg_none;
}
if (marathonmode & MA_INGAME)
{

View file

@ -699,9 +699,6 @@ void P_Ticker(boolean run)
if (!S_MusicPaused())
S_AdjustMusicStackTics();
for (i = 0; i <= r_splitscreen; i++)
postimgtype[i] = postimg_none;
P_MapStart();
if (run)

View file

@ -3359,8 +3359,8 @@ boolean P_SpectatorJoinGame(player_t *player)
static void P_CalcPostImg(player_t *player)
{
sector_t *sector = player->mo->subsector->sector;
postimg_t *type = NULL;
INT32 *param;
INT16 typeflag = 0;
//INT32 *param;
fixed_t pviewheight;
size_t i;
@ -3375,22 +3375,21 @@ static void P_CalcPostImg(player_t *player)
pviewheight = player->awayviewmobj->z + 20*FRACUNIT;
}
for (i = 0; i <= (unsigned)r_splitscreen; i++)
/*for (i = 0; i <= (unsigned)r_splitscreen; i++)
{
if (player == &players[displayplayers[i]])
{
type = &postimgtype[i];
param = &postimgparam[i];
break;
}
}
}*/
// see if we are in heat (no, not THAT kind of heat...)
for (i = 0; i < sector->tags.count; i++)
{
if (Tag_FindLineSpecial(13, sector->tags.tags[i]) != -1)
{
*type = postimg_heat;
typeflag |= POSTIMG_HEAT;
break;
}
else if (sector->ffloors)
@ -3417,7 +3416,7 @@ static void P_CalcPostImg(player_t *player)
{
if (Tag_FindLineSpecial(13, rover->master->frontsector->tags.tags[j]) != -1)
{
*type = postimg_heat;
typeflag |= POSTIMG_HEAT;
gotres = true;
break;
}
@ -3446,36 +3445,35 @@ static void P_CalcPostImg(player_t *player)
if (pviewheight >= topheight || pviewheight <= bottomheight)
continue;
*type = postimg_water;
typeflag |= POSTIMG_WATER;
}
}
if (!encoremode) // srb2kart
{
if (player->mo->eflags & MFE_VERTICALFLIP)
*type = postimg_flip;
}
else
{
if (player->mo->eflags & MFE_VERTICALFLIP)
*type = postimg_mirrorflip;
else
*type = postimg_mirror;
}
if (encoremode) // srb2kart
typeflag |= POSTIMG_MIRROR;
if (player->mo->eflags & MFE_VERTICALFLIP)
typeflag |= POSTIMG_FLIP;
#if 1
(void)param;
#else
// Motion blur
if (player->speed > (35<<FRACBITS))
// unused
/*if (player->speed > (35<<FRACBITS))
{
*type = postimg_motion;
typeflag |= POSTIMG_MOTION;
*param = (player->speed - 32)/4;
if (*param > 5)
*param = 5;
}*/
for (i = 0; i <= (unsigned)r_splitscreen; i++)
{
if (player != &players[displayplayers[i]])
continue;
players[displayplayers[i]].postimgflags = typeflag;
break;
}
#endif
}
void P_DoTimeOver(player_t *player)

View file

@ -2839,8 +2839,8 @@ INT32 heatindex[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0};
//
// Perform a particular image postprocessing function.
//
#include "p_local.h"
void V_DoPostProcessor(INT32 view, postimg_t type, INT32 param)
void V_DoPostProcessor(INT32 view, player_t *player, INT32 param)
{
#if NUMSCREENS < 5
// do not enable image post processing for ARM, SH and MIPS CPUs
@ -2848,6 +2848,7 @@ void V_DoPostProcessor(INT32 view, postimg_t type, INT32 param)
(void)type;
(void)param;
#else
(void)param; // unused motion blur stuff
INT32 yoffset, xoffset;
#ifdef HWRENDER
@ -2868,10 +2869,14 @@ void V_DoPostProcessor(INT32 view, postimg_t type, INT32 param)
else
xoffset = 0;
if (type == postimg_water)
UINT8 *tmpscr = screens[4];
UINT8 *srcscr = screens[0];
if (!player->postimgflags)
return;
if (player->postimgflags & POSTIMG_WATER)
{
UINT8 *tmpscr = screens[4];
UINT8 *srcscr = screens[0];
INT32 y;
// Set disStart to a range from 0 to FINEANGLE, incrementing by 128 per tic
angle_t disStart = (((leveltime-1)*128) + (rendertimefrac / (FRACUNIT/128))) & FINEMASK;
@ -2907,62 +2912,47 @@ void V_DoPostProcessor(INT32 view, postimg_t type, INT32 param)
}
}
/*
Unoptimized version
for (x = 0; x < vid.width*vid.bpp; x++)
{
newpix = (x + sine);
if (newpix < 0)
newpix = 0;
else if (newpix >= vid.width)
newpix = vid.width-1;
tmpscr[y*vid.width + x] = srcscr[y*vid.width+newpix]; // *(transme + (srcscr[y*vid.width+x]<<8) + srcscr[y*vid.width+newpix]);
}*/
/*
* Unoptimized version
* for (x = 0; x < vid.width*vid.bpp; x++)
* {
* newpix = (x + sine);
*
* if (newpix < 0)
* newpix = 0;
* else if (newpix >= vid.width)
* newpix = vid.width-1;
*
* tmpscrwater[y*vid.width + x] = srcscr[y*vid.width+newpix]; // *(transme + (srcscr[y*vid.width+x]<<8) + srcscr[y*vid.width+newpix]);
}*/
disStart += 22;//the offset into the displacement map, increment each game loop
disStart &= FINEMASK; //clip it to FINEMASK
}
VID_BlitLinearScreen(tmpscr+vid.width*vid.bpp*yoffset+xoffset, screens[0]+vid.width*vid.bpp*yoffset+xoffset,
viewwidth*vid.bpp, viewheight, vid.width*vid.bpp, vid.width);
UINT8 *tmp = tmpscr;
tmpscr = srcscr;
srcscr = tmp;
}
else if (type == postimg_motion) // Motion Blur!
/*if (player->postimgflags & POSTIMG_MOTION) // Motion Blur!
* {
* INT32 x, y;
*
* // TODO: Add a postimg_param so that we can pick the translucency level...
* UINT8 *transme = transtables + ((param-1)<<FF_TRANSSHIFT);
*
* for (y = yoffset; y < yoffset+viewheight; y++)
* {
* for (x = xoffset; x < xoffset+viewwidth; x++)
* {
* tmpscr[y*vid.width + x]
* = colormaps[*(transme + (srcscr [(y*vid.width)+x ] <<8) + (tmpscr[(y*vid.width)+x]))];
}
}
}*/
if (player->postimgflags & POSTIMG_HEAT) // Heat wave
{
UINT8 *tmpscr = screens[4];
UINT8 *srcscr = screens[0];
INT32 x, y;
// TODO: Add a postimg_param so that we can pick the translucency level...
UINT8 *transme = R_GetTranslucencyTable(param);
for (y = yoffset; y < yoffset+viewheight; y++)
{
for (x = xoffset; x < xoffset+viewwidth; x++)
{
tmpscr[y*vid.width + x]
= colormaps[*(transme + (srcscr [(y*vid.width)+x ] <<8) + (tmpscr[(y*vid.width)+x]))];
}
}
VID_BlitLinearScreen(tmpscr+vid.width*vid.bpp*yoffset+xoffset, screens[0]+vid.width*vid.bpp*yoffset+xoffset,
viewwidth*vid.bpp, viewheight, vid.width*vid.bpp, vid.width);
}
else if (type == postimg_flip) // Flip the screen upside-down
{
UINT8 *tmpscr = screens[4];
UINT8 *srcscr = screens[0];
INT32 y, y2;
for (y = yoffset, y2 = yoffset+viewheight - 1; y < yoffset+viewheight; y++, y2--)
M_Memcpy(&tmpscr[(y2*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset], viewwidth);
VID_BlitLinearScreen(tmpscr+vid.width*vid.bpp*yoffset+xoffset, screens[0]+vid.width*vid.bpp*yoffset+xoffset,
viewwidth*vid.bpp, viewheight, vid.width*vid.bpp, vid.width);
}
else if (type == postimg_heat) // Heat wave
{
UINT8 *tmpscr = screens[4];
UINT8 *srcscr = screens[0];
INT32 y;
// Make sure table is built
@ -3003,37 +2993,49 @@ Unoptimized version
heatindex[view] %= vid.height;
}
VID_BlitLinearScreen(tmpscr+vid.width*vid.bpp*yoffset+xoffset, screens[0]+vid.width*vid.bpp*yoffset+xoffset,
viewwidth*vid.bpp, viewheight, vid.width*vid.bpp, vid.width);
UINT8 *tmp = tmpscr;
tmpscr = srcscr;
srcscr = tmp;
}
else if (type == postimg_mirror) // Flip the screen on the x axis
if ((player->postimgflags & POSTIMG_FLIP) && !(player->postimgflags & POSTIMG_MIRROR)) // Flip the screen upside-down
{
INT32 y, y2;
for (y = yoffset, y2 = yoffset+viewheight - 1; y < yoffset+viewheight; y++, y2--)
M_Memcpy(&tmpscr[(y2*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset], viewwidth);
UINT8 *tmp = tmpscr;
tmpscr = srcscr;
srcscr = tmp;
}
else if ((player->postimgflags & POSTIMG_MIRROR) && !(player->postimgflags & POSTIMG_FLIP)) // Flip the screen on the x axis
{
UINT8 *tmpscr = screens[4];
UINT8 *srcscr = screens[0];
INT32 y, x, x2;
for (y = yoffset; y < yoffset+viewheight; y++)
{
for (x = xoffset, x2 = xoffset+((viewwidth*vid.bpp)-1); x < xoffset+(viewwidth*vid.bpp); x++, x2--)
tmpscr[y*vid.width + x2] = srcscr[y*vid.width + x];
}
VID_BlitLinearScreen(tmpscr+vid.width*vid.bpp*yoffset+xoffset, screens[0]+vid.width*vid.bpp*yoffset+xoffset,
viewwidth*vid.bpp, viewheight, vid.width*vid.bpp, vid.width);
UINT8 *tmp = tmpscr;
tmpscr = srcscr;
srcscr = tmp;
}
else if (type == postimg_mirrorflip) // Flip the screen upside-down and on the x axis
else if ((player->postimgflags & POSTIMG_MIRROR) && (player->postimgflags & POSTIMG_FLIP)) // Flip the screen upside-down and on the x axis
{
UINT8 *tmpscr = screens[4];
UINT8 *srcscr = screens[0];
INT32 y, x;
for (y = yoffset; y < yoffset + viewheight; y++)
for (x = xoffset; x < xoffset + viewwidth; x++)
tmpscr[((yoffset + viewheight - 1 - y) * vid.width) + xoffset + viewwidth - (x - xoffset) - 1] = srcscr[(y * vid.width) + x];
VID_BlitLinearScreen(tmpscr+vid.width*vid.bpp*yoffset+xoffset, screens[0]+vid.width*vid.bpp*yoffset+xoffset,
viewwidth*vid.bpp, viewheight, vid.width*vid.bpp, vid.width);
UINT8 *tmp = tmpscr;
tmpscr = srcscr;
srcscr = tmp;
}
VID_BlitLinearScreen(srcscr+vid.width*vid.bpp*yoffset+xoffset, tmpscr+vid.width*vid.bpp*yoffset+xoffset,
viewwidth*vid.bpp, viewheight, vid.width*vid.bpp, vid.width);
#endif
}

View file

@ -337,7 +337,7 @@ INT32 V_ThinStringWidth(const char *string, INT32 option);
// Find string width from tny_font chars, 0.5x scale
INT32 V_SmallThinStringWidth(const char *string, INT32 option);
void V_DoPostProcessor(INT32 view, postimg_t type, INT32 param);
void V_DoPostProcessor(INT32 view, player_t *player, INT32 param);
void V_DrawPatchFill(patch_t *pat);