From c8f04d9afbc8e2d213f86cc5a6f7ef8b52d2fde3 Mon Sep 17 00:00:00 2001 From: vortex Date: Fri, 20 May 2011 20:27:10 +0000 Subject: [PATCH] Added "loadcubemap" builtin to allow preload cubemaps level can use, added experimental "r_water_lowquality" which reduces options while rendering water planes, this can help a bit. Added "gl_texturecompression_sprites" cvar. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11158 d7cf8633-e32d-0410-b094-e92efae38249 ::stable-branch::merge=4e08e20e6bfbd53bb1796e8de40d261bbfd0e7c3 --- cl_particles.c | 4 ++-- clvm_cmds.c | 14 ++++++++++++-- gl_rmain.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++--- gl_textures.c | 2 ++ model_sprite.c | 5 ++++- 5 files changed, 69 insertions(+), 8 deletions(-) diff --git a/cl_particles.c b/cl_particles.c index 46802873..ebdaad00 100644 --- a/cl_particles.c +++ b/cl_particles.c @@ -1824,11 +1824,11 @@ void CL_ParticleRain (const vec3_t mins, const vec3_t maxs, const vec3_t dir, in } } -static cvar_t r_drawparticles = {0, "r_drawparticles", "1", "enables drawing of particles"}; +cvar_t r_drawparticles = {0, "r_drawparticles", "1", "enables drawing of particles"}; static cvar_t r_drawparticles_drawdistance = {CVAR_SAVE, "r_drawparticles_drawdistance", "2000", "particles further than drawdistance*size will not be drawn"}; static cvar_t r_drawparticles_nearclip_min = {CVAR_SAVE, "r_drawparticles_nearclip_min", "4", "particles closer than drawnearclip_min will not be drawn"}; static cvar_t r_drawparticles_nearclip_max = {CVAR_SAVE, "r_drawparticles_nearclip_max", "4", "particles closer than drawnearclip_min will be faded"}; -static cvar_t r_drawdecals = {0, "r_drawdecals", "1", "enables drawing of decals"}; +cvar_t r_drawdecals = {0, "r_drawdecals", "1", "enables drawing of decals"}; static cvar_t r_drawdecals_drawdistance = {CVAR_SAVE, "r_drawdecals_drawdistance", "500", "decals further than drawdistance*size will not be drawn"}; #define PARTICLETEXTURESIZE 64 diff --git a/clvm_cmds.c b/clvm_cmds.c index 580eabf2..4adb467a 100644 --- a/clvm_cmds.c +++ b/clvm_cmds.c @@ -4014,7 +4014,7 @@ void VM_CL_RotateMoves(void) * has to detect input the client sent before it received the origin * update, but after the warp occurred on the server, and has to adjust * input appropriately. - */ + */ matrix4x4_t m; vec3_t v = {0, 0, 0}; vec3_t x, y, z; @@ -4024,6 +4024,16 @@ void VM_CL_RotateMoves(void) CL_RotateMoves(&m); } +// #358 void(string cubemapname) loadcubemap +static void VM_CL_loadcubemap(void) +{ + const char *name; + + VM_SAFEPARMCOUNT(1, VM_CL_loadcubemap); + name = PRVM_G_STRING(OFS_PARM0); + R_GetCubemap(name); +} + //============================================================================ // To create a almost working builtin file from this replace: @@ -4395,7 +4405,7 @@ VM_CL_serverkey, // #354 string(string key) serverkey (EXT_CSQC) VM_CL_videoplaying, // #355 VM_findfont, // #356 float(string fontname) loadfont (DP_GFX_FONTS) VM_loadfont, // #357 float(string fontname, string fontmaps, string sizes, float slot) loadfont (DP_GFX_FONTS) -NULL, // #358 +VM_CL_loadcubemap, // #358 void(string cubemapname) loadcubemap (DP_GFX_) NULL, // #359 VM_CL_ReadByte, // #360 float() readbyte (EXT_CSQC) VM_CL_ReadChar, // #361 float() readchar (EXT_CSQC) diff --git a/gl_rmain.c b/gl_rmain.c index a8af5a4d..cdf15e68 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -173,6 +173,7 @@ cvar_t r_water_resolutionmultiplier = {CVAR_SAVE, "r_water_resolutionmultiplier" cvar_t r_water_refractdistort = {CVAR_SAVE, "r_water_refractdistort", "0.01", "how much water refractions shimmer"}; cvar_t r_water_reflectdistort = {CVAR_SAVE, "r_water_reflectdistort", "0.01", "how much water reflections shimmer"}; cvar_t r_water_scissormode = {0, "r_water_scissormode", "3", "scissor (1) or cull (2) or both (3) water renders"}; +cvar_t r_water_lowquality = {0, "r_water_lowquality", "0", "special option to accelerate water rendering, 1 disables shadows and particles, 2 disables all dynamic lights"}; cvar_t r_lerpsprites = {CVAR_SAVE, "r_lerpsprites", "0", "enables animation smoothing on sprites"}; cvar_t r_lerpmodels = {CVAR_SAVE, "r_lerpmodels", "1", "enables animation smoothing on models"}; @@ -4164,6 +4165,8 @@ void GL_Main_Init(void) Cvar_RegisterVariable(&r_water_refractdistort); Cvar_RegisterVariable(&r_water_reflectdistort); Cvar_RegisterVariable(&r_water_scissormode); + Cvar_RegisterVariable(&r_water_lowquality); + Cvar_RegisterVariable(&r_lerpsprites); Cvar_RegisterVariable(&r_lerpmodels); Cvar_RegisterVariable(&r_lerplightstyles); @@ -5545,17 +5548,44 @@ void R_Water_AddWaterPlane(msurface_t *surface, int entno) } } +extern cvar_t r_drawparticles; +extern cvar_t r_drawdecals; + static void R_Water_ProcessPlanes(void) { int myscissor[4]; r_refdef_view_t originalview; r_refdef_view_t myview; - int planeindex; + int planeindex, qualityreduction = 0, old_r_dynamic = 0, old_r_shadows = 0, old_r_worldrtlight = 0, old_r_dlight = 0, old_r_particles = 0, old_r_decals = 0; r_waterstate_waterplane_t *p; vec3_t visorigin; originalview = r_refdef.view; + // lowquality hack, temporarily shut down some cvars and restore afterwards + qualityreduction = r_water_lowquality.integer; + if (qualityreduction > 0) + { + if (qualityreduction >= 1) + { + old_r_shadows = r_shadows.integer; + old_r_worldrtlight = r_shadow_realtime_world.integer; + old_r_dlight = r_shadow_realtime_dlight.integer; + Cvar_SetValueQuick(&r_shadows, 0); + Cvar_SetValueQuick(&r_shadow_realtime_world, 0); + Cvar_SetValueQuick(&r_shadow_realtime_dlight, 0); + } + if (qualityreduction >= 2) + { + old_r_dynamic = r_dynamic.integer; + old_r_particles = r_drawparticles.integer; + old_r_decals = r_drawdecals.integer; + Cvar_SetValueQuick(&r_dynamic, 0); + Cvar_SetValueQuick(&r_drawparticles, 0); + Cvar_SetValueQuick(&r_drawdecals, 0); + } + } + // make sure enough textures are allocated for (planeindex = 0, p = r_waterstate.waterplanes;planeindex < r_waterstate.numwaterplanes;planeindex++, p++) { @@ -5735,13 +5765,29 @@ static void R_Water_ProcessPlanes(void) R_ResetViewRendering3D(); R_ClearScreen(r_refdef.fogenabled); R_View_Update(); - return; + goto finish; error: r_refdef.view = originalview; r_waterstate.renderingscene = false; Cvar_SetValueQuick(&r_water, 0); Con_Printf("R_Water_ProcessPlanes: Error: texture creation failed! Turned off r_water.\n"); - return; +finish: + // lowquality hack, restore cvars + if (qualityreduction > 0) + { + if (qualityreduction >= 1) + { + Cvar_SetValueQuick(&r_shadows, old_r_shadows); + Cvar_SetValueQuick(&r_shadow_realtime_world, old_r_worldrtlight); + Cvar_SetValueQuick(&r_shadow_realtime_dlight, old_r_dlight); + } + if (qualityreduction >= 2) + { + Cvar_SetValueQuick(&r_dynamic, old_r_dynamic); + Cvar_SetValueQuick(&r_drawparticles, old_r_particles); + Cvar_SetValueQuick(&r_drawdecals, old_r_decals); + } + } } void R_Bloom_StartFrame(void) diff --git a/gl_textures.c b/gl_textures.c index 4b262fa8..4966f0d2 100644 --- a/gl_textures.c +++ b/gl_textures.c @@ -31,6 +31,7 @@ cvar_t gl_texturecompression_q3bspdeluxemaps = {CVAR_SAVE, "gl_texturecompressio cvar_t gl_texturecompression_sky = {CVAR_SAVE, "gl_texturecompression_sky", "0", "whether to compress sky textures"}; cvar_t gl_texturecompression_lightcubemaps = {CVAR_SAVE, "gl_texturecompression_lightcubemaps", "1", "whether to compress light cubemaps (spotlights and other light projection images)"}; cvar_t gl_texturecompression_reflectmask = {CVAR_SAVE, "gl_texturecompression_reflectmask", "1", "whether to compress reflection cubemap masks (mask of which areas of the texture should reflect the generic shiny cubemap)"}; +cvar_t gl_texturecompression_sprites = {CVAR_SAVE, "gl_texturecompression_sprites", "1", "whether to compress sprites"}; cvar_t gl_nopartialtextureupdates = {CVAR_SAVE, "gl_nopartialtextureupdates", "0", "use alternate path for dynamic lightmap updates that avoids a possibly slow code path in the driver"}; cvar_t r_texture_dds_load_alphamode = {0, "r_texture_dds_load_alphamode", "1", "0: trust DDPF_ALPHAPIXELS flag, 1: texture format and brute force search if ambiguous, 2: texture format only"}; cvar_t r_texture_dds_load_logfailure = {0, "r_texture_dds_load_logfailure", "1", "log missing DDS textures to ddstexturefailures.log"}; @@ -897,6 +898,7 @@ void R_Textures_Init (void) Cvar_RegisterVariable (&gl_texturecompression_sky); Cvar_RegisterVariable (&gl_texturecompression_lightcubemaps); Cvar_RegisterVariable (&gl_texturecompression_reflectmask); + Cvar_RegisterVariable (&gl_texturecompression_sprites); Cvar_RegisterVariable (&gl_nopartialtextureupdates); Cvar_RegisterVariable (&r_texture_dds_load_alphamode); Cvar_RegisterVariable (&r_texture_dds_load_logfailure); diff --git a/model_sprite.c b/model_sprite.c index 3588c61d..3e9f7b47 100644 --- a/model_sprite.c +++ b/model_sprite.c @@ -65,6 +65,8 @@ static void Mod_SpriteSetupTexture(texture_t *texture, skinframe_t *skinframe, q texture->supercontents |= SUPERCONTENTS_OPAQUE; } +extern cvar_t gl_texturecompression_sprites; + static void Mod_Sprite_SharedSetup(const unsigned char *datapointer, int version, const unsigned int *palette, qboolean additive) { int i, j, groupframes, realframes, x, y, origin[2], width, height; @@ -77,7 +79,7 @@ static void Mod_Sprite_SharedSetup(const unsigned char *datapointer, int version float modelradius, interval; char name[MAX_QPATH], fogname[MAX_QPATH]; const void *startframes; - int texflags = (r_mipsprites.integer ? TEXF_MIPMAP : 0) | TEXF_ISSPRITE | TEXF_PICMIP | TEXF_ALPHA | TEXF_CLAMP; + int texflags = (r_mipsprites.integer ? TEXF_MIPMAP : 0) | (gl_texturecompression_sprites.integer ? TEXF_COMPRESS : 0) | TEXF_ISSPRITE | TEXF_PICMIP | TEXF_ALPHA | TEXF_CLAMP; modelradius = 0; if (loadmodel->numframes < 1) @@ -213,6 +215,7 @@ static void Mod_Sprite_SharedSetup(const unsigned char *datapointer, int version else //if (version == SPRITEHL_VERSION || version == SPRITE_VERSION) Image_Copy8bitBGRA(datapointer, pixels, width*height, palette ? palette : palette_bgra_transparent); skinframe = R_SkinFrame_LoadInternalBGRA(name, texflags, pixels, width, height, false); + // texflags |= TEXF_COMPRESS; Mem_Free(pixels); } } -- 2.39.2