Compare commits

...
15 Commits
Author SHA1 Message Date
alufolie91 f332e21fa7 adjust shader vhs fuzzyness to match software at default res
the shader looks the same no matter the resolution, so we shouldnt scale this at all
thisll now treat rows for offsetting like its always default resolution (1280x800)
also readjusted the upwards bar since its actually the same size as the downwards bar lul
2026-11-16 00:04:48 +01:00
alufolie91 bc4c1637ad use menu rendertimefrac for shader vhs
forgor abt this, fixes interp in replay hut lulul
2026-11-15 16:41:51 +01:00
alufolie91 d9e3dd979e Merge branch 'Saturn-Next' into shadercrap 2026-11-15 01:27:02 +01:00
alufolie91 6b84c86197 fix vhs effect bars when rewinding
noticed while doing the shader thing
basically the effect is supposed to stack
but both calls being recursive, updated just the same bar positions, so both sets of bars would just draw over each other
this basically just like, keeps seperate positions for when rewind it true
this is probably how it was intended to work, otherwise that code makes not much sense
2026-11-15 01:26:57 +01:00
alufolie91 df8f167549 combine both vhs shaders
not sure why i didnt think of this lul
saves us another screen texture copy and draw
so shit is even faster
2026-11-15 00:33:46 +01:00
alufolie91 d60d9d5611 make vhs shader bars use triangle instead of sine
also adjust the color since they were too dark compared to software
idk maths for shit so this is pieced together from shit i found on the interwebs
this matches software since it also does the trongle for this ugh
the rest was also retuned and basically matches software at default res almost 1:1
2026-11-15 00:08:02 +01:00
alufolie91 b5f4db5131 wrap vhs shader distortion horizontally instead of clamping
matches software aswell!
thisll take the screen from the opposite site instead of "stretching" it
always forget modulo is a thing lul
2026-11-14 22:47:13 +01:00
alufolie91 f74a7e3f07 flip shader vhs horizontal distortion direction
matches software
2026-11-14 22:46:36 +01:00
alufolie91 8e1212d9d5 fix uv clamps in the RR screen shaders
forgor
this makes sure the shaders dont sample outside the screen region as the screen textures may not be exactly screen sized
2026-11-14 21:55:28 +01:00
alufolie91 cc952dfd52 use software wall/slope contrast checks in gl paletterendering mode
simple enough change which should make this match up more, tho shouldnt be super different
2026-11-14 06:40:07 +01:00
alufolie91 063f94da8b fix slope contrast
missed a fix when ported it so the contrast direction was off by 90 degrees
also apparently i moved the software contrast part to never apply to fofs for some reason?
rechecked against the srb2 code for this and now properly matches up
2026-11-14 06:40:07 +01:00
alufolie91 457cae0ed9 adjust floor fudge for palette render
this significantly more matches software especially when drawing horizonlines
as gl was too dark in the distance compared to software
theres still some things left to recheck to better match software lighting (ex. wallcontrast) but too lazy atm
2026-11-14 06:40:07 +01:00
alufolie91 b990589e66 smol style fixes lua mobj and player lib 2026-11-14 06:40:07 +01:00
alufolie91 59a4627911 gl: use shaders for vhs effect
this is a fuckton faster lol
the old one did a gazillion draw calls now we do two, one for the fuzzy and the 2nd for the bars as both are handled within a single shader
thanks to RRs heat effect being super similar to the vhs bars lul
2026-11-12 21:02:07 +01:00
alufolie91 ecab383078 gl: use shaders for underwater / heatwave effect
basically ported over from RR
water was massively toned down and adjusted, it visually almost matches software at default res (note that the software effects are not properly scaled lol)
the heat effect is just the water effect adjusted to look like the fixed function version from before but slightly slower to accomidate the slower water effect here

this should speed things up a little since we now only need ONE draw call instead of 20 per effect
small note: this does not zoom into the image like the shaderless version, which was quite jarring tbh but there can be some very slight "stretch" marks at screen border, but theyre extremely unnoticable
2026-11-12 20:32:38 +01:00
12 changed files with 633 additions and 365 deletions

No files matched your search

+5
View File
@@ -196,6 +196,11 @@ enum
SHADER_PALETTE_POSTPROCESS, SHADER_PALETTE_POSTPROCESS,
SHADER_UI_COLORMAP_FADE, SHADER_UI_COLORMAP_FADE,
SHADER_POSTPROCESS_WATER,
SHADER_POSTPROCESS_HEAT,
SHADER_VHS,
NUMSHADERTARGETS NUMSHADERTARGETS
}; };
+2 -1
View File
@@ -66,10 +66,11 @@ void GL_FlushScreenTextures(void);
void GL_DrawScreenTexture(int tex, FSurfaceInfo *surf, FBITFIELD polyflags); void GL_DrawScreenTexture(int tex, FSurfaceInfo *surf, FBITFIELD polyflags);
void GL_DoScreenWipe(int wipeStart, int wipeEnd); void GL_DoScreenWipe(int wipeStart, int wipeEnd);
void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize); void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize, boolean rewind);
void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height); void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height);
void GL_PostImgRedraw(float points[SCREENVERTS][SCREENVERTS][2]); void GL_PostImgRedraw(float points[SCREENVERTS][SCREENVERTS][2]);
void GL_DoPostProcessor(INT32 type);
boolean GL_InitShaders(void); boolean GL_InitShaders(void);
void GL_LoadShader(int slot, char *code, hwdshaderstage_t stage); void GL_LoadShader(int slot, char *code, hwdshaderstage_t stage);
+53 -32
View File
@@ -504,6 +504,13 @@ static UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap) // Let's
return surfcolor.s.alpha; return surfcolor.s.alpha;
} }
static boolean HWR_ApplyLightOffset(UINT8 baselightnum, const sector_t *sector)
{
if (HWR_ShouldUsePaletteRendering())
return P_ApplyLightOffset(baselightnum >> LIGHTSEGSHIFT, sector);
return P_ApplyLightOffsetFine(baselightnum, sector);
}
static FUINT HWR_CalcWallLight(FUINT lightnum, seg_t *seg, extracolormap_t *colormap) static FUINT HWR_CalcWallLight(FUINT lightnum, seg_t *seg, extracolormap_t *colormap)
{ {
INT16 finallight = lightnum; INT16 finallight = lightnum;
@@ -511,7 +518,7 @@ static FUINT HWR_CalcWallLight(FUINT lightnum, seg_t *seg, extracolormap_t *colo
if (cv_glfakecontrast.value == 0 || (colormap && HWR_ShouldUsePaletteRendering())) if (cv_glfakecontrast.value == 0 || (colormap && HWR_ShouldUsePaletteRendering()))
return (FUINT)finallight; return (FUINT)finallight;
if (seg != NULL && P_ApplyLightOffsetFine(lightnum, seg->frontsector)) if (seg != NULL && HWR_ApplyLightOffset(lightnum, seg->frontsector))
{ {
const INT16 offset = (cv_glfakecontrast.value == 2) ? seg->hwLightOffset : ((INT16)seg->lightOffset * 8); const INT16 offset = (cv_glfakecontrast.value == 2) ? seg->hwLightOffset : ((INT16)seg->lightOffset * 8);
@@ -529,10 +536,9 @@ static FUINT HWR_CalcSlopeLight(FUINT lightnum, pslope_t *slope, const sector_t
if (cv_glfakecontrast.value == 0 || cv_glslopecontrast.value == 0) if (cv_glfakecontrast.value == 0 || cv_glslopecontrast.value == 0)
return (FUINT)finallight; return (FUINT)finallight;
if (slope != NULL && sector != NULL && P_ApplyLightOffsetFine(lightnum, sector)) if (slope != NULL && sector != NULL && HWR_ApplyLightOffset(lightnum, sector))
{ {
const INT16 offset = (cv_glfakecontrast.value == 2) ? slope->hwLightOffset : ((INT16)slope->lightOffset * 8); const INT16 offset = (cv_glfakecontrast.value == 2) ? slope->hwLightOffset : ((INT16)slope->lightOffset * 8);
finallight += (fof ? -offset : offset); finallight += (fof ? -offset : offset);
finallight = CLAMP(finallight, 0, 255); finallight = CLAMP(finallight, 0, 255);
} }
@@ -5992,8 +5998,7 @@ void HWR_RenderPlayerView(void)
if (HWR_UseShader()) if (HWR_UseShader())
{ {
if (cv_ripplewater.value) GL_SetShaderInfo(HWD_SHADERINFO_LEVELTIME, (INT32)leveltime); // The water surface shader needs the leveltime.
GL_SetShaderInfo(HWD_SHADERINFO_LEVELTIME, (INT32)leveltime); // The water surface shader needs the leveltime.
if (cv_glmdls.value) if (cv_glmdls.value)
{ {
@@ -6002,7 +6007,7 @@ void HWR_RenderPlayerView(void)
const angle_t light_angle = maplighting.angle - viewangle + ANGLE_90; // I fucking hate OGL's coordinate system const angle_t light_angle = maplighting.angle - viewangle + ANGLE_90; // I fucking hate OGL's coordinate system
GL_SetShaderInfo(HWD_SHADERINFO_LIGHT_X, FINECOSINE(light_angle >> ANGLETOFINESHIFT)); GL_SetShaderInfo(HWD_SHADERINFO_LIGHT_X, FINECOSINE(light_angle >> ANGLETOFINESHIFT));
GL_SetShaderInfo(HWD_SHADERINFO_LIGHT_Y, 0); GL_SetShaderInfo(HWD_SHADERINFO_LIGHT_Y, 0);
GL_SetShaderInfo(HWD_SHADERINFO_LIGHT_Z, -FINESINE(light_angle >> ANGLETOFINESHIFT)); GL_SetShaderInfo(HWD_SHADERINFO_LIGHT_Z, -FINESINE(light_angle >> ANGLETOFINESHIFT));
} }
GL_SetShaderInfo(HWD_SHADERINFO_LIGHT_CONTRAST, maplighting.contrast); GL_SetShaderInfo(HWD_SHADERINFO_LIGHT_CONTRAST, maplighting.contrast);
@@ -6352,42 +6357,58 @@ static void HWR_DoPostProcessor(void)
GL_MakeScreenTexture(HWD_SCREENTEXTURE_GENERIC1); GL_MakeScreenTexture(HWD_SCREENTEXTURE_GENERIC1);
// Drunken vision! WooOOooo~ // Drunken vision! WooOOooo~
// 10 by 10 grid. 2 coordinates (xy)
float v[SCREENVERTS][SCREENVERTS][2];
float disStart = (leveltime-1) + FixedToFloat(R_GetTimeFrac(RTF_LEVEL));
UINT8 x, y; // shader based, should be a bit faster!
float WAVELENGTH; if (HWR_UseShader())
float AMPLITUDE;
float FREQUENCY;
// Modifies the wave.
if (thiscam->postimg & POSTIMG_WATER)
{ {
WAVELENGTH = 5.0f; if (thiscam->postimg & POSTIMG_WATER)
AMPLITUDE = 40.0f; {
FREQUENCY = 8.0f; GL_DoPostProcessor(POSTIMG_WATER);
}
else if (thiscam->postimg & POSTIMG_HEAT)
{
GL_DoPostProcessor(POSTIMG_HEAT);
}
} }
else else
{ {
WAVELENGTH = 10.0f; // 10 by 10 grid. 2 coordinates (xy)
AMPLITUDE = 60.0f; float v[SCREENVERTS][SCREENVERTS][2];
FREQUENCY = 4.0f; float disStart = (leveltime-1) + FixedToFloat(R_GetTimeFrac(RTF_LEVEL));
}
//static constexpr float scale = ((float)SCREENVERTS - 1.0f) / 9.0f; // well this evals to just 1.0f and what is x / 1? kek UINT8 x, y;
float WAVELENGTH;
float AMPLITUDE;
float FREQUENCY;
for (x = 0; x < SCREENVERTS; x++) // Modifies the wave.
{ if (thiscam->postimg & POSTIMG_WATER)
for (y = 0; y < SCREENVERTS; y++)
{ {
// Change X position based on its Y position. WAVELENGTH = 5.0f;
v[x][y][0] = x-4.5f + sinf(((disStart+(static_cast<float>(y) * WAVELENGTH)) / FREQUENCY)) / AMPLITUDE; // (x / scale) AMPLITUDE = 40.0f;
v[x][y][1] = y-4.5f; // (y / scale) FREQUENCY = 8.0f;
}
else
{
WAVELENGTH = 10.0f;
AMPLITUDE = 60.0f;
FREQUENCY = 4.0f;
} }
}
GL_PostImgRedraw(v); //static constexpr float scale = ((float)SCREENVERTS - 1.0f) / 9.0f; // well this evals to just 1.0f and what is x / 1? kek
for (x = 0; x < SCREENVERTS; x++)
{
for (y = 0; y < SCREENVERTS; y++)
{
// Change X position based on its Y position.
v[x][y][0] = x-4.5f + sinf(((disStart+(static_cast<float>(y) * WAVELENGTH)) / FREQUENCY)) / AMPLITUDE; // (x / scale)
v[x][y][1] = y-4.5f; // (y / scale)
}
}
GL_PostImgRedraw(v);
}
// Capture the screen again for screen waving on the intermission // Capture the screen again for screen waving on the intermission
if (gamestate != GS_INTERMISSION) if (gamestate != GS_INTERMISSION)
+2 -2
View File
@@ -145,9 +145,9 @@ FUNCINLINE static ATTRINLINE void HWR_DrawIntermissionBG(void)
GL_DrawScreenTexture(HWD_SCREENTEXTURE_GENERIC1, NULL, 0); GL_DrawScreenTexture(HWD_SCREENTEXTURE_GENERIC1, NULL, 0);
} }
FUNCINLINE static ATTRINLINE void HWR_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize) FUNCINLINE static ATTRINLINE void HWR_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize, boolean rewind)
{ {
GL_RenderVhsEffect(upbary, downbary, updistort, downdistort, barsize); GL_RenderVhsEffect(upbary, downbary, updistort, downdistort, barsize, rewind);
} }
FUNCINLINE static ATTRINLINE void HWR_MakeScreenTexture(void) FUNCINLINE static ATTRINLINE void HWR_MakeScreenTexture(void)
+12
View File
@@ -53,6 +53,15 @@ static struct {
// UI colormap fade shader // UI colormap fade shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_UI_COLORMAP_FADE_FRAGMENT_SHADER}, {GLSL_DEFAULT_VERTEX_SHADER, GLSL_UI_COLORMAP_FADE_FRAGMENT_SHADER},
// water postprocess shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_POSTPROCESS_FRAGMENT_WATER},
// heat postprocess shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_POSTPROCESS_FRAGMENT_HEAT},
// VHS effect
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_VHS_SHADER},
{NULL, NULL}, {NULL, NULL},
}; };
@@ -444,6 +453,9 @@ customshaderxlat_t shaderxlat[] =
{"Sky", SHADER_SKY}, {"Sky", SHADER_SKY},
{"PalettePostprocess", SHADER_PALETTE_POSTPROCESS}, {"PalettePostprocess", SHADER_PALETTE_POSTPROCESS},
{"UIColormapFade", SHADER_UI_COLORMAP_FADE}, {"UIColormapFade", SHADER_UI_COLORMAP_FADE},
{"PostProcessWater", SHADER_POSTPROCESS_WATER},
{"PostProcessHeat", SHADER_POSTPROCESS_HEAT},
{"VHS", SHADER_VHS},
{NULL, 0}, {NULL, 0},
}; };
+118 -1
View File
@@ -196,7 +196,11 @@
// hand tuned adjustments for light level calculation // hand tuned adjustments for light level calculation
#define GLSL_FLOOR_FUDGES \ #define GLSL_FLOOR_FUDGES \
"#define STARTMAP_FUDGE 1.06\n" \ "#define STARTMAP_FUDGE 1.06\n" \
"#define SCALE_FUDGE 1.15\n" "#ifdef SRB2_PALETTE_RENDERING\n" \
"#define SCALE_FUDGE 1.3\n" \
"#else\n" \
"#define SCALE_FUDGE 1.15\n" \
"#endif\n"
#define GLSL_WALL_FUDGES \ #define GLSL_WALL_FUDGES \
"#define STARTMAP_FUDGE 1.05\n" \ "#define STARTMAP_FUDGE 1.05\n" \
@@ -337,6 +341,119 @@
"gl_FragColor = texture2D(lighttable_tex, lighttable_coord);\n" \ "gl_FragColor = texture2D(lighttable_tex, lighttable_coord);\n" \
"}\0" \ "}\0" \
// these are RRs postprocess shaders
// for water and heat
/*
#define GLSL_POSTPROCESS_FRAGMENT_WATER \
"uniform sampler2D tex;\n" \
"uniform vec2 scr_resolution;\n" \
"uniform vec2 scr_tex_size;\n" \
"uniform float leveltime;\n" \
"void main(void) {\n" \
"vec2 uv = gl_TexCoord[0].st;\n" \
"vec2 maxuv = scr_resolution / scr_tex_size;\n" \
"float y = 1.0 - uv.y;\n" \
"uv.x += sin(leveltime * 2.0 + y * 20.0) * 0.01;\n" \
"uv = clamp(uv, vec2(0.0), maxuv - vec2(0.0001));\n" \
"gl_FragColor = texture2D(tex, uv);\n" \
"}\0"
#define GLSL_POSTPROCESS_FRAGMENT_HEAT \
"uniform sampler2D tex;\n" \
"uniform vec2 scr_resolution;\n" \
"uniform vec2 scr_tex_size;\n" \
"uniform float leveltime;\n" \
"void main(void) {\n" \
"vec2 uv = gl_TexCoord[0].st;\n" \
"vec2 maxuv = scr_resolution / scr_tex_size;\n" \
"float y = 1.0 - uv.y;\n" \
"float time = leveltime * 35.0;\n" \
"uv.x += max(sin((time / 35.0) * 1.2 - y * 5.0) - 0.995, 0.0);\n" \
"uv.x -= max(sin(((time + 24.0) / 35.0) * 0.2 - y * 1.5) - 0.990, 0.0);\n" \
"uv = clamp(uv, vec2(0.0), maxuv - vec2(0.0001));\n" \
"gl_FragColor = texture2D(tex, uv);\n" \
"}\0"
*/
// for reference
// sin(leveltime * X + (y) + Y) * Z
// X = Speed, Y = Vertical phase, Z = Amplitude
// this matches software at 720p wonderfully
#define GLSL_POSTPROCESS_FRAGMENT_WATER \
"#version 120\n" \
"uniform sampler2D tex;\n" \
"uniform vec2 scr_resolution;\n" \
"uniform vec2 scr_tex_size;\n" \
"uniform float leveltime;\n" \
"void main(void) {\n" \
"vec2 uv = gl_TexCoord[0].st;\n" \
"vec2 maxuv = scr_resolution / scr_tex_size;\n" \
"float y = 1.0 - uv.y;\n" \
"uv.x += sin(leveltime * 3.0 + y * 15.0) * 0.0025;\n" \
"uv = clamp(uv, vec2(0.0), maxuv - vec2(0.0001));\n" \
"gl_FragColor = texture2D(tex, uv);\n" \
"}\0"
// like the fixed function version, this is just the water wave again
// a bit readjusted since the shader wave is more lean
// makes it less neausiating anyways :p
#define GLSL_POSTPROCESS_FRAGMENT_HEAT \
"#version 120\n" \
"uniform sampler2D tex;\n" \
"uniform vec2 scr_resolution;\n" \
"uniform vec2 scr_tex_size;\n" \
"uniform float leveltime;\n" \
"void main(void) {\n" \
"vec2 uv = gl_TexCoord[0].st;\n" \
"vec2 maxuv = scr_resolution / scr_tex_size;\n" \
"float y = 1.0 - uv.y;\n" \
"uv.x += sin(leveltime * 6.0 + y * 22.5) * 0.00125;\n" \
"uv = clamp(uv, vec2(0.0), maxuv - vec2(0.0001));\n" \
"gl_FragColor = texture2D(tex, uv);\n" \
"}\0"
// VHS effect as a shader
// basically just what we did before as a shader lul
// the bars are just the RR heat shader repurposed
// thanks "stackoverflow.com/a/4275343" for the pseudo random stuff for glsl
// and thanks "thndl.com/triangle-waves" and "gamedev.stackexchange.com/q/191829"
// for the maths since im super bad at stuff
// 0.159155 = 1/pi*2
#define GLSL_VHS_SHADER \
"#version 120\n" \
"uniform sampler2D tex;\n" \
"uniform vec2 scr_resolution;\n" \
"uniform vec2 scr_tex_size;\n" \
"uniform float vhs_time;\n" \
"uniform float vhs_rewind;\n" \
"void main(void) {\n" \
"vec2 uv = gl_TexCoord[0].st;\n" \
"vec2 maxuv = scr_resolution / scr_tex_size;\n" \
"float y = (1.0 - uv.y);\n" \
"float ystep = floor(y * (800 / 2.0));\n" \
"float rand = fract(sin((ystep + vhs_time) * 12.9898 + 78.233) * 43758.5453);\n" \
"uv.x -= floor(rand * 128.0) / -22000.0;\n" \
"float updistort = (vhs_rewind > 0.5) ? 0.266667 : 0.16;\n" \
"float downdistort = updistort / 2.0;\n" \
"float downspd = (vhs_rewind > 0.5) ? 2.0 : 1.0;\n" \
"float upspd = (vhs_rewind > 0.5) ? 3.0 : 1.8;\n" \
"float downbar = max((1.0 - abs(2.0 * fract((vhs_time * downspd - y * 5.0) * 0.159155) - 1.0)) - 0.87, 0.0);\n" \
"float upbar = max((1.0 - abs(2.0 * fract(((vhs_time * -1.0) * upspd - y * 5.0) * 0.159155) - 1.0)) - 0.87, 0.0);\n" \
"uv.x -= downbar * downdistort;\n" \
"uv.x += upbar * updistort;\n" \
"uv.y = clamp(uv.y, 0.0, maxuv.y - 0.0001);\n" \
"uv.x = mod(uv.x, maxuv.x - 0.0001);\n" \
"vec4 color = texture2D(tex, uv);\n" \
"float downcol = step(0.00001, downbar);\n" \
"float upcol = step(0.00001, upbar);\n" \
"color.rgb = mix(color.rgb, color.rgb * (210.0 / 255.0), downcol);\n" \
"color.rgb = mix(color.rgb, color.rgb * (210.0 / 255.0), upcol);\n" \
"color.a = mix(color.a, color.a * (250.0 / 255.0), downcol);\n" \
"color.a = mix(color.a, color.a * (250.0 / 255.0), upcol);\n" \
"gl_FragColor = color;\n" \
"}\0"
// ================ // ================
// Fallback shaders // Fallback shaders
// ================ // ================
+210 -94
View File
@@ -761,6 +761,13 @@ typedef enum
gluniform_scr_resolution, gluniform_scr_resolution,
// postprocess stuff
gluniform_scr_tex_size,
// vhs
gluniform_vhs_rewind,
gluniform_vhs_time,
gluniform_max, gluniform_max,
} gluniform_t; } gluniform_t;
@@ -793,6 +800,9 @@ static float shader_light_z = 0.0f;
static INT32 shader_light_contrast = 0; static INT32 shader_light_contrast = 0;
static INT32 shader_light_backlight = 0; static INT32 shader_light_backlight = 0;
static float shader_vhs_rewind = 1.0f;
static float shader_vhs_time = 0.0f;
// Lactozilla: Shader functions // Lactozilla: Shader functions
static boolean GL_Shader_CompileProgram(gl_shader_t *shader, GLint i); static boolean GL_Shader_CompileProgram(gl_shader_t *shader, GLint i);
static void GL_Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAFloat *tint, GLRGBAFloat *fade); static void GL_Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAFloat *tint, GLRGBAFloat *fade);
@@ -2330,6 +2340,12 @@ static void GL_Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRG
UNIFORM_2(shader->uniforms[gluniform_scr_resolution], (GLfloat)screen_width, (GLfloat)screen_height, pglUniform2f); UNIFORM_2(shader->uniforms[gluniform_scr_resolution], (GLfloat)screen_width, (GLfloat)screen_height, pglUniform2f);
// grrrrr stupid 2.0 support.. used similar to yfix, xfix
UNIFORM_2(shader->uniforms[gluniform_scr_tex_size], (GLfloat)screen_texsizew, (GLfloat)screen_texsizeh, pglUniform2f);
UNIFORM_1(shader->uniforms[gluniform_vhs_rewind], shader_vhs_rewind, pglUniform1f);
UNIFORM_1(shader->uniforms[gluniform_vhs_time], shader_vhs_time, pglUniform1f);
#undef UNIFORM_1 #undef UNIFORM_1
#undef UNIFORM_2 #undef UNIFORM_2
#undef UNIFORM_3 #undef UNIFORM_3
@@ -2461,6 +2477,14 @@ static boolean GL_Shader_CompileProgram(gl_shader_t *shader, GLint i)
// misc. // misc.
shader->uniforms[gluniform_leveltime] = GETUNI("leveltime"); shader->uniforms[gluniform_leveltime] = GETUNI("leveltime");
// postprocessor stuff (water/heat effect)
shader->uniforms[gluniform_scr_tex_size] = GETUNI("scr_tex_size");
// vhs stuff
shader->uniforms[gluniform_vhs_rewind] = GETUNI("vhs_rewind");
shader->uniforms[gluniform_vhs_time] = GETUNI("vhs_time");
#undef GETUNI #undef GETUNI
// set permanent uniform values // set permanent uniform values
@@ -3597,6 +3621,55 @@ INT32 GL_GetTextureUsed(void)
return res; return res;
} }
void GL_DoPostProcessor(INT32 type)
{
float fix[8];
float xfix, yfix;
if (gl_enable_screen_textures != 2)
return;
xfix = 1/((float)screen_texsizew/(float)screen_width);
yfix = 1/((float)screen_texsizeh/(float)screen_height);
fix[0] = fix[1] =
fix[2] = fix[7] = 0.0f;
fix[3] = fix[5] = yfix;
fix[4] = fix[6] = xfix;
// this shouldnt be necessary, since this comes after level draw
// but somehow it breaks without this??
pglMatrixMode(GL_PROJECTION);
pglPushMatrix();
pglLoadIdentity();
pglMatrixMode(GL_MODELVIEW);
pglPushMatrix();
pglLoadIdentity();
GL_SetBlend(PF_NoDepthTest);
pglActiveTexture(GL_TEXTURE0);
pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_GENERIC1]);
tex_downloaded = screenTextures[HWD_SCREENTEXTURE_GENERIC1];
int shader = (type == POSTIMG_WATER) ? SHADER_POSTPROCESS_WATER : SHADER_POSTPROCESS_HEAT;
GL_SetShader(HWR_GetShaderFromTarget(shader));
GL_Shader_SetUniforms(NULL, NULL, NULL, NULL);
pglColor4ubv(white);
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
pglVertexPointer(3, GL_FLOAT, 0, defaultscreenVerts);
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
GL_UnSetShader();
pglMatrixMode(GL_PROJECTION);
pglPopMatrix();
pglMatrixMode(GL_MODELVIEW);
pglPopMatrix();
}
void GL_PostImgRedraw(float points[SCREENVERTS][SCREENVERTS][2]) void GL_PostImgRedraw(float points[SCREENVERTS][SCREENVERTS][2])
{ {
INT32 x, y; INT32 x, y;
@@ -3716,7 +3789,6 @@ void GL_DrawScreenTexture(int tex, FSurfaceInfo *surf, FBITFIELD polyflags)
tex_downloaded = screenTextures[tex]; tex_downloaded = screenTextures[tex];
} }
// Do screen fades! // Do screen fades!
void GL_DoScreenWipe(int wipeStart, int wipeEnd) void GL_DoScreenWipe(int wipeStart, int wipeEnd)
{ {
@@ -3791,120 +3863,164 @@ void GL_DoScreenWipe(int wipeStart, int wipeEnd)
tex_downloaded = screenTextures[wipeEnd]; tex_downloaded = screenTextures[wipeEnd];
} }
void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize) void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize, boolean rewind)
{ {
float xfix, yfix; float xfix, yfix;
float fix[8]; float fix[8];
float i;
if (gl_enable_screen_textures != 2) if (gl_enable_screen_textures != 2)
return; return;
GLubyte color[4] = {255, 255, 255, 255};
float screenVerts[12] =
{
-1.0f, -1.0f, 1.0f,
-1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f, -1.0f, 1.0f
};
const GLfloat scrwf = (float)screen_width; const GLfloat scrwf = (float)screen_width;
const GLfloat scrwh = (float)screen_height; const GLfloat scrhf = (float)screen_height;
xfix = 1/((float)screen_texsizew/scrwf); xfix = 1/((float)screen_texsizew/scrwf);
yfix = 1/((float)screen_texsizeh/scrwh); yfix = 1/((float)screen_texsizeh/scrhf);
GL_SetBlend(PF_Modulated|PF_Translucent|PF_NoDepthTest); // uses shaders to replicate the effect
// thanks RR for their heat effect being basically the vhs bars, made this lots easier lul
// Slight fuzziness if (HWR_UseShader())
GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS);
pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]);
uint32_t r = rand();
const float ystep = 2.f/scrwh * (float)vid.udup/4.f;
for (i = 0; i < 1; i += ystep)
{ {
// avoid calling rand thousands of times // leveltime pauses with the game so we need to keep our own counter here
r ^= r >> 13; static tic_t lleveltime = 0;
r ^= r >> 11; if (renderisnewtic) lleveltime++;
r ^= r << 21; shader_vhs_time = (((float)(lleveltime-1)) + FIXED_TO_FLOAT(R_GetTimeFrac(RTF_MENU))) / TICRATE;
fix[2] = (float)(r & 127) / -22000.f * xfix; // easier to account for within the shader
fix[0] = fix[2]; shader_vhs_rewind = rewind ? 1.0f : 0.0f;
fix[6] = fix[0] + xfix;
fix[4] = fix[2] + xfix;
fix[1] = fix[7] = i*yfix;
fix[3] = fix[5] = (i+0.015f)*yfix;
screenVerts[1] = screenVerts[10] = 2*i - 1.0f; fix[0] = fix[1] =
screenVerts[4] = screenVerts[7] = screenVerts[1] + 0.03f; fix[2] = fix[7] = 0.0f;
fix[3] = fix[5] = yfix;
fix[4] = fix[6] = xfix;
GL_SetBlend(PF_NoDepthTest);
// Slight fuzziness
GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS);
pglActiveTexture(GL_TEXTURE0);
pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]);
tex_downloaded = screenTextures[HWD_SCREENTEXTURE_VHS];
GL_SetShader(HWR_GetShaderFromTarget(SHADER_VHS));
GL_Shader_SetUniforms(NULL, NULL, NULL, NULL);
pglColor4ubv(white);
pglEnableClientState(GL_TEXTURE_COORD_ARRAY);
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
pglVertexPointer(3, GL_FLOAT, 0, defaultscreenVerts);
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
GL_UnSetShader();
}
else // fallback fixed function version, this is quite slow
{
float i;
GLubyte color[4] = {255, 255, 255, 255};
float screenVerts[12] =
{
-1.0f, -1.0f, 1.0f,
-1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f, -1.0f, 1.0f
};
xfix = 1/((float)screen_texsizew/scrwf);
yfix = 1/((float)screen_texsizeh/scrhf);
GL_SetBlend(PF_Modulated|PF_Translucent|PF_NoDepthTest);
// Slight fuzziness
GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS);
pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]);
uint32_t r = rand();
const float ystep = 2.f/scrhf * (float)vid.udup/4.f;
for (i = 0.0; i < 1.0; i += ystep)
{
// avoid calling rand thousands of times
r ^= r >> 13;
r ^= r >> 11;
r ^= r << 21;
fix[2] = (float)(r & 127) / -22000.f * xfix;
fix[0] = fix[2];
fix[6] = fix[0] + xfix;
fix[4] = fix[2] + xfix;
fix[1] = fix[7] = i*yfix;
fix[3] = fix[5] = (i+0.015f)*yfix;
screenVerts[1] = screenVerts[10] = 2*i - 1.0f;
screenVerts[4] = screenVerts[7] = screenVerts[1] + 0.03f;
pglColor4ubv(color);
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
pglVertexPointer(3, GL_FLOAT, 0, screenVerts);
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
}
// Upward bar
GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS);
pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]);
color[0] = color[1] = color[2] = 190;
color[3] = 250;
pglColor4ubv(color); pglColor4ubv(color);
fix[0] = 0.0f;
fix[6] = xfix;
fix[2] = (float)updistort / scrwf * xfix;
fix[4] = fix[2] + fix[6];
screenVerts[1] = screenVerts[10] = 2.0f*upbary/scrhf - 1.0f;
screenVerts[4] = screenVerts[7] = screenVerts[1] + (float)barsize/scrhf;
fix[1] = fix[7] = (float)upbary/scrhf * yfix;
fix[3] = fix[5] = fix[1] + (float)barsize/2/scrhf * yfix;
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
pglVertexPointer(3, GL_FLOAT, 0, screenVerts);
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
fix[1] = fix[7] += (fix[3] - fix[7])*2;
screenVerts[1] = screenVerts[10] += (screenVerts[4] - screenVerts[1])*2;
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
pglVertexPointer(3, GL_FLOAT, 0, screenVerts);
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
// Downward bar
GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS);
pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]);
fix[0] = 0.0f;
fix[6] = xfix;
fix[2] = (float)downdistort / scrwf * -xfix;
fix[4] = fix[2] + fix[6];
screenVerts[1] = screenVerts[10] = 2.0f*downbary/scrhf - 1.0f;
screenVerts[4] = screenVerts[7] = screenVerts[1] + (float)barsize/scrhf;
fix[1] = fix[7] = (float)downbary/scrhf * yfix;
fix[3] = fix[5] = fix[1] + (float)barsize/2/scrhf * yfix;
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
pglVertexPointer(3, GL_FLOAT, 0, screenVerts);
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
fix[1] = fix[7] += (fix[3] - fix[7])*2;
screenVerts[1] = screenVerts[10] += (screenVerts[4] - screenVerts[1])*2;
pglTexCoordPointer(2, GL_FLOAT, 0, fix); pglTexCoordPointer(2, GL_FLOAT, 0, fix);
pglVertexPointer(3, GL_FLOAT, 0, screenVerts); pglVertexPointer(3, GL_FLOAT, 0, screenVerts);
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4); pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
} }
// Upward bar
GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS);
pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]);
color[0] = color[1] = color[2] = 190;
color[3] = 250;
pglColor4ubv(color);
fix[0] = 0.0f;
fix[6] = xfix;
fix[2] = (float)updistort / scrwf * xfix;
fix[4] = fix[2] + fix[6];
screenVerts[1] = screenVerts[10] = 2.0f*upbary/scrwh - 1.0f;
screenVerts[4] = screenVerts[7] = screenVerts[1] + (float)barsize/scrwh;
fix[1] = fix[7] = (float)upbary/scrwh * yfix;
fix[3] = fix[5] = fix[1] + (float)barsize/2/scrwh * yfix;
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
pglVertexPointer(3, GL_FLOAT, 0, screenVerts);
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
fix[1] = fix[7] += (fix[3] - fix[7])*2;
screenVerts[1] = screenVerts[10] += (screenVerts[4] - screenVerts[1])*2;
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
pglVertexPointer(3, GL_FLOAT, 0, screenVerts);
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
// Downward bar
GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS);
pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]);
fix[0] = 0.0f;
fix[6] = xfix;
fix[2] = (float)downdistort / scrwf * -xfix;
fix[4] = fix[2] + fix[6];
screenVerts[1] = screenVerts[10] = 2.0f*downbary/scrwh - 1.0f;
screenVerts[4] = screenVerts[7] = screenVerts[1] + (float)barsize/scrwh;
fix[1] = fix[7] = (float)downbary/scrwh * yfix;
fix[3] = fix[5] = fix[1] + (float)barsize/2/scrwh * yfix;
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
pglVertexPointer(3, GL_FLOAT, 0, screenVerts);
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
fix[1] = fix[7] += (fix[3] - fix[7])*2;
screenVerts[1] = screenVerts[10] += (screenVerts[4] - screenVerts[1])*2;
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
pglVertexPointer(3, GL_FLOAT, 0, screenVerts);
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
} }
// Create a texture from the screen. // Create a texture from the screen.
+141 -148
View File
@@ -344,19 +344,16 @@ static int mobj_get(lua_State *L)
lua_pushangle(L, mo->slopepitch); lua_pushangle(L, mo->slopepitch);
break; break;
case mobj_rollsum: case mobj_rollsum:
{
angle_t pitchnroll = P_MobjPitchAndRoll(mo);
angle_t rollsum = mo->rollangle + pitchnroll;
if (mo->player)
{ {
rollsum += R_PlayerSliptideAngle(mo->player); angle_t pitchnroll = P_MobjPitchAndRoll(mo);
angle_t rollsum = mo->rollangle + pitchnroll;
if (mo->player)
{
rollsum += R_PlayerSliptideAngle(mo->player);
}
lua_pushangle(L, rollsum);
} }
lua_pushangle(L, rollsum);
break; break;
}
case mobj_spritexscale: case mobj_spritexscale:
lua_pushfixed(L, mo->spritexscale); lua_pushfixed(L, mo->spritexscale);
break; break;
@@ -431,30 +428,24 @@ static int mobj_set(lua_State *L)
case mobj_y: case mobj_y:
return NOSETPOS; return NOSETPOS;
case mobj_z: case mobj_z:
{ {
// z doesn't cross sector bounds so it's okay. // z doesn't cross sector bounds so it's okay.
mobj_t *ptmthing = tmthing; mobj_t *ptmthing = tmthing;
mo->z = luaL_checkfixed(L, 3); mo->z = luaL_checkfixed(L, 3);
P_CheckPosition(mo, mo->x, mo->y); P_CheckPosition(mo, mo->x, mo->y);
mo->floorz = tmfloorz; mo->floorz = tmfloorz;
mo->ceilingz = tmceilingz; mo->ceilingz = tmceilingz;
P_SetTarget(&tmthing, ptmthing); P_SetTarget(&tmthing, ptmthing);
}
break; break;
}
case mobj_snext: case mobj_snext:
return NOSETPOS; return NOSETPOS;
case mobj_sprev: case mobj_sprev:
return UNIMPLEMENTED; return UNIMPLEMENTED;
case mobj_angle: case mobj_angle:
mo->angle = luaL_checkangle(L, 3); mo->angle = luaL_checkangle(L, 3);
if (mo->player == &players[consoleplayer]) if (mo->player)
localangle[0] = mo->angle; P_ForceLocalAngle(mo->player, mo->angle);
else if (mo->player == &players[displayplayers[1]])
localangle[1] = mo->angle;
else if (mo->player == &players[displayplayers[2]])
localangle[2] = mo->angle;
else if (mo->player == &players[displayplayers[3]])
localangle[3] = mo->angle;
break; break;
case mobj_sprite: case mobj_sprite:
mo->sprite = luaL_checkinteger(L, 3); mo->sprite = luaL_checkinteger(L, 3);
@@ -474,29 +465,29 @@ static int mobj_set(lua_State *L)
case mobj_ceilingz: case mobj_ceilingz:
return NOSETPOS; return NOSETPOS;
case mobj_radius: case mobj_radius:
{ {
mobj_t *ptmthing = tmthing; mobj_t *ptmthing = tmthing;
mo->radius = luaL_checkfixed(L, 3); mo->radius = luaL_checkfixed(L, 3);
if (mo->radius < 0) if (mo->radius < 0)
mo->radius = 0; mo->radius = 0;
P_CheckPosition(mo, mo->x, mo->y); P_CheckPosition(mo, mo->x, mo->y);
mo->floorz = tmfloorz; mo->floorz = tmfloorz;
mo->ceilingz = tmceilingz; mo->ceilingz = tmceilingz;
P_SetTarget(&tmthing, ptmthing); P_SetTarget(&tmthing, ptmthing);
}
break; break;
}
case mobj_height: case mobj_height:
{ {
mobj_t *ptmthing = tmthing; mobj_t *ptmthing = tmthing;
mo->height = luaL_checkfixed(L, 3); mo->height = luaL_checkfixed(L, 3);
if (mo->height < 0) if (mo->height < 0)
mo->height = 0; mo->height = 0;
P_CheckPosition(mo, mo->x, mo->y); P_CheckPosition(mo, mo->x, mo->y);
mo->floorz = tmfloorz; mo->floorz = tmfloorz;
mo->ceilingz = tmceilingz; mo->ceilingz = tmceilingz;
P_SetTarget(&tmthing, ptmthing); P_SetTarget(&tmthing, ptmthing);
}
break; break;
}
case mobj_momx: case mobj_momx:
mo->momx = luaL_checkfixed(L, 3); mo->momx = luaL_checkfixed(L, 3);
break; break;
@@ -520,25 +511,25 @@ static int mobj_set(lua_State *L)
P_SetMobjState(mo, luaL_checkinteger(L, 3)); P_SetMobjState(mo, luaL_checkinteger(L, 3));
break; break;
case mobj_flags: // special handling for MF_NOBLOCKMAP and MF_NOSECTOR case mobj_flags: // special handling for MF_NOBLOCKMAP and MF_NOSECTOR
{
UINT32 flags = luaL_checkinteger(L, 3);
if ((flags & (MF_NOBLOCKMAP|MF_NOSECTOR)) != (mo->flags & (MF_NOBLOCKMAP|MF_NOSECTOR)))
{ {
P_UnsetThingPosition(mo); UINT32 flags = luaL_checkinteger(L, 3);
mo->flags = flags; if ((flags & (MF_NOBLOCKMAP|MF_NOSECTOR)) != (mo->flags & (MF_NOBLOCKMAP|MF_NOSECTOR)))
if (flags & MF_NOSECTOR && sector_list)
{ {
P_DelSeclist(sector_list); P_UnsetThingPosition(mo);
sector_list = NULL; mo->flags = flags;
if (flags & MF_NOSECTOR && sector_list)
{
P_DelSeclist(sector_list);
sector_list = NULL;
}
mo->snext = NULL, mo->sprev = NULL;
mo->bnext = NULL, mo->bprev = NULL;
P_SetThingPosition(mo);
} }
mo->snext = NULL, mo->sprev = NULL; else
mo->bnext = NULL, mo->bprev = NULL; mo->flags = flags;
P_SetThingPosition(mo);
} }
else
mo->flags = flags;
break; break;
}
case mobj_flags2: case mobj_flags2:
mo->flags2 = (UINT32)luaL_checkinteger(L, 3); mo->flags2 = (UINT32)luaL_checkinteger(L, 3);
break; break;
@@ -546,27 +537,29 @@ static int mobj_set(lua_State *L)
mo->eflags = (UINT32)luaL_checkinteger(L, 3); mo->eflags = (UINT32)luaL_checkinteger(L, 3);
break; break;
case mobj_skin: // set skin by name case mobj_skin: // set skin by name
{ {
INT32 i; INT32 i;
char skin[SKINNAMESIZE+1]; // all skin names are limited to this length char skin[SKINNAMESIZE+1]; // all skin names are limited to this length
strlcpy(skin, luaL_checkstring(L, 3), sizeof skin); strlcpy(skin, luaL_checkstring(L, 3), sizeof skin);
strlwr(skin); // all skin names are lowercase strlwr(skin); // all skin names are lowercase
for (i = 0; i < numskins; i++) for (i = 0; i < numskins; i++)
if (fastcmp(skins[i].name, skin))
{ {
mo->skin = &skins[i]; if (fastcmp(skins[i].name, skin))
return 0; {
mo->skin = &skins[i];
return 0;
}
} }
return luaL_error(L, "mobj.skin '%s' not found!", skin); return luaL_error(L, "mobj.skin '%s' not found!", skin);
} }
case mobj_color: case mobj_color:
{ {
UINT8 newcolor = (UINT8)luaL_checkinteger(L,3); UINT8 newcolor = (UINT8)luaL_checkinteger(L,3);
if (newcolor >= MAXTRANSLATIONS) if (newcolor >= MAXTRANSLATIONS)
return luaL_error(L, "mobj.color %d out of range (0 - %d).", newcolor, MAXTRANSLATIONS-1); return luaL_error(L, "mobj.color %d out of range (0 - %d).", newcolor, MAXTRANSLATIONS-1);
mo->color = newcolor; mo->color = newcolor;
}
break; break;
}
case mobj_bnext: case mobj_bnext:
return NOSETPOS; return NOSETPOS;
case mobj_bprev: case mobj_bprev:
@@ -590,15 +583,15 @@ static int mobj_set(lua_State *L)
} }
break; break;
case mobj_type: // yeah sure, we'll let you change the mobj's type. case mobj_type: // yeah sure, we'll let you change the mobj's type.
{ {
mobjtype_t newtype = luaL_checkinteger(L, 3); mobjtype_t newtype = luaL_checkinteger(L, 3);
if (newtype >= NUMMOBJTYPES) if (newtype >= NUMMOBJTYPES)
return luaL_error(L, "mobj.type %d out of range (0 - %d).", newtype, NUMMOBJTYPES-1); return luaL_error(L, "mobj.type %d out of range (0 - %d).", newtype, NUMMOBJTYPES-1);
mo->type = newtype; mo->type = newtype;
mo->info = &mobjinfo[newtype]; mo->info = &mobjinfo[newtype];
P_SetScale(mo, mo->scale); P_SetScale(mo, mo->scale);
}
break; break;
}
case mobj_info: case mobj_info:
return NOSET; return NOSET;
case mobj_health: case mobj_health:
@@ -666,23 +659,23 @@ static int mobj_set(lua_State *L)
case mobj_mobjnum: case mobj_mobjnum:
return UNIMPLEMENTED; return UNIMPLEMENTED;
case mobj_scale: case mobj_scale:
{ {
fixed_t scale = luaL_checkfixed(L, 3); fixed_t scale = luaL_checkfixed(L, 3);
if (scale < FRACUNIT/100) if (scale < FRACUNIT/100)
scale = FRACUNIT/100; scale = FRACUNIT/100;
mo->destscale = scale; mo->destscale = scale;
P_SetScale(mo, scale); P_SetScale(mo, scale);
mo->old_scale = scale; mo->old_scale = scale;
}
break; break;
}
case mobj_destscale: case mobj_destscale:
{ {
fixed_t scale = luaL_checkfixed(L, 3); fixed_t scale = luaL_checkfixed(L, 3);
if (scale < FRACUNIT/100) if (scale < FRACUNIT/100)
scale = FRACUNIT/100; scale = FRACUNIT/100;
mo->destscale = scale; mo->destscale = scale;
}
break; break;
}
case mobj_scalespeed: case mobj_scalespeed:
mo->scalespeed = luaL_checkfixed(L, 3); mo->scalespeed = luaL_checkfixed(L, 3);
break; break;
@@ -747,58 +740,58 @@ static int mobj_set(lua_State *L)
mo->lightlevel = (INT16)luaL_checkinteger(L, 3); mo->lightlevel = (INT16)luaL_checkinteger(L, 3);
break; break;
case mobj_localskin: case mobj_localskin:
{
if (mo->player)
{ {
SetLocalPlayerSkin(mo->player - players, luaL_optstring(L, 3, "none"), NULL); if (mo->player)
}
else
{
INT32 i;
char skin[SKINNAMESIZE+1]; // all skin names are limited to this length
strlcpy(skin, luaL_optstring(L, 3, "none"), sizeof skin);
strlwr(skin); // all skin names are lowercase
if (!fasticmp(skin, "none"))
{ {
// Try localskins SetLocalPlayerSkin(mo->player - players, luaL_optstring(L, 3, "none"), NULL);
for (i = 0; i < numlocalskins; i++)
{
if (fasticmp(localskins[i].name, skin))
{
mo->localskin = &localskins[i];
mo->skinlocal = true;
return 0;
}
}
// Try other skins
for (i = 0; i < numskins; i++)
{
if (fasticmp(skins[i].name, skin))
{
mo->localskin = &skins[i];
mo->skinlocal = false;
return 0;
}
}
} }
else else
{ {
mo->localskin = NULL; INT32 i;
mo->skinlocal = false; char skin[SKINNAMESIZE+1]; // all skin names are limited to this length
strlcpy(skin, luaL_optstring(L, 3, "none"), sizeof skin);
strlwr(skin); // all skin names are lowercase
if (!fasticmp(skin, "none"))
{
// Try localskins
for (i = 0; i < numlocalskins; i++)
{
if (fasticmp(localskins[i].name, skin))
{
mo->localskin = &localskins[i];
mo->skinlocal = true;
return 0;
}
}
// Try other skins
for (i = 0; i < numskins; i++)
{
if (fasticmp(skins[i].name, skin))
{
mo->localskin = &skins[i];
mo->skinlocal = false;
return 0;
}
}
}
else
{
mo->localskin = NULL;
mo->skinlocal = false;
}
} }
} }
break; break;
}
case mobj_blendmode: case mobj_blendmode:
{ {
INT32 blendmode = (INT32)luaL_checkinteger(L, 3); INT32 blendmode = (INT32)luaL_checkinteger(L, 3);
if (blendmode < 0 || blendmode > AST_OVERLAY) if (blendmode < 0 || blendmode > AST_OVERLAY)
return luaL_error(L, "mobj.blendmode %d out of range (0 - %d).", blendmode, AST_OVERLAY); return luaL_error(L, "mobj.blendmode %d out of range (0 - %d).", blendmode, AST_OVERLAY);
mo->blendmode = blendmode; mo->blendmode = blendmode;
}
break; break;
}
case mobj_mirrored: case mobj_mirrored:
mo->mirrored = luaL_checkboolean(L, 3); mo->mirrored = luaL_checkboolean(L, 3);
break; break;
@@ -950,13 +943,13 @@ static int mapthing_set(lua_State *L)
mt->z = (INT16)luaL_checkinteger(L, 3); mt->z = (INT16)luaL_checkinteger(L, 3);
break; break;
case mapthing_extrainfo: case mapthing_extrainfo:
{ {
INT32 extrainfo = luaL_checkinteger(L, 3); INT32 extrainfo = luaL_checkinteger(L, 3);
if (extrainfo & ~15) if (extrainfo & ~15)
return luaL_error(L, "mapthing_t extrainfo set %d out of range (%d - %d)", extrainfo, 0, 15); return luaL_error(L, "mapthing_t extrainfo set %d out of range (%d - %d)", extrainfo, 0, 15);
mt->extrainfo = (UINT8)extrainfo; mt->extrainfo = (UINT8)extrainfo;
}
break; break;
}
case mapthing_mobj: case mapthing_mobj:
mt->mobj = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); mt->mobj = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ));
break; break;
+45 -45
View File
@@ -298,12 +298,12 @@ static int player_get(lua_State *L)
lua_pushstring(L, player_names[plr-players]); lua_pushstring(L, player_names[plr-players]);
break; break;
case player_mo: case player_mo:
{ {
if (plr->spectator) if (plr->spectator)
lua_pushnil(L); lua_pushnil(L);
else else
LUA_PushUserdata(L, plr->mo, META_MOBJ); LUA_PushUserdata(L, plr->mo, META_MOBJ);
} }
break; break;
case player_cmd: case player_cmd:
LUA_PushUserdata(L, &plr->cmd, META_TICCMD); LUA_PushUserdata(L, &plr->cmd, META_TICCMD);
@@ -668,11 +668,11 @@ static int player_set(lua_State *L)
return 0; // In vanilla those are not handled and are added into player fields table, but they aren't accessible anyway so we can just ignore them return 0; // In vanilla those are not handled and are added into player fields table, but they aren't accessible anyway so we can just ignore them
break; break;
case player_mo: case player_mo:
{ {
mobj_t *newmo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); mobj_t *newmo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ));
plr->mo->player = NULL; // remove player pointer from old mobj plr->mo->player = NULL; // remove player pointer from old mobj
(newmo->player = plr)->mo = newmo; // set player pointer for new mobj, and set new mobj as the player's mobj (newmo->player = plr)->mo = newmo; // set player pointer for new mobj, and set new mobj as the player's mobj
} }
break; break;
case player_cmd: case player_cmd:
return NOSET; return NOSET;
@@ -692,17 +692,17 @@ static int player_set(lua_State *L)
case player_bob: case player_bob:
plr->bob = luaL_checkfixed(L, 3);*/ plr->bob = luaL_checkfixed(L, 3);*/
break; break;
case player_aiming: { case player_aiming:
plr->aiming = luaL_checkangle(L, 3); {
if (plr == &players[consoleplayer]) plr->aiming = luaL_checkangle(L, 3);
localaiming[0] = plr->aiming; for (UINT8 i = 0; i <= splitscreen; i++)
else if (plr == &players[displayplayers[1]]) {
localaiming[1] = plr->aiming; if (plr == &players[displayplayers[i]])
else if (plr == &players[displayplayers[2]]) {
localaiming[2] = plr->aiming; localaiming[i] = plr->aiming;
else if (plr == &players[displayplayers[3]]) }
localaiming[3] = plr->aiming; }
} }
break; break;
case player_health: case player_health:
plr->health = (INT32)luaL_checkinteger(L, 3); plr->health = (INT32)luaL_checkinteger(L, 3);
@@ -732,12 +732,12 @@ static int player_set(lua_State *L)
plr->flashpal = (UINT16)luaL_checkinteger(L, 3); plr->flashpal = (UINT16)luaL_checkinteger(L, 3);
break; break;
case player_skincolor: case player_skincolor:
{ {
UINT8 newcolor = (UINT8)luaL_checkinteger(L,3); UINT8 newcolor = (UINT8)luaL_checkinteger(L,3);
if (newcolor >= MAXSKINCOLORS) if (newcolor >= MAXSKINCOLORS)
return luaL_error(L, "player.skincolor %d out of range (0 - %d).", newcolor, MAXSKINCOLORS-1); return luaL_error(L, "player.skincolor %d out of range (0 - %d).", newcolor, MAXSKINCOLORS-1);
plr->skincolor = newcolor; plr->skincolor = newcolor;
} }
break; break;
case player_score: case player_score:
plr->score = (UINT32)luaL_checkinteger(L, 3); plr->score = (UINT32)luaL_checkinteger(L, 3);
@@ -907,12 +907,12 @@ static int player_set(lua_State *L)
plr->bonustime = luaL_checkboolean(L, 3); plr->bonustime = luaL_checkboolean(L, 3);
break; break;
case player_capsule: case player_capsule:
{ {
mobj_t *mo = NULL; mobj_t *mo = NULL;
if (!lua_isnil(L, 3)) if (!lua_isnil(L, 3))
mo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); mo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ));
P_SetTarget(&plr->capsule, mo); P_SetTarget(&plr->capsule, mo);
} }
break; break;
case player_mare: case player_mare:
plr->mare = (UINT8)luaL_checkinteger(L, 3); plr->mare = (UINT8)luaL_checkinteger(L, 3);
@@ -963,19 +963,19 @@ static int player_set(lua_State *L)
plr->onconveyor = (INT32)luaL_checkinteger(L, 3); plr->onconveyor = (INT32)luaL_checkinteger(L, 3);
break; break;
case player_awayviewmobj: case player_awayviewmobj:
{ {
mobj_t *mo = NULL; mobj_t *mo = NULL;
if (!lua_isnil(L, 3)) if (!lua_isnil(L, 3))
mo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); mo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ));
P_SetTarget(&plr->awayviewmobj, mo); P_SetTarget(&plr->awayviewmobj, mo);
} }
break; break;
case player_awayviewtics: case player_awayviewtics:
{ {
plr->awayviewtics = (INT32)luaL_checkinteger(L, 3); plr->awayviewtics = (INT32)luaL_checkinteger(L, 3);
if (plr->awayviewtics && !plr->awayviewmobj) // awayviewtics must ALWAYS have an awayviewmobj set!! if (plr->awayviewtics && !plr->awayviewmobj) // awayviewtics must ALWAYS have an awayviewmobj set!!
P_SetTarget(&plr->awayviewmobj, plr->mo); // but since the script might set awayviewmobj immediately AFTER setting awayviewtics, use player mobj as filler for now. P_SetTarget(&plr->awayviewmobj, plr->mo); // but since the script might set awayviewmobj immediately AFTER setting awayviewtics, use player mobj as filler for now.
} }
break; break;
case player_awayviewaiming: case player_awayviewaiming:
plr->awayviewaiming = luaL_checkangle(L, 3); plr->awayviewaiming = luaL_checkangle(L, 3);
+10 -10
View File
@@ -66,22 +66,22 @@ static void P_UpdateSlopeLightOffset(pslope_t *slope)
nY = FixedDiv(nY, nLen); nY = FixedDiv(nY, nLen);
/* /*
* if (slope is ceiling) if (slope is ceiling)
* { {
* // There is no good way to calculate this condition here. // There is no good way to calculate this condition here.
* // We reverse it in R_FindPlane now. // We reverse it in R_FindPlane now.
* nX = -nX; nX = -nX;
* nY = -nY; nY = -nY;
* } }
*/ */
light = FixedMul(nX, FINECOSINE(maplighting.angle >> ANGLETOFINESHIFT)) light = FixedMul(nX, FINECOSINE(maplighting.angle >> ANGLETOFINESHIFT))
+ FixedMul(nY, FINESINE(maplighting.angle >> ANGLETOFINESHIFT)); + FixedMul(nY, FINESINE(maplighting.angle >> ANGLETOFINESHIFT));
light = (light + FRACUNIT) / 2; light = (light + FRACUNIT) / 2;
} }
else else
{ {
light = FixedDiv(R_PointToAngle2(0, 0, abs(slope->d.x), abs(slope->d.y)), ANGLE_90); light = FixedDiv(R_PointToAngle2(0, 0, abs(slope->normal.y), abs(slope->normal.x)), ANGLE_90);
} }
const int delta = abs(slope->zdelta)*3/2; // *3/2, to make 60 degree slopes match walls. const int delta = abs(slope->zdelta)*3/2; // *3/2, to make 60 degree slopes match walls.
+14 -14
View File
@@ -350,8 +350,8 @@ void R_ClearPlanes(void)
angle = (viewangle-ANGLE_90)>>ANGLETOFINESHIFT; angle = (viewangle-ANGLE_90)>>ANGLETOFINESHIFT;
// scale will be unit scale at SCREENWIDTH/2 distance // scale will be unit scale at SCREENWIDTH/2 distance
basexscale = FixedDiv (FINECOSINE(angle), centerxfrac); basexscale = FixedDiv(FINECOSINE(angle), centerxfrac);
baseyscale = -FixedDiv (FINESINE(angle), centerxfrac); baseyscale = -FixedDiv(FINESINE(angle), centerxfrac);
} }
static visplane_t *new_visplane(unsigned hash) static visplane_t *new_visplane(unsigned hash)
@@ -440,20 +440,20 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
} }
} }
if (slope != NULL && P_ApplyLightOffset(lightlevel >> LIGHTSEGSHIFT, lighting_sector))
{
if (reverseLight && maplighting.directional == true)
{
lightlevel -= slope->lightOffset * 8;
}
else
{
lightlevel += slope->lightOffset * 8;
}
}
if (!pfloor) if (!pfloor)
{ {
if (slope != NULL && P_ApplyLightOffset(lightlevel >> LIGHTSEGSHIFT, lighting_sector))
{
if (reverseLight)
{
lightlevel -= slope->lightOffset * 8;
}
else
{
lightlevel += slope->lightOffset * 8;
}
}
hash = visplane_hash(picnum, lightlevel, height >> FRACBITS); hash = visplane_hash(picnum, lightlevel, height >> FRACBITS);
for (check = visplanes[hash]; check; check = check->next) for (check = visplanes[hash]; check; check = check->next)
+21 -18
View File
@@ -1839,8 +1839,11 @@ void V_DrawHorizontallyScaledFullScreenPatch(patch_t *patch)
void V_DrawVhsEffect(boolean rewind) void V_DrawVhsEffect(boolean rewind)
{ {
fixed_t uby, dby; fixed_t uby, dby;
// upbary is the bar going from top to bottom for some reason static fixed_t upbary_normal = 100*FRACUNIT, downbary_normal = 150*FRACUNIT;
static fixed_t upbary = 100*FRACUNIT, downbary = 150*FRACUNIT; static fixed_t upbary_rewind = 100*FRACUNIT, downbary_rewind = 150*FRACUNIT;
fixed_t *upbary = rewind ? &upbary_rewind : &upbary_normal;
fixed_t *downbary = rewind ? &downbary_rewind : &downbary_normal;
UINT8 barsize, updistort, downdistort; UINT8 barsize, updistort, downdistort;
@@ -1864,25 +1867,25 @@ void V_DrawVhsEffect(boolean rewind)
if (rewind) if (rewind)
V_DrawVhsEffect(false); // experimentation V_DrawVhsEffect(false); // experimentation
upbary -= renderdeltatics * (fixed_t)(vid.udup * (rewind ? 3 : 1.8f)); *upbary -= renderdeltatics * (fixed_t)(vid.udup * (rewind ? 3 : 1.8f));
downbary += renderdeltatics * (vid.udup * (rewind ? 2 : 1)); *downbary += renderdeltatics * (vid.udup * (rewind ? 2 : 1));
if (upbary < -barsize*FRACUNIT) if (*upbary < -barsize*FRACUNIT)
upbary = vid.height << FRACBITS; *upbary = vid.height << FRACBITS;
if (upbary > vid.height << FRACBITS) if (*upbary > vid.height << FRACBITS)
upbary = -barsize*FRACUNIT; *upbary = -barsize*FRACUNIT;
if (downbary > vid.height << FRACBITS) if (*downbary > vid.height << FRACBITS)
downbary = -barsize*FRACUNIT; *downbary = -barsize*FRACUNIT;
if (downbary < -barsize*FRACUNIT) if (*downbary < -barsize*FRACUNIT)
downbary = vid.height << FRACBITS; *downbary = vid.height << FRACBITS;
uby = upbary >> FRACBITS; uby = *upbary >> FRACBITS;
dby = downbary >> FRACBITS; dby = *downbary >> FRACBITS;
#ifdef HWRENDER #ifdef HWRENDER
if (rendermode == render_opengl) if (rendermode == render_opengl)
{ {
HWR_RenderVhsEffect(uby, dby, updistort, downdistort, barsize); HWR_RenderVhsEffect(uby, dby, updistort, downdistort, barsize, rewind);
return; return;
} }
#endif #endif
@@ -3619,7 +3622,7 @@ void V_DoPostProcessor(INT32 view, INT32 param)
for (y = yoffset; y < yoffset+viewheight; y++) for (y = yoffset; y < yoffset+viewheight; y++)
{ {
sine = (FINESINE(disStart)*5)>>FRACBITS; sine = (FINESINE(disStart) * 5) >> FRACBITS;
newpix = abs(sine); newpix = abs(sine);
if (sine < 0) if (sine < 0)
@@ -3659,8 +3662,8 @@ void V_DoPostProcessor(INT32 view, INT32 param)
tmpscr[y*vid.width + x] = srcscr[y*vid.width+newpix]; // *(transme + (srcscr[y*vid.width+x]<<8) + srcscr[y*vid.width+newpix]); tmpscr[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 += 22; // the offset into the displacement map, increment each game loop
disStart &= FINEMASK; //clip it to FINEMASK disStart &= FINEMASK; // clip it to FINEMASK
} }
UINT8 *tmp = tmpscr; UINT8 *tmp = tmpscr;