port directional + sprite lightning

doesent do all too much without soc
but was bored and could make smth cool out of it

needs a global toggle since it does some stuff by default
This commit is contained in:
Alug committed 2024-09-11 23:17:47 +02:00
1 parent 65793db889
commit 3bb18a1bc7
26 files changed
+448 -79

No files matched your search

+22
View File
@@ -1012,6 +1012,27 @@ static void readlevelheader(MYFILE *f, INT32 num, INT32 wadnum)
}*/
else if (fastcmp(word, "MOBJSCALE"))
mapheaderinfo[num-1]->mobj_scale = get_number(word2);
else if (fastcmp(word, "LIGHTCONTRAST"))
{
mapheaderinfo[num-1]->light_contrast = (UINT8)i;
}
else if (fastcmp(word, "SPRITEBACKLIGHT"))
{
mapheaderinfo[num]->sprite_backlight = (SINT8)i;
}
else if (fastcmp(word, "LIGHTANGLE"))
{
if (fastcmp(word2, "EVEN"))
{
mapheaderinfo[num-1]->use_light_angle = false;
mapheaderinfo[num-1]->light_angle = 0;
}
else
{
mapheaderinfo[num-1]->use_light_angle = true;
mapheaderinfo[num-1]->light_angle = FixedAngle(FloatToFixed(atof(word2)));
}
}
// Individual triggers for level flags, for ease of use (and 2.0 compatibility)
else if (fastcmp(word, "SCRIPTISFILE"))
@@ -7862,6 +7883,7 @@ struct {
{"FF_FULLBRIGHT",FF_FULLBRIGHT},
{"FF_TRANSMASK",FF_TRANSMASK},
{"FF_TRANSSHIFT",FF_TRANSSHIFT},
{"FF_ABSOLUTELIGHTLEVEL",FF_ABSOLUTELIGHTLEVEL},
// new preshifted translucency (used in source)
{"FF_TRANS10",FF_TRANS10},
{"FF_TRANS20",FF_TRANS20},
+13
View File
@@ -260,6 +260,11 @@ typedef struct
//boolean automap; ///< Displays a level's white map outline in modified games
fixed_t mobj_scale; ///< Replacement for TOL_ERZ3
UINT8 light_contrast; ///< Range of wall lighting. 0 is no lighting.
SINT8 sprite_backlight; ///< Subtract from wall lighting for sprites only.
boolean use_light_angle; ///< When false, wall lighting is evenly distributed. When true, wall lighting is directional.
angle_t light_angle; ///< Angle of directional wall lighting.
// Music stuff.
UINT32 musinterfadeout; ///< Fade out level music on intermission screen in milliseconds
char musintername[7]; ///< Intermission screen music.
@@ -446,6 +451,14 @@ extern tic_t racecountdown, exitcountdown;
extern fixed_t gravity;
extern fixed_t mapobjectscale;
extern struct maplighting
{
UINT8 contrast;
SINT8 backlight;
boolean directional;
angle_t angle;
} maplighting;
//for CTF balancing
extern INT16 autobalance;
extern INT16 teamscramble;
+2
View File
@@ -244,6 +244,8 @@ tic_t racecountdown, exitcountdown; // for racing
fixed_t gravity;
fixed_t mapobjectscale;
struct maplighting maplighting;
INT16 autobalance; //for CTF team balance
INT16 teamscramble; //for CTF team scramble
INT16 scrambleplayers[MAXPLAYERS]; //for CTF team scramble
+8 -2
View File
@@ -180,6 +180,10 @@ static int comparePolygons(const void *p1, const void *p2)
diff = poly1->surf.LightInfo.fade_start - poly2->surf.LightInfo.fade_start;
if (diff != 0) return diff;
diff = poly1->surf.LightInfo.fade_end - poly2->surf.LightInfo.fade_end;
diff = poly1->surf.LightInfo.directional - poly2->surf.LightInfo.directional;
if (diff != 0) return diff;
return diff;
}
@@ -228,7 +232,7 @@ void HWR_RenderBatches(void)
int currentShader;
int nextShader = 0;
GLMipmap_t *currentTexture;
GLMipmap_t *currentTexture = NULL;
GLMipmap_t *nextTexture = NULL;
FBITFIELD currentPolyFlags = 0;
FBITFIELD nextPolyFlags = 0;
@@ -243,6 +247,7 @@ void HWR_RenderBatches(void)
nextSurfaceInfo.LightInfo.fade_end = 0;
nextSurfaceInfo.LightInfo.fade_start = 0;
nextSurfaceInfo.LightInfo.light_level = 0;
nextSurfaceInfo.LightInfo.directional = false;
currently_batching = false;// no longer collecting batches
if (!polygonArraySize)
@@ -392,7 +397,8 @@ void HWR_RenderBatches(void)
currentSurfaceInfo.FadeColor.rgba != nextSurfaceInfo.FadeColor.rgba ||
currentSurfaceInfo.LightInfo.light_level != nextSurfaceInfo.LightInfo.light_level ||
currentSurfaceInfo.LightInfo.fade_start != nextSurfaceInfo.LightInfo.fade_start ||
currentSurfaceInfo.LightInfo.fade_end != nextSurfaceInfo.LightInfo.fade_end)
currentSurfaceInfo.LightInfo.fade_end != nextSurfaceInfo.LightInfo.fade_end ||
currentSurfaceInfo.LightInfo.directional != nextSurfaceInfo.LightInfo.directional)
{
changeState = true;
changeSurfaceInfo = true;
+6
View File
@@ -273,6 +273,7 @@ struct FLightInfo
FUINT light_level;
FUINT fade_start;
FUINT fade_end;
boolean directional;
};
typedef struct FLightInfo FLightInfo;
@@ -314,6 +315,11 @@ typedef enum hwdsetspecialstate hwdspecialstate_t;
enum hwdshaderinfo
{
HWD_SHADERINFO_LEVELTIME = 1,
HWD_SHADERINFO_LIGHT_X,
HWD_SHADERINFO_LIGHT_Y,
HWD_SHADERINFO_LIGHT_Z,
HWD_SHADERINFO_LIGHT_CONTRAST,
HWD_SHADERINFO_LIGHT_BACKLIGHT,
};
typedef enum hwdshaderinfo hwdshaderinfo_t;
+2
View File
@@ -44,6 +44,8 @@ typedef struct gr_vissprite_s
INT32 dispoffset; // copy of info->dispoffset, affects ordering but not drawing
} gr_vissprite_t;
void HWR_ObjectLightLevelPost(gr_vissprite_t *spr, const sector_t *sector, INT32 *lightlevel, boolean model);
// --------
// hw_bsp.c
// --------
+78 -33
View File
@@ -512,7 +512,48 @@ boolean HWR_PalRenderFlashpal(void)
return (HWR_ShouldUsePaletteRendering() && cv_grflashpal.value);
}
void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *colormap)
void HWR_ObjectLightLevelPost(gr_vissprite_t *spr, const sector_t *sector, INT32 *lightlevel, boolean model)
{
const boolean papersprite = (spr->mobj->frame & FF_PAPERSPRITE);
*lightlevel += R_ThingLightLevel(spr->mobj);
if (maplighting.directional == true && P_SectorUsesDirectionalLighting(sector))
{
if (model == false) // this is implemented by shader
{
fixed_t extralight = R_GetSpriteDirectionalLighting(
papersprite
? R_PointToAngle(spr->mobj->x, spr->mobj->y) + (spr->flip ? -ANGLE_90 : ANGLE_90)
: R_PointToAngle(spr->mobj->x, spr->mobj->y) // fixme
);
// Less change in contrast in dark sectors
extralight = FixedMul(extralight, min(max(0, *lightlevel), 255) * FRACUNIT / 255);
if (papersprite)
{
// Papersprite contrast should match walls
*lightlevel += FixedFloor(extralight + (FRACUNIT / 2)) / FRACUNIT;
}
else
{
// simple OGL approximation
fixed_t tr = R_PointToDist(spr->mobj->x, spr->mobj->y);
fixed_t xscale = FixedDiv((vid.width / 2) << FRACBITS, tr);
// Less change in contrast at further distances, to counteract DOOM diminished light
fixed_t n = FixedDiv(FixedMul(xscale, LIGHTRESOLUTIONFIX), ((MAXLIGHTSCALE-1) << LIGHTSCALESHIFT));
extralight = FixedMul(extralight, min(n, FRACUNIT));
// Contrast is stronger for normal sprites, stronger than wall lighting is at the same distance
*lightlevel += FixedFloor((extralight * 2) + (FRACUNIT / 2)) / FRACUNIT;
}
}
}
}
void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *colormap, const boolean directional)
{
RGBA_t poly_color, tint_color, fade_color;
@@ -572,6 +613,7 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col
Surface->LightInfo.light_level = light_level;
Surface->LightInfo.fade_start = (colormap != NULL) ? colormap->fadestart : 0;
Surface->LightInfo.fade_end = (colormap != NULL) ? colormap->fadeend : 31;
Surface->LightInfo.directional = (maplighting.directional == true && directional == true);
if (HWR_ShouldUsePaletteRendering())
Surface->LightTableId = HWR_GetLightTableID(colormap);
@@ -608,43 +650,31 @@ static FUINT HWR_CalcWallLight(FUINT lightnum, seg_t *seg)
{
INT16 finallight = lightnum;
if (seg != NULL && cv_grfakecontrast.value != 0)
if (seg != NULL && P_ApplyLightOffsetFine(lightnum, seg->frontsector) && cv_grfakecontrast.value != 0)
{
fixed_t extralight = 0;
if (cv_grfakecontrast.value == 2) // Smooth setting
extralight += seg->hwLightOffset;
finallight += seg->hwLightOffset;
else
extralight += seg->lightOffset * 8;
finallight += seg->lightOffset * 8;
if (extralight != 0)
{
finallight += extralight;
finallight = CLAMP(finallight, 0 , 255);
}
finallight = CLAMP(finallight, 0 , 255);
}
return (FUINT)finallight;
}
static FUINT HWR_CalcSlopeLight(FUINT lightnum, pslope_t *slope)
static FUINT HWR_CalcSlopeLight(FUINT lightnum, pslope_t *slope, const sector_t *sector, const boolean fof)
{
INT16 finallight = lightnum;
if (slope != NULL && cv_grfakecontrast.value != 0 && cv_grslopecontrast.value != 0)
if (slope != NULL && P_ApplyLightOffsetFine(lightnum, sector) && cv_grfakecontrast.value != 0 && cv_grslopecontrast.value != 0)
{
fixed_t extralight = 0;
if (cv_grfakecontrast.value == 2) // Smooth setting
extralight += slope->hwLightOffset;
finallight += (fof ? -slope->hwLightOffset : slope->hwLightOffset);
else
extralight += slope->lightOffset * 8;
finallight += (fof ? -slope->lightOffset * 8 : slope->lightOffset * 8);
if (extralight != 0)
{
finallight += extralight;
finallight = CLAMP(finallight, 0 , 255);
}
finallight = CLAMP(finallight, 0 , 255);
}
return (FUINT)finallight;
@@ -829,9 +859,9 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc
SETUP3DVERT(v3d, pv->x, pv->y);
if (slope)
lightlevel = HWR_CalcSlopeLight(lightlevel, slope);
lightlevel = HWR_CalcSlopeLight(lightlevel, slope, gr_frontsector, (FOFsector != NULL));
HWR_Lighting(&Surf, lightlevel, planecolormap);
HWR_Lighting(&Surf, lightlevel, planecolormap, P_SectorUsesDirectionalLighting(gr_frontsector));
if (PolyFlags & (PF_Translucent|PF_Fog))
{
@@ -1043,7 +1073,7 @@ void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend
{
INT32 shader = SHADER_NONE;
HWR_Lighting(pSurf, lightlevel, wallcolormap);
HWR_Lighting(pSurf, lightlevel, wallcolormap, P_SectorUsesDirectionalLighting(gr_frontsector));
if (HWR_UseShader())
{
@@ -2809,7 +2839,7 @@ void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, fixed_t
v3d->z = FIXED_TO_FLOAT(polysector->vertices[i]->y);
}
HWR_Lighting(&Surf, lightlevel, planecolormap);
HWR_Lighting(&Surf, lightlevel, planecolormap, P_SectorUsesDirectionalLighting((FOFsector != NULL) ? FOFsector : gr_frontsector));
if (blendmode & PF_Translucent)
{
@@ -3676,7 +3706,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
GLPatch_t *gpatch;
FSurfaceInfo Surf;
extracolormap_t *colormap;
FUINT lightlevel;
INT32 lightlevel;
FBITFIELD blend = 0;
UINT8 alpha;
@@ -3818,6 +3848,8 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
if (spr->mobj->frame & FF_FULLBRIGHT)
lightlevel = 255;
HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false);
for (i = 1; i < sector->numlights; i++)
{
fixed_t h = P_GetLightZAt(&sector->lightlist[i], spr->mobj->x, spr->mobj->y);
@@ -3826,6 +3858,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
if (!(spr->mobj->frame & FF_FULLBRIGHT))
lightlevel = min(*list[i-1].lightlevel, 255);
HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false);
colormap = list[i-1].extra_colormap;
break;
}
@@ -3840,6 +3873,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
{
if (!(spr->mobj->frame & FF_FULLBRIGHT))
lightlevel = min(*list[i].lightlevel, 255);
HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false);
colormap = list[i].extra_colormap;
}
@@ -3902,7 +3936,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
wallVerts[1].z = baseWallVerts[2].z + (baseWallVerts[2].z - baseWallVerts[1].z) * heightmult;
}
HWR_Lighting(&Surf, lightlevel, colormap);
HWR_Lighting(&Surf, lightlevel, colormap, P_SectorUsesDirectionalLighting(sector) && !(spr->mobj->frame & FF_FULLBRIGHT));
Surf.PolyColor.s.alpha = alpha;
@@ -3929,7 +3963,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
wallVerts[0].y = bot;
wallVerts[1].y = endbot;
HWR_Lighting(&Surf, lightlevel, colormap);
HWR_Lighting(&Surf, lightlevel, colormap, P_SectorUsesDirectionalLighting(sector));
Surf.PolyColor.s.alpha = alpha;
@@ -4046,13 +4080,15 @@ static void HWR_DrawSprite(gr_vissprite_t *spr)
// colormap test
sector_t *sector = spr->mobj->subsector->sector;
UINT8 lightlevel = 255;
INT32 lightlevel = 255;
extracolormap_t *colormap = sector->extra_colormap;
if (!(spr->mobj->frame & FF_FULLBRIGHT))
lightlevel = min(sector->lightlevel, 255);
HWR_Lighting(&Surf, lightlevel, colormap);
HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false);
HWR_Lighting(&Surf, lightlevel, colormap, P_SectorUsesDirectionalLighting(sector) && !(spr->mobj->frame & FF_FULLBRIGHT));
{
FBITFIELD blend = 0;
@@ -4163,7 +4199,7 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr)
colormap = sector->extra_colormap;
}
HWR_Lighting(&Surf, lightlevel, colormap);
HWR_Lighting(&Surf, lightlevel, colormap, P_SectorUsesDirectionalLighting(sector));
if (spr->mobj->frame & FF_TRANSMASK)
blend = HWR_TranstableToAlpha((spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf);
@@ -5680,7 +5716,16 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
HWD.pfnClearBuffer(true, false, false, &ClearColor);
if (cv_grshaders.value)
{
HWD.pfnSetShaderInfo(HWD_SHADERINFO_LEVELTIME, (INT32)leveltime); // The water surface shader needs the leveltime.
const angle_t light_angle = maplighting.angle - viewangle + ANGLE_90; // I fucking hate OGL's coordinate system
HWD.pfnSetShaderInfo(HWD_SHADERINFO_LIGHT_X, FINECOSINE(light_angle >> ANGLETOFINESHIFT));
HWD.pfnSetShaderInfo(HWD_SHADERINFO_LIGHT_Y, 0);
HWD.pfnSetShaderInfo(HWD_SHADERINFO_LIGHT_Z, -FINESINE(light_angle >> ANGLETOFINESHIFT));
HWD.pfnSetShaderInfo(HWD_SHADERINFO_LIGHT_CONTRAST, maplighting.contrast);
HWD.pfnSetShaderInfo(HWD_SHADERINFO_LIGHT_BACKLIGHT, maplighting.backlight);
}
if (viewnumber > 3)
return;
@@ -5860,7 +5905,7 @@ void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend,
INT32 shader = SHADER_NONE;
// Lighting is done here instead so that fog isn't drawn incorrectly on transparent walls after sorting
HWR_Lighting(pSurf, lightlevel, wallcolormap);
HWR_Lighting(pSurf, lightlevel, wallcolormap, P_SectorUsesDirectionalLighting(gr_frontsector));
pSurf->PolyColor.s.alpha = alpha; // put the alpha back after lighting
+1 -1
View File
@@ -97,7 +97,7 @@ void HWR_TogglePaletteRendering(void);
// into files like hw_bsp.c, hw_sprites.c...
// hw_main.c: Lighting and fog
void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *colormap);
void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *colormap, const boolean directional);
UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap); // Let's see if this can work
FBITFIELD HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf);
+5 -2
View File
@@ -31,6 +31,7 @@
#include "../r_bsp.h"
#include "../r_fps.h"
#include "../r_main.h"
#include "../p_setup.h"
#include "../m_misc.h"
#include "../w_wad.h"
#include "../z_zone.h"
@@ -1119,7 +1120,7 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
{
sector_t *sector = spr->mobj->subsector->sector;
extracolormap_t *colormap = sector->extra_colormap;
UINT8 lightlevel = 255;
INT32 lightlevel = 255;
if (sector->numlights)
{
@@ -1142,7 +1143,9 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
colormap = sector->extra_colormap;
}
HWR_Lighting(&Surf, lightlevel, colormap);
HWR_ObjectLightLevelPost(spr, sector, &lightlevel, true);
HWR_Lighting(&Surf, lightlevel, colormap, P_SectorUsesDirectionalLighting(sector) && !(spr->mobj->frame & FF_FULLBRIGHT));
}
else
{
+1 -1
View File
@@ -39,7 +39,7 @@ static struct {
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER},
// Model shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER},
{GLSL_MODEL_LIGHTING_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER},
// Water shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_WATER_FRAGMENT_SHADER},
+25
View File
@@ -31,6 +31,31 @@
"gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;\n" \
"}\0"
// reinterpretation of sprite lighting for models
// it's a combination of how it works for normal sprites & papersprites
#define GLSL_MODEL_LIGHTING_VERTEX_SHADER \
"uniform float lighting;\n" \
"uniform vec3 light_dir;\n" \
"uniform float light_contrast;\n" \
"uniform float light_backlight;\n" \
"void main()\n" \
"{\n" \
"gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;\n" \
"float light = lighting;\n" \
"if (length(light_dir) > 0.000001) {\n" \
"mat4 m4 = gl_ProjectionMatrix * gl_ModelViewMatrix;\n" \
"mat3 m3 = mat3( m4[0].xyz, m4[1].xyz, m4[2].xyz );\n" \
"float extralight = -dot(normalize(gl_Normal * m3), normalize(light_dir));\n" \
"extralight *= light_contrast - light_backlight;\n" \
"extralight *= lighting / 255.0;\n" \
"light += extralight * 2.5;\n" \
"}\n" \
"light = clamp(light / 255.0, 0.0, 1.0);\n" \
"gl_FrontColor = vec4(light, light, light, 1.0);\n" \
"gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;\n" \
"gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;\n" \
"}\0"
// ==================
// Fragment shaders
// ==================
+47
View File
@@ -665,6 +665,9 @@ typedef enum
gluniform_lighting,
gluniform_fade_start,
gluniform_fade_end,
gluniform_light_dir,
gluniform_light_contrast,
gluniform_light_backlight,
// palette rendering
gluniform_palette_tex, // 1d texture containing a palette
@@ -705,6 +708,11 @@ static gl_shaderstate_t gl_shaderstate;
// Shader info
static float shader_leveltime = 0;
static float shader_light_x = 0.0f;
static float shader_light_y = 0.0f;
static float shader_light_z = 0.0f;
static INT32 shader_light_contrast = 0;
static INT32 shader_light_backlight = 0;
// Lactozilla: Shader functions
static boolean Shader_CompileProgram(gl_shader_t *shader, GLint i);
@@ -861,6 +869,21 @@ EXPORT void HWRAPI(SetShaderInfo) (hwdshaderinfo_t info, INT32 value)
case HWD_SHADERINFO_LEVELTIME:
shader_leveltime = value;
break;
case HWD_SHADERINFO_LIGHT_X:
shader_light_x = FixedToFloat(value);
break;
case HWD_SHADERINFO_LIGHT_Y:
shader_light_y = FixedToFloat(value);
break;
case HWD_SHADERINFO_LIGHT_Z:
shader_light_z = FixedToFloat(value);
break;
case HWD_SHADERINFO_LIGHT_CONTRAST:
shader_light_contrast = value;
break;
case HWD_SHADERINFO_LIGHT_BACKLIGHT:
shader_light_backlight = value;
break;
default:
break;
}
@@ -1851,11 +1874,32 @@ static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAF
UNIFORM_4(shader->uniforms[gluniform_tint_color], tint->red, tint->green, tint->blue, tint->alpha, pglUniform4f);
UNIFORM_4(shader->uniforms[gluniform_fade_color], fade->red, fade->green, fade->blue, fade->alpha, pglUniform4f);
boolean directional = false;
if (Surface != NULL)
{
UNIFORM_1(shader->uniforms[gluniform_lighting], (GLfloat)Surface->LightInfo.light_level, pglUniform1f);
UNIFORM_1(shader->uniforms[gluniform_fade_start], (GLfloat)Surface->LightInfo.fade_start, pglUniform1f);
UNIFORM_1(shader->uniforms[gluniform_fade_end], (GLfloat)Surface->LightInfo.fade_end, pglUniform1f);
directional = Surface->LightInfo.directional;
}
else
{
UNIFORM_1(shader->uniforms[gluniform_lighting], 255, pglUniform1f);
UNIFORM_1(shader->uniforms[gluniform_fade_start], 0, pglUniform1f);
UNIFORM_1(shader->uniforms[gluniform_fade_end], 31, pglUniform1f);
}
if (directional)
{
UNIFORM_3(shader->uniforms[gluniform_light_dir], shader_light_x, shader_light_y, shader_light_z, pglUniform3f);
UNIFORM_1(shader->uniforms[gluniform_light_contrast], shader_light_contrast, pglUniform1f);
UNIFORM_1(shader->uniforms[gluniform_light_backlight], shader_light_backlight, pglUniform1f);
}
else
{
UNIFORM_3(shader->uniforms[gluniform_light_dir], 0, 0, 0, pglUniform3f);
UNIFORM_1(shader->uniforms[gluniform_light_contrast], 0, pglUniform1f);
UNIFORM_1(shader->uniforms[gluniform_light_backlight], 0, pglUniform1f);
}
UNIFORM_1(shader->uniforms[gluniform_leveltime], ((float)shader_leveltime) / TICRATE, pglUniform1f);
@@ -1980,6 +2024,9 @@ static boolean Shader_CompileProgram(gl_shader_t *shader, GLint i)
shader->uniforms[gluniform_lighting] = GETUNI("lighting");
shader->uniforms[gluniform_fade_start] = GETUNI("fade_start");
shader->uniforms[gluniform_fade_end] = GETUNI("fade_end");
shader->uniforms[gluniform_light_dir] = GETUNI("light_dir");
shader->uniforms[gluniform_light_contrast] = GETUNI("light_contrast");
shader->uniforms[gluniform_light_backlight] = GETUNI("light_backlight");
// palette rendering
shader->uniforms[gluniform_palette_tex] = GETUNI("palette_tex");
+2
View File
@@ -293,6 +293,7 @@ typedef struct mobj_s
fixed_t spritexoffset, spriteyoffset;
fixed_t old_spritexscale, old_spriteyscale;
fixed_t old_spritexoffset, old_spriteyoffset;
INT16 lightlevel; // Add to sector lightlevel, -255 - 255
fixed_t realxscale, realyscale; // funn-E streeetch
@@ -447,6 +448,7 @@ typedef struct precipmobj_s
fixed_t spritexoffset, spriteyoffset;
fixed_t old_spritexscale, old_spriteyscale;
fixed_t old_spritexoffset, old_spriteyoffset;
INT16 lightlevel; // Add to sector lightlevel, -255 - 255
fixed_t realxscale, realyscale; // funn-E streeetch
+63 -3
View File
@@ -358,6 +358,14 @@ static void P_ClearSingleMapHeaderInfo(INT16 i)
//mapheaderinfo[num]->automap = false;
DEH_WriteUndoline("MOBJSCALE", va("%d", mapheaderinfo[num]->mobj_scale), UNDO_NONE);
mapheaderinfo[num]->mobj_scale = FRACUNIT;
DEH_WriteUndoline("LIGHTCONTRAST", va("%d", mapheaderinfo[num]->light_contrast), UNDO_NONE);
mapheaderinfo[num]->light_contrast = 8;
DEH_WriteUndoline("SPRITEBACKLIGHT", va("%d", mapheaderinfo[num]->sprite_backlight), UNDO_NONE);
mapheaderinfo[num]->sprite_backlight = 0;
DEH_WriteUndoline("LIGHTANGLE", va("%d", mapheaderinfo[num]->use_light_angle), UNDO_NONE);
mapheaderinfo[num]->use_light_angle = false;
DEH_WriteUndoline("LIGHTANGLE", va("%d", mapheaderinfo[num]->light_angle), UNDO_NONE);
mapheaderinfo[num]->light_angle = 0;
// an even further impossibility, delfile custom opts support
mapheaderinfo[num]->customopts = NULL;
mapheaderinfo[num]->numCustomOptions = 0;
@@ -528,21 +536,73 @@ static inline float P_SegLengthFloat(seg_t *seg)
*/
void P_UpdateSegLightOffset(seg_t *li)
{
const UINT8 contrast = 8;
const UINT8 contrast = maplighting.contrast;
const fixed_t contrastFixed = ((fixed_t)contrast) * FRACUNIT;
fixed_t light = FRACUNIT;
fixed_t extralight = 0;
light = FixedDiv(R_PointToAngle2(0, 0, abs(li->v1->x - li->v2->x), abs(li->v1->y - li->v2->y)), ANGLE_90);
if (maplighting.directional == true)
{
angle_t liAngle = R_PointToAngle2(0, 0, (li->v1->x - li->v2->x), (li->v1->y - li->v2->y)) - ANGLE_90;
light = FixedMul(FINECOSINE(liAngle >> ANGLETOFINESHIFT), FINECOSINE(maplighting.angle >> ANGLETOFINESHIFT))
+ FixedMul(FINESINE(liAngle >> ANGLETOFINESHIFT), FINESINE(maplighting.angle >> ANGLETOFINESHIFT));
light = (light + FRACUNIT) / 2;
}
else
{
light = FixedDiv(R_PointToAngle2(0, 0, abs(li->v1->x - li->v2->x), abs(li->v1->y - li->v2->y)), ANGLE_90);
}
extralight = -contrastFixed + FixedMul(light, contrastFixed * 2);
// Between -2 and 2 for software, -8 and 8 for hardware
li->lightOffset = FixedFloor((extralight / contrast) + (FRACUNIT / 2)) / FRACUNIT;
li->lightOffset = FixedFloor((extralight / 8) + (FRACUNIT / 2)) / FRACUNIT;
#ifdef HWRENDER
li->hwLightOffset = FixedFloor(extralight + (FRACUNIT / 2)) / FRACUNIT;
#endif
}
boolean P_SectorUsesDirectionalLighting(const sector_t *sector)
{
if (sector != NULL)
{
// automatically turned on
if (sector->ceilingpic == skyflatnum)
{
// sky is visible
return true;
}
}
// default is off, for indoors
return false;
}
boolean P_ApplyLightOffset(UINT8 baselightnum, const sector_t *sector)
{
if (!P_SectorUsesDirectionalLighting(sector))
{
return false;
}
// Don't apply light offsets at full bright or full dark.
// Is in steps of light num .
return (baselightnum < LIGHTLEVELS-1 && baselightnum > 0);
}
boolean P_ApplyLightOffsetFine(UINT8 baselightlevel, const sector_t *sector)
{
if (!P_SectorUsesDirectionalLighting(sector))
{
return false;
}
// Don't apply light offsets at full bright or full dark.
// Uses exact light levels for more smoothness.
return (baselightlevel < 255 && baselightlevel > 0);
}
// Loads the SEGS resource from a level.
static void P_LoadRawSegs(UINT8 *data)
{
+3
View File
@@ -89,6 +89,9 @@ SINT8 P_PartialAddGetStage(void);
boolean P_RunSOC(const char *socfilename);
void P_WriteThings(lumpnum_t lump);
void P_UpdateSegLightOffset(seg_t *li);
boolean P_ApplyLightOffset(UINT8 baselightnum, const sector_t *sector);
boolean P_ApplyLightOffsetFine(UINT8 baselightlevel, const sector_t *sector);
boolean P_SectorUsesDirectionalLighting(const sector_t *sector);
size_t P_PrecacheLevelFlats(void);
void P_AllocMapHeader(INT16 i);
+39 -7
View File
@@ -30,14 +30,14 @@ static UINT16 slopecount = 0;
// Calculate light
static void P_UpdateSlopeLightOffset(pslope_t *slope)
{
const boolean ceiling = (slope->normal.z < 0);
const UINT8 contrast = 8;
const UINT8 contrast = maplighting.contrast;
fixed_t contrastFixed = ((fixed_t)contrast) * FRACUNIT;
fixed_t zMul = FRACUNIT;
angle_t slopeDir = ANGLE_MAX;
fixed_t light = FRACUNIT;
fixed_t extralight = 0;
if (slope->normal.z == 0)
{
slope->lightOffset = 0;
@@ -47,15 +47,47 @@ static void P_UpdateSlopeLightOffset(pslope_t *slope)
return;
}
slopeDir = R_PointToAngle2(0, 0, abs(slope->normal.y), abs(slope->normal.x));
if (ceiling == true)
if (maplighting.directional == true)
{
slopeDir ^= ANGLE_180;
fixed_t nX = -slope->normal.x;
fixed_t nY = -slope->normal.y;
fixed_t nLen = FixedHypot(nX, nY);
if (nLen == 0)
{
slope->lightOffset = 0;
#ifdef HWRENDER
slope->hwLightOffset = 0;
#endif
return;
}
nX = FixedDiv(nX, nLen);
nY = FixedDiv(nY, nLen);
/*
* if (slope is ceiling)
* {
* // There is no good way to calculate this condition here.
* // We reverse it in R_FindPlane now.
* nX = -nX;
* nY = -nY;
}
*/
light = FixedMul(nX, FINECOSINE(maplighting.angle >> ANGLETOFINESHIFT))
+ FixedMul(nY, FINESINE(maplighting.angle >> ANGLETOFINESHIFT));
light = (light + FRACUNIT) / 2;
}
else
{
light = FixedDiv(R_PointToAngle2(0, 0, abs(slope->d.x), abs(slope->d.y)), ANGLE_90);
}
zMul = min(FRACUNIT, abs(slope->zdelta)*3/2); // *3/2, to make 60 degree slopes match walls.
contrastFixed = FixedMul(contrastFixed, zMul);
extralight = -contrastFixed + FixedMul(FixedDiv(AngleFixed(slopeDir), ANGLE_90), (contrastFixed * 2));
extralight = -contrastFixed + FixedMul(light, contrastFixed * 2);
// Between -2 and 2 for software, -8 and 8 for hardware
slope->lightOffset = FixedFloor((extralight / 8) + (FRACUNIT / 2)) / FRACUNIT;
+6
View File
@@ -5166,6 +5166,12 @@ void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate)
// Set the default gravity. Custom gravity overrides this setting.
gravity = (FRACUNIT*8)/10;
// Set map lighting settings.
maplighting.contrast = mapheaderinfo[gamemap-1]->light_contrast;
maplighting.backlight = mapheaderinfo[gamemap-1]->sprite_backlight;
maplighting.directional = mapheaderinfo[gamemap-1]->use_light_angle;
maplighting.angle = mapheaderinfo[gamemap-1]->light_angle;
// Defaults in case levels don't have them set.
sstimer = 90*TICRATE + 6;
totalrings = 1;
+6 -6
View File
@@ -943,7 +943,7 @@ static void R_Subsector(size_t num)
frontsector->floor_xoffs, frontsector->floor_yoffs, frontsector->floorpic_angle, floorcolormap, NULL
, NULL
, frontsector->f_slope
, R_NoEncore(frontsector, false));
, R_NoEncore(frontsector, false), false, frontsector);
}
else
floorplane = NULL;
@@ -959,7 +959,7 @@ static void R_Subsector(size_t num)
ceilingcolormap, NULL
, NULL
, frontsector->c_slope
, R_NoEncore(frontsector, true));
, R_NoEncore(frontsector, true), true, frontsector);
}
else
ceilingplane = NULL;
@@ -1009,7 +1009,7 @@ static void R_Subsector(size_t num)
*rover->bottomyoffs, *rover->bottomangle, frontsector->lightlist[light].extra_colormap, rover
, NULL
, *rover->b_slope
, R_NoEncore(rover->master->frontsector, true));
, R_NoEncore(rover->master->frontsector, true), true, frontsector);
ffloor[numffloors].slope = *rover->b_slope;
@@ -1045,7 +1045,7 @@ static void R_Subsector(size_t num)
frontsector->lightlist[light].extra_colormap, rover
, NULL
, *rover->t_slope
, R_NoEncore(rover->master->frontsector, false));
, R_NoEncore(rover->master->frontsector, false), false, frontsector);
ffloor[numffloors].slope = *rover->t_slope;
@@ -1090,7 +1090,7 @@ static void R_Subsector(size_t num)
polysec->floorpic_angle-po->angle,
(light == -1 ? frontsector->extra_colormap : frontsector->lightlist[light].extra_colormap), NULL, po
,NULL // will ffloors be slopable eventually?
, R_NoEncore(polysec, false));
, R_NoEncore(polysec, false), false, frontsector);
ffloor[numffloors].height = polysec->floorheight;
ffloor[numffloors].polyobj = po;
@@ -1114,7 +1114,7 @@ static void R_Subsector(size_t num)
(light == -1 ? frontsector->lightlevel : *frontsector->lightlist[light].lightlevel), polysec->ceiling_xoffs, polysec->ceiling_yoffs, polysec->ceilingpic_angle-po->angle,
(light == -1 ? frontsector->extra_colormap : frontsector->lightlist[light].extra_colormap), NULL, po
,NULL // will ffloors be slopable eventually?
, R_NoEncore(polysec, true));
, R_NoEncore(polysec, true), false, frontsector);
ffloor[numffloors].polyobj = po;
ffloor[numffloors].height = polysec->ceilingheight;
+2
View File
@@ -693,6 +693,8 @@ typedef enum // trimmed since its only real use here is for xscale/yscale
RF_VERTICALFLIP = 0x0002, // Flip sprite vertically
RF_ABSOLUTEOFFSETS = 0x0004, // Sprite uses the object's offsets absolutely, instead of relatively
RF_FLIPOFFSETS = 0x0008, // Relative object offsets are flipped with the sprite
FF_ABSOLUTELIGHTLEVEL = 0x00010000, // mobj_t.lightlevel is absolute instead of relative
} renderflags_t;
typedef enum
+11 -3
View File
@@ -382,7 +382,8 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
ffloor_t *pfloor
, polyobj_t *polyobj
, pslope_t *slope
, boolean noencore)
, boolean noencore
, boolean reverseLight, const sector_t *lighting_sector)
{
visplane_t *check;
unsigned hash;
@@ -419,9 +420,16 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
}
}
if (slope != NULL)
if (slope != NULL && P_ApplyLightOffset(lightlevel >> LIGHTSEGSHIFT, lighting_sector))
{
lightlevel += slope->lightOffset * 8;
if (reverseLight)
{
lightlevel -= slope->lightOffset * 8;
}
else
{
lightlevel += slope->lightOffset * 8;
}
}
// This appears to fix the Nimbus Ruins sky bug.
+2 -1
View File
@@ -87,7 +87,8 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, fixed_t
extracolormap_t *planecolormap, ffloor_t *ffloor
, polyobj_t *polyobj
, pslope_t *slope
, boolean noencore);
, boolean noencore
, boolean reverseLight, const sector_t *lighting_sector);
visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop);
void R_ExpandPlane(visplane_t *pl, INT32 start, INT32 stop);
void R_PlaneBounds(visplane_t *plane);
+8 -6
View File
@@ -22,6 +22,7 @@
#include "d_netcmd.h"
#include "m_misc.h"
#include "p_local.h" // Camera...
#include "p_setup.h"
#include "p_slopes.h"
#include "console.h" // con_clipviewtop
@@ -406,7 +407,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
if (rlight->extra_colormap && rlight->extra_colormap->fog)
;
else
else if (P_ApplyLightOffset(lightnum, frontsector))
lightnum += curline->lightOffset;
rlight->lightnum = lightnum;
@@ -427,7 +428,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
if (colfunc == R_DrawFogColumn_8
|| (frontsector->extra_colormap && frontsector->extra_colormap->fog))
;
else
else if (P_ApplyLightOffset(lightnum, frontsector))
lightnum += curline->lightOffset;
if (lightnum < 0)
@@ -832,7 +833,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
if (pfloor->flags & FF_FOG || rlight->flags & FF_FOG || (rlight->extra_colormap && rlight->extra_colormap->fog))
;
else
else if (P_ApplyLightOffset(lightnum, frontsector))
rlight->lightnum += curline->lightOffset;
p++;
@@ -855,7 +856,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
if (pfloor->flags & FF_FOG || (frontsector->extra_colormap && frontsector->extra_colormap->fog))
;
else
else if (P_ApplyLightOffset(lightnum, frontsector))
lightnum += curline->lightOffset;
if (lightnum < 0)
@@ -1409,7 +1410,7 @@ static void R_RenderSegLoop (void)
if (dc_lightlist[i].extra_colormap)
;
else
else if (P_ApplyLightOffset(lightnum, frontsector))
lightnum += curline->lightOffset;
if (lightnum < 0)
@@ -2427,7 +2428,8 @@ void R_StoreWallRange(INT32 start, INT32 stop)
// OPTIMIZE: get rid of LIGHTSEGSHIFT globally
lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT);
lightnum += curline->lightOffset;
if (P_ApplyLightOffset(lightnum, frontsector))
lightnum += curline->lightOffset;
if (lightnum < 0)
walllights = scalelight[0];
+86 -14
View File
@@ -26,6 +26,7 @@
#include "r_plane.h"
#include "p_tick.h"
#include "p_local.h"
#include "p_setup.h"
#include "p_slopes.h"
#include "dehacked.h" // get_number (for thok)
#include "d_netfil.h" // blargh. for nameonly().
@@ -106,6 +107,13 @@ static drawseg_xrange_item_t *drawsegs_xrange;
static size_t drawsegs_xrange_size = 0;
static INT32 drawsegs_xrange_count = 0;
INT32 R_ThingLightLevel(mobj_t* thing)
{
INT32 lightlevel = thing->lightlevel;
return lightlevel;
}
// ==========================================================================
//
// Sprite loading routines: support sprites in pwad, dehacked sprite renaming,
@@ -1095,6 +1103,26 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope)
#undef CHECKZ
}
fixed_t R_GetSpriteDirectionalLighting(angle_t angle)
{
// Copied from P_UpdateSegLightOffset
const UINT8 contrast = min(max(0, maplighting.contrast - maplighting.backlight), UINT8_MAX);
const fixed_t contrastFixed = ((fixed_t)contrast) * FRACUNIT;
fixed_t light = FRACUNIT;
fixed_t extralight = 0;
light = FixedMul(FINECOSINE(angle >> ANGLETOFINESHIFT), FINECOSINE(maplighting.angle >> ANGLETOFINESHIFT))
+ FixedMul(FINESINE(angle >> ANGLETOFINESHIFT), FINESINE(maplighting.angle >> ANGLETOFINESHIFT));
light = (light + FRACUNIT) / 2;
light = FixedMul(light, FRACUNIT - FSIN(abs(AngleDeltaSigned(angle, maplighting.angle)) / 2));
extralight = -contrastFixed + FixedMul(light, contrastFixed * 2);
return extralight;
}
//
// R_ProjectSprite
// Generates a vissprite for a thing
@@ -1140,6 +1168,7 @@ static void R_ProjectSprite(mobj_t *thing)
fixed_t gz, gzt;
INT32 heightsec, phs;
INT32 light = 0;
lighttable_t **lights_array = spritelights;
fixed_t this_scale;
fixed_t spritexscale, spriteyscale;
@@ -1556,28 +1585,71 @@ static void R_ProjectSprite(mobj_t *thing)
return;
}
if (thing->subsector->sector->numlights)
if (thing->renderflags & FF_ABSOLUTELIGHTLEVEL)
{
const UINT8 n = R_ThingLightLevel(thing);
// n = uint8 aka 0 - 255, so the shift will always be 0 - LIGHTLEVELS - 1
lights_array = scalelight[n >> LIGHTSEGSHIFT];
}
else
{
INT32 lightnum;
light = thing->subsector->sector->numlights - 1;
if (thing->subsector->sector->numlights)
{
light = thing->subsector->sector->numlights - 1;
for (lightnum = 1; lightnum < thing->subsector->sector->numlights; lightnum++) {
fixed_t h = thing->subsector->sector->lightlist[lightnum].slope ? P_GetZAt(thing->subsector->sector->lightlist[lightnum].slope, interp.x, interp.y)
: thing->subsector->sector->lightlist[lightnum].height;
if (h <= gzt)
for (lightnum = 1; lightnum < thing->subsector->sector->numlights; lightnum++) {
fixed_t h = thing->subsector->sector->lightlist[lightnum].slope ? P_GetZAt(thing->subsector->sector->lightlist[lightnum].slope, interp.x, interp.y)
: thing->subsector->sector->lightlist[lightnum].height;
if (h <= gzt)
{
light = lightnum - 1;
break;
}
}
lightnum = *thing->subsector->sector->lightlist[light].lightlevel;
}
else
{
lightnum = thing->subsector->sector->lightlevel;
}
lightnum = (lightnum + R_ThingLightLevel(thing)) >> LIGHTSEGSHIFT;
if (maplighting.directional == true && P_SectorUsesDirectionalLighting(thing->subsector->sector))
{
fixed_t extralight = R_GetSpriteDirectionalLighting(papersprite
? interp.angle + (ang >= ANGLE_180 ? -ANGLE_90 : ANGLE_90)
: R_PointToAngle(interp.x, interp.y));
// Less change in contrast in dark sectors
extralight = FixedMul(extralight, min(max(0, lightnum), LIGHTLEVELS - 1) * FRACUNIT / (LIGHTLEVELS - 1));
if (papersprite)
{
light = lightnum - 1;
break;
// Papersprite contrast should match walls
lightnum += FixedFloor((extralight / 8) + (FRACUNIT / 2)) / FRACUNIT;
}
else
{
fixed_t n = FixedDiv(FixedMul(xscale, LIGHTRESOLUTIONFIX), ((MAXLIGHTSCALE-1) << LIGHTSCALESHIFT));
// Less change in contrast at further distances, to counteract DOOM diminished light
extralight = FixedMul(extralight, min(n, FRACUNIT));
// Contrast is stronger for normal sprites, stronger than wall lighting is at the same distance
lightnum += FixedFloor((extralight / 4) + (FRACUNIT / 2)) / FRACUNIT;
}
}
lightnum = (*thing->subsector->sector->lightlist[light].lightlevel >> LIGHTSEGSHIFT);
if (lightnum < 0)
spritelights = scalelight[0];
lights_array = scalelight[0];
else if (lightnum >= LIGHTLEVELS)
spritelights = scalelight[LIGHTLEVELS-1];
lights_array = scalelight[LIGHTLEVELS-1];
else
spritelights = scalelight[lightnum];
lights_array = scalelight[lightnum];
}
heightsec = thing->subsector->sector->heightsec;
@@ -1707,7 +1779,7 @@ static void R_ProjectSprite(mobj_t *thing)
// Mitigate against negative xscale and arithmetic overflow
lindex = CLAMP(lindex, 0, MAXLIGHTSCALE - 1);
vis->colormap = spritelights[lindex];
vis->colormap = lights_array[lindex];
}
vis->precip = false;
@@ -1719,7 +1791,7 @@ static void R_ProjectSprite(mobj_t *thing)
vis->isScaled = false;
if (thing->subsector->sector->numlights)
if (thing->subsector->sector->numlights && !(thing->renderflags & FF_ABSOLUTELIGHTLEVEL))
R_SplitSprite(vis, thing);
// Debug
+3
View File
@@ -56,6 +56,9 @@ extern fixed_t sprbotscreen;
extern fixed_t windowtop;
extern fixed_t windowbottom;
INT32 R_ThingLightLevel(mobj_t *thing);
fixed_t R_GetSpriteDirectionalLighting(angle_t angle);
fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope);
void R_DrawMaskedColumn(column_t *column);
+5
View File
@@ -176,6 +176,11 @@ fixed_t *finecosine = &finesine[FINEANGLES/4];
#include "t_facon.c"
INT32 AngleDeltaSigned(angle_t a1, angle_t a2)
{
// Silly but easy way to do it through integer conversion.
return (INT32)(a1) - (INT32)(a2);
}
FUNCMATH angle_t FixedAcos(fixed_t x)
{
+2
View File
@@ -110,6 +110,8 @@ FUNCMATH angle_t FixedAngleC(fixed_t fa, fixed_t factor);
/// The FixedAcos function
FUNCMATH angle_t FixedAcos(fixed_t x);
FUNCMATH INT32 AngleDeltaSigned(angle_t a1, angle_t a2);
/// Fixed Point Vector functions
angle_t FV2_AngleBetweenVectors(const vector2_t *Vector1, const vector2_t *Vector2);
angle_t FV3_AngleBetweenVectors(const vector3_t *Vector1, const vector3_t *Vector2);