hack some sort of hdr in there, because we can. I'm sure it could be improved.

provide xz support, because we might as well.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4866 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2015-04-27 12:51:42 +00:00
parent 410db5d6b0
commit 56b8f125a1
12 changed files with 3232 additions and 14 deletions

View File

@ -647,6 +647,7 @@ COMMON_OBJS = \
fs_stdio.o \
fs_pak.o \
fs_zip.o \
fs_xz.o \
mathlib.o \
huff.o \
md4.o \

View File

@ -607,6 +607,7 @@ struct playerview_s
vec3_t simvel;
vec3_t simangles;
float rollangle;
float hdr_last;
float crouch; // local amount for smoothing stepups
vec3_t oldorigin; // to track step smoothing

View File

@ -974,7 +974,7 @@ void M_Menu_Render_f (void)
};
menu_t *menu;
extern cvar_t r_novis, cl_item_bobbing, r_waterwarp, r_nolerp, r_noframegrouplerp, r_fastsky, gl_nocolors, gl_lerpimages, r_wateralpha, r_drawviewmodel, gl_cshiftenabled;
extern cvar_t r_novis, cl_item_bobbing, r_waterwarp, r_nolerp, r_noframegrouplerp, r_fastsky, gl_nocolors, gl_lerpimages, r_wateralpha, r_drawviewmodel, gl_cshiftenabled, r_hdr_irisadaptation;
#ifdef GLQUAKE
extern cvar_t r_bloom;
#endif
@ -998,6 +998,7 @@ void M_Menu_Render_f (void)
#ifdef GLQUAKE
MB_CHECKBOXCVAR("Bloom", r_bloom, 0),
#endif
MB_CHECKBOXCVAR("HDR", r_hdr_irisadaptation, 0),
MB_CHECKBOXCVAR("Model Bobbing", cl_item_bobbing, 0),
MB_END()
};

View File

@ -2005,6 +2005,7 @@ void Surf_SetupFrame(void)
else
{
VectorCopy(r_refdef.vieworg, pvsorg);
R_UpdateHDR(r_refdef.vieworg);
}
r_viewcontents = 0;

View File

@ -235,6 +235,7 @@ typedef struct
int frustum_numplanes;
fogstate_t globalfog;
float hdr_value;
pxrect_t pxrect; /*vrect, but in pixels rather than virtual coords*/
qboolean externalview; /*draw external models and not viewmodels*/
@ -487,6 +488,7 @@ qbyte *R_MarkLeaves_Q3 (void);
void R_SetFrustum (float projmat[16], float viewmat[16]);
void R_SetRenderer(rendererinfo_t *ri);
void R_AnimateLight (void);
void R_UpdateHDR(vec3_t org);
void R_UpdateLightStyle(unsigned int style, const char *stylestring, float r, float g, float b);
struct texture_s *R_TextureAnimation (int frame, struct texture_s *base); //mostly deprecated, only lingers for rtlights so world only.
struct texture_s *R_TextureAnimation_Q2 (struct texture_s *base); //mostly deprecated, only lingers for rtlights so world only.

View File

@ -114,6 +114,12 @@ cvar_t r_lightstylesmooth = CVARF ("r_lightstylesmooth", "0", CVAR_ARCHIVE)
cvar_t r_lightstylesmooth_limit = SCVAR ("r_lightstylesmooth_limit", "2");
cvar_t r_lightstylespeed = SCVAR ("r_lightstylespeed", "10");
cvar_t r_lightstylescale = SCVAR ("r_lightstylescale", "1");
cvar_t r_hdr_irisadaptation = SCVAR ("r_hdr_irisadaptation", "0");
cvar_t r_hdr_irisadaptation_multiplier = SCVAR ("r_hdr_irisadaptation_multiplier", "2");
cvar_t r_hdr_irisadaptation_minvalue = SCVAR ("r_hdr_irisadaptation_minvalue", "0.5");
cvar_t r_hdr_irisadaptation_maxvalue = SCVAR ("r_hdr_irisadaptation_maxvalue", "4");
cvar_t r_hdr_irisadaptation_fade_down = SCVAR ("r_hdr_irisadaptation_fade_down", "0.5");
cvar_t r_hdr_irisadaptation_fade_up = SCVAR ("r_hdr_irisadaptation_fade_up", "0.1");
cvar_t r_loadlits = CVARF ("r_loadlit", "1", CVAR_ARCHIVE);
cvar_t r_menutint = SCVARF ("r_menutint", "0.68 0.4 0.13",
CVAR_RENDERERCALLBACK);
@ -630,6 +636,13 @@ void Renderer_Init(void)
Cvar_Register(&r_lightstylespeed, GRAPHICALNICETIES);
Cvar_Register(&r_lightstylescale, GRAPHICALNICETIES);
Cvar_Register(&r_hdr_irisadaptation, GRAPHICALNICETIES);
Cvar_Register(&r_hdr_irisadaptation_multiplier, GRAPHICALNICETIES);
Cvar_Register(&r_hdr_irisadaptation_minvalue, GRAPHICALNICETIES);
Cvar_Register(&r_hdr_irisadaptation_maxvalue, GRAPHICALNICETIES);
Cvar_Register(&r_hdr_irisadaptation_fade_down, GRAPHICALNICETIES);
Cvar_Register(&r_hdr_irisadaptation_fade_up, GRAPHICALNICETIES);
Cvar_Register(&r_stains, GRAPHICALNICETIES);
Cvar_Register(&r_stainfadetime, GRAPHICALNICETIES);
Cvar_Register(&r_stainfadeammount, GRAPHICALNICETIES);

View File

@ -96,7 +96,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define AVAIL_DSOUND
#define AVAIL_D3D
#endif
//#define AVAIL_XZDEC
#define AVAIL_XZDEC
#if !defined(MINIMAL) && !defined(NPFTE) && !defined(NPQTV)
#if defined(_WIN32) && !defined(FTE_SDL) && !defined(WINRT)

3110
engine/common/fs_xz.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -5264,8 +5264,10 @@ void GLBE_DrawWorld (qboolean drawworld, qbyte *vis)
else
#endif
shaderstate.identitylighting = 1;
shaderstate.identitylighting *= r_refdef.hdr_value;
shaderstate.identitylightmap = shaderstate.identitylighting / (1<<gl_overbright.ival);
shaderstate.identitylightmap =1;
#ifdef RTLIGHTS
if (r_lightprepass.ival)

View File

@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "shader.h"
extern cvar_t r_shadow_realtime_world, r_shadow_realtime_world_lightmaps;
extern cvar_t r_hdr_irisadaptation, r_hdr_irisadaptation_multiplier, r_hdr_irisadaptation_minvalue, r_hdr_irisadaptation_maxvalue, r_hdr_irisadaptation_fade_down, r_hdr_irisadaptation_fade_up;
int r_dlightframecount;
@ -50,6 +51,38 @@ void R_UpdateLightStyle(unsigned int style, const char *stylestring, float r, fl
cl_lightstyle[style].colourkey = (int)(cl_lightstyle[style].colours[0]*0x400) ^ (int)(cl_lightstyle[style].colours[1]*0x100000) ^ (int)(cl_lightstyle[style].colours[2]*0x40000000);
}
void Sh_CalcPointLight(vec3_t point, vec3_t light);
void R_UpdateHDR(vec3_t org)
{
if (r_hdr_irisadaptation.ival && cl.worldmodel && !(r_refdef.flags & RDF_NOWORLDMODEL))
{
//fake and lame, but whatever.
vec3_t ambient, diffuse, dir;
float lev = 0;
if (!r_shadow_realtime_world.ival || r_shadow_realtime_world_lightmaps.value)
{
cl.worldmodel->funcs.LightPointValues(cl.worldmodel, org, ambient, diffuse, dir);
lev += (VectorLength(ambient) + VectorLength(diffuse))/256;
}
Sh_CalcPointLight(org, ambient);
lev += VectorLength(ambient);
lev += 0.001; //no division by 0!
lev = r_hdr_irisadaptation_multiplier.value / lev;
lev = bound(r_hdr_irisadaptation_minvalue.value, lev, r_hdr_irisadaptation_maxvalue.value);
if (lev > r_refdef.playerview->hdr_last + r_hdr_irisadaptation_fade_up.value*host_frametime)
lev = r_refdef.playerview->hdr_last + r_hdr_irisadaptation_fade_up.value*host_frametime;
else if (lev < r_refdef.playerview->hdr_last - r_hdr_irisadaptation_fade_down.value*host_frametime)
lev = r_refdef.playerview->hdr_last - r_hdr_irisadaptation_fade_down.value*host_frametime;
lev = bound(r_hdr_irisadaptation_minvalue.value, lev, r_hdr_irisadaptation_maxvalue.value);
r_refdef.playerview->hdr_last = lev;
r_refdef.hdr_value = lev;
}
else
r_refdef.hdr_value = 1;
}
/*
==================
R_AnimateLight
@ -60,6 +93,7 @@ void R_AnimateLight (void)
int i,j;
float f;
//if (r_lightstylescale.value > 2)
//r_lightstylescale.value = 2;

View File

@ -3401,6 +3401,56 @@ void Sh_CheckSettings(void)
}
}
void Sh_CalcPointLight(vec3_t point, vec3_t light)
{
vec3_t colour;
dlight_t *dl;
vec3_t disp;
float dist;
float frac;
int i;
unsigned int ignoreflags;
vec3_t norm, impact;
ignoreflags = (r_shadow_realtime_world.value?LFLAG_REALTIMEMODE:LFLAG_NORMALMODE);
VectorClear(light);
if (ignoreflags)
for (dl = cl_dlights+rtlights_first, i=rtlights_first; i<rtlights_max; i++, dl++)
{
if (!(dl->flags & ignoreflags))
continue;
colour[0] = dl->color[0];
colour[1] = dl->color[1];
colour[2] = dl->color[2];
if (dl->style)
{
colour[0] *= cl_lightstyle[dl->style-1].colours[0] * d_lightstylevalue[dl->style-1]/255.0f;
colour[1] *= cl_lightstyle[dl->style-1].colours[1] * d_lightstylevalue[dl->style-1]/255.0f;
colour[2] *= cl_lightstyle[dl->style-1].colours[2] * d_lightstylevalue[dl->style-1]/255.0f;
}
else
{
colour[0] *= r_lightstylescale.value;
colour[1] *= r_lightstylescale.value;
colour[2] *= r_lightstylescale.value;
}
if (colour[0] < 0.001 && colour[1] < 0.001 && colour[2] < 0.001)
continue; //just switch these off.
VectorSubtract(dl->origin, point, disp);
dist = VectorLength(disp);
frac = dist / dl->radius;
if (frac >= 1)
continue;
//FIXME: this should be affected by the direction.
if (!TraceLineN(point, dl->origin, impact, norm))
VectorMA(light, 1-frac, colour, light);
}
}
int drawdlightnum;
void Sh_DrawLights(qbyte *vis)
{
@ -3459,6 +3509,9 @@ void Sh_DrawLights(qbyte *vis)
colour[1] *= r_lightstylescale.value;
colour[2] *= r_lightstylescale.value;
}
colour[0] *= r_refdef.hdr_value;
colour[1] *= r_refdef.hdr_value;
colour[2] *= r_refdef.hdr_value;
if (colour[0] < 0.001 && colour[1] < 0.001 && colour[2] < 0.001)
continue; //just switch these off.

View File

@ -9280,7 +9280,7 @@ BuiltinList_t BuiltinList[] = { //nq qw h2 ebfs
{"bwriteentity", PF_qtBroadcast_WriteEntity, 0, 0, 0, 0, D("void(entity val)", NULL), true}, //66
#endif
{"sin", PF_Sin, 0, 0, 62, 60, "float(float angle)"}, //60
{"sin", PF_Sin, 0, 0, 62, 60, D("float(float angle)", "Forgive me father, for I have trigonometry homework.")}, //60
{"cos", PF_Cos, 0, 0, 61, 61, "float(float angle)"}, //61
{"sqrt", PF_Sqrt, 0, 0, 84, 62, "float(float value)"}, //62
{"modulo", PF_mod, 0, 0, 0, 0, "float(float a, float n)"}, //62
@ -9289,7 +9289,7 @@ BuiltinList_t BuiltinList[] = { //nq qw h2 ebfs
{"tracetoss", PF_TraceToss, 0, 0, 0, 64, "void(entity ent, entity ignore)"},
{"etos", PF_etos, 0, 0, 0, 65, "string(entity ent)"},
{"movetogoal", PF_sv_movetogoal, 67, 67, 67, 0, "void(float step)"}, //67
{"movetogoal", PF_sv_movetogoal, 67, 67, 67, 0, D("void(float step)", "Runs lots and lots of fancy logic in order to try to step the entity the specified distance towards its goalentity.")}, //67
{"precache_file", PF_precache_file, 68, 68, 68, 0, D("string(string s)", "This builtin does nothing. It was used only as a hint for pak generation.")}, //68
{"makestatic", PF_makestatic, 69, 69, 69, 0, D("void(entity e)", "Sends a copy of the entity's renderable fields to all clients, and REMOVES the entity, preventing further changes. This means it will be unmutable and non-solid.")}, //69
@ -9875,9 +9875,9 @@ BuiltinList_t BuiltinList[] = { //nq qw h2 ebfs
{"acos", PF_acos, 0, 0, 0, 472, "float(float c)"},//DP_QC_ASINACOSATANATAN2TAN
{"atan", PF_atan, 0, 0, 0, 473, "float(float t)"},//DP_QC_ASINACOSATANATAN2TAN
{"atan2", PF_atan2, 0, 0, 0, 474, "float(float c, float s)"},//DP_QC_ASINACOSATANATAN2TAN
{"tan", PF_tan, 0, 0, 0, 475, "float(float a)"},//DP_QC_ASINACOSATANATAN2TAN
{"strlennocol", PF_strlennocol, 0, 0, 0, 476, "float(string s)"},//DP_QC_STRINGCOLORFUNCTIONS
{"strdecolorize", PF_strdecolorize, 0, 0, 0, 477, "string(string s)"},//DP_QC_STRINGCOLORFUNCTIONS
{"tan", PF_tan, 0, 0, 0, 475, D("float(float a)", "Forgive me father, for I have a sunbed and I'm not afraid to use it.")},//DP_QC_ASINACOSATANATAN2TAN
{"strlennocol", PF_strlennocol, 0, 0, 0, 476, D("float(string s)", "Returns the number of characters in the string after any colour codes or other markup has been parsed.")},//DP_QC_STRINGCOLORFUNCTIONS
{"strdecolorize", PF_strdecolorize, 0, 0, 0, 477, D("string(string s)", "Flattens any markup/colours, removing them from the string.")},//DP_QC_STRINGCOLORFUNCTIONS
{"strftime", PF_strftime, 0, 0, 0, 478, "string(float uselocaltime, string format, ...)"}, //DP_QC_STRFTIME
{"tokenizebyseparator",PF_tokenizebyseparator,0,0, 0, 479, "float(string s, string separator1, ...)"}, //DP_QC_TOKENIZEBYSEPARATOR
{"strtolower", PF_strtolower, 0, 0, 0, 480, "string(string s)"}, //DP_QC_STRING_CASE_FUNCTIONS
@ -9918,11 +9918,11 @@ BuiltinList_t BuiltinList[] = { //nq qw h2 ebfs
{"uri_unescape", PF_uri_unescape, 0, 0, 0, 511, "string(string in)"},//DP_QC_URI_ESCAPE
{"num_for_edict", PF_num_for_edict, 0, 0, 0, 512, "float(entity ent)"},//DP_QC_NUM_FOR_EDICT
{"uri_get", PF_uri_get, 0, 0, 0, 513, D("float(string uril, float id, optional string postmimetype, optional string postdata)", "uri_get() gets content from an URL and calls a callback \"uri_get_callback\" with it set as string; an unique ID of the transfer is returned\nreturns 1 on success, and then calls the callback with the ID, 0 or the HTTP status code, and the received data in a string")},//DP_QC_URI_GET
{"tokenize_console",PF_tokenize_console,0, 0, 0, 514, "float(string str)"},
{"argv_start_index",PF_argv_start_index,0, 0, 0, 515, "float(float idx)"},
{"argv_end_index", PF_argv_end_index, 0, 0, 0, 516, "float(float idx)"},
{"tokenize_console",PF_tokenize_console,0, 0, 0, 514, D("float(string str)", "Tokenize a string exactly as the console's tokenizer would do so. The regular tokenize builtin became bastardized for convienient string parsing, which resulted in a large disparity that can be exploited to bypass checks implemented in a naive SV_ParseClientCommand function, therefore you can use this builtin to make sure it exactly matches.")},
{"argv_start_index",PF_argv_start_index,0, 0, 0, 515, D("float(float idx)", "Returns the character index that the tokenized arg started at.")},
{"argv_end_index", PF_argv_end_index, 0, 0, 0, 516, D("float(float idx)", "Returns the character index that the tokenized arg stopped at.")},
{"buf_cvarlist", PF_buf_cvarlist, 0, 0, 0, 517, "void(strbuf strbuf, string pattern, string antipattern)"},
{"cvar_description",PF_cvar_description,0, 0, 0, 518, "string(string cvarname)"},
{"cvar_description",PF_cvar_description,0, 0, 0, 518, D("string(string cvarname)", "Retrieves the description of a cvar, which might be useful for tooltips or help files. This may still not be useful.")},
{"gettime", PF_gettime, 0, 0, 0, 519, "float(optional float timetype)"},
{"keynumtostring_omgwtf",PF_Fixme, 0, 0, 0, 520, "string(float keynum)"}, //excessive third version in dp's csqc.
{"findkeysforcommand",PF_Fixme, 0, 0, 0, 521, "string(string command, optional float bindmap)"},
@ -9962,8 +9962,8 @@ BuiltinList_t BuiltinList[] = { //nq qw h2 ebfs
{"getmousetarget", PF_Fixme, 0, 0, 0, 604, "float()"},
{"callfunction", PF_callfunction, 0, 0, 0, 605, D("void(.../*, string funcname*/)", "Invokes the named function. The function name is always passed as the last parameter and must always be present. The others are passed to the named function as-is")},
{"writetofile", PF_writetofile, 0, 0, 0, 606, D("void(filestream fh, entity e)", "Writes an entity's fields to the named frik_file file handle.")},
{"isfunction", PF_isfunction, 0, 0, 0, 607, "float(string s)"},
{"getresolution", PF_Fixme, 0, 0, 0, 608, "vector(float vidmode, optional float forfullscreen)"},
{"isfunction", PF_isfunction, 0, 0, 0, 607, D("float(string s)", "Returns true if the named function exists and can be called with the callfunction builtin.")},
{"getresolution", PF_Fixme, 0, 0, 0, 608, D("vector(float vidmode, optional float forfullscreen)", "Supposed to query the driver for supported video modes. FTE does not query drivers in this way, nor would it trust drivers anyway.")},
{"keynumtostring_menu",PF_Fixme, 0, 0, 0, 609, "string(float keynum)"}, //third copy of this builtin in dp's csqc.
{"findkeysforcommand_dp",PF_Fixme, 0, 0, 0, 610, "string(string command, optional float bindmap)"},
{"keynumtostring", PF_Fixme, 0, 0, 0, 609, D("string(float keynum)", "Converts a qscancode key number into a mostly-human-readable name, matching the bind command.")}, //normal name is for menuqc standard.