From 9d26d7c94f91f2175c916b5a961b0479ea5f68a6 Mon Sep 17 00:00:00 2001 From: black Date: Mon, 25 Feb 2008 13:07:10 +0000 Subject: [PATCH] Move rt* states and the ambient value into r_refdef_scene. Menu now uses fullbright rendering as default. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8131 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_main.c | 2 +- client.h | 11 +++++++---- gl_rmain.c | 26 ++++++++++++++------------ mvm_cmds.c | 2 ++ r_shadow.c | 12 ++++++------ 5 files changed, 30 insertions(+), 23 deletions(-) diff --git a/cl_main.c b/cl_main.c index 6078183b..4bd33087 100644 --- a/cl_main.c +++ b/cl_main.c @@ -488,7 +488,7 @@ static void CL_UpdateRenderEntity_Lighting(entity_render_t *ent) vec3_t tempdiffusenormal; // fetch the lighting from the worldmodel data - VectorSet(ent->modellight_ambient, r_ambient.value * (2.0f / 128.0f), r_ambient.value * (2.0f / 128.0f), r_ambient.value * (2.0f / 128.0f)); + VectorSet(ent->modellight_ambient, r_refdef.scene.ambient * (2.0f / 128.0f), r_refdef.scene.ambient * (2.0f / 128.0f), r_refdef.scene.ambient * (2.0f / 128.0f)); VectorClear(ent->modellight_diffuse); VectorClear(tempdiffusenormal); if ((ent->flags & RENDER_LIGHT) && cl.worldmodel && cl.worldmodel->brush.LightPoint) diff --git a/client.h b/client.h index fac7edfb..fe483591 100644 --- a/client.h +++ b/client.h @@ -1470,6 +1470,13 @@ typedef struct r_refdef_scene_s { // 8.8bit fixed point intensities for light styles // controls intensity lightmap layers unsigned short lightstylevalue[256]; // 8.8 fraction of base light value + + float ambient; + + qboolean rtworld; + qboolean rtworldshadows; + qboolean rtdlight; + qboolean rtdlightshadows; } r_refdef_scene_t; typedef struct r_refdef_s @@ -1523,10 +1530,6 @@ typedef struct r_refdef_s // (often reduced when world rtlights are enabled) float lightmapintensity; // whether to draw world lights realtime, dlights realtime, and their shadows - qboolean rtworld; - qboolean rtworldshadows; - qboolean rtdlight; - qboolean rtdlightshadows; float polygonfactor; float polygonoffset; float shadowpolygonfactor; diff --git a/gl_rmain.c b/gl_rmain.c index 810b84b1..1f59f2cb 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -1684,7 +1684,7 @@ void R_SetupSurfaceShader(const vec3_t lightcolorbase, qboolean modellighting, f } else { - if (r_glsl_permutation->loc_AmbientScale >= 0) qglUniform1fARB(r_glsl_permutation->loc_AmbientScale, r_ambient.value * 1.0f / 128.0f); + if (r_glsl_permutation->loc_AmbientScale >= 0) qglUniform1fARB(r_glsl_permutation->loc_AmbientScale, r_refdef.scene.ambient * 1.0f / 128.0f); if (r_glsl_permutation->loc_DiffuseScale >= 0) qglUniform1fARB(r_glsl_permutation->loc_DiffuseScale, r_refdef.lightmapintensity); if (r_glsl_permutation->loc_SpecularScale >= 0) qglUniform1fARB(r_glsl_permutation->loc_SpecularScale, r_refdef.lightmapintensity * specularscale); } @@ -2763,7 +2763,7 @@ void R_SetupView(qboolean allowwaterclippingplane) { if (!r_refdef.view.useperspective) GL_SetupView_Mode_Ortho(-r_refdef.view.ortho_x, -r_refdef.view.ortho_y, r_refdef.view.ortho_x, r_refdef.view.ortho_y, -r_refdef.farclip, r_refdef.farclip); - else if (r_refdef.rtworldshadows || r_refdef.rtdlightshadows) + else if (r_refdef.scene.rtworldshadows || r_refdef.scene.rtdlightshadows) GL_SetupView_Mode_PerspectiveInfiniteFarClip(r_refdef.view.frustum_x, r_refdef.view.frustum_y, r_refdef.nearclip); else GL_SetupView_Mode_Perspective(r_refdef.view.frustum_x, r_refdef.view.frustum_y, r_refdef.nearclip, r_refdef.farclip); @@ -3528,6 +3528,8 @@ void R_UpdateVariables(void) { R_Textures_Frame(); + r_refdef.scene.ambient = r_ambient.value; + r_refdef.farclip = 4096; if (r_refdef.scene.worldmodel) r_refdef.farclip += VectorDistance(r_refdef.scene.worldmodel->normalmins, r_refdef.scene.worldmodel->normalmaxs); @@ -3540,17 +3542,17 @@ void R_UpdateVariables(void) r_refdef.shadowpolygonfactor = r_refdef.polygonfactor + r_shadow_polygonfactor.value * (r_shadow_frontsidecasting.integer ? 1 : -1); r_refdef.shadowpolygonoffset = r_refdef.polygonoffset + r_shadow_polygonoffset.value * (r_shadow_frontsidecasting.integer ? 1 : -1); - r_refdef.rtworld = r_shadow_realtime_world.integer; - r_refdef.rtworldshadows = r_shadow_realtime_world_shadows.integer && gl_stencil; - r_refdef.rtdlight = (r_shadow_realtime_world.integer || r_shadow_realtime_dlight.integer) && !gl_flashblend.integer && r_dynamic.integer; - r_refdef.rtdlightshadows = r_refdef.rtdlight && r_shadow_realtime_dlight_shadows.integer && gl_stencil; - r_refdef.lightmapintensity = r_refdef.rtworld ? r_shadow_realtime_world_lightmaps.value : 1; + r_refdef.scene.rtworld = r_shadow_realtime_world.integer; + r_refdef.scene.rtworldshadows = r_shadow_realtime_world_shadows.integer && gl_stencil; + r_refdef.scene.rtdlight = (r_shadow_realtime_world.integer || r_shadow_realtime_dlight.integer) && !gl_flashblend.integer && r_dynamic.integer; + r_refdef.scene.rtdlightshadows = r_refdef.scene.rtdlight && r_shadow_realtime_dlight_shadows.integer && gl_stencil; + r_refdef.lightmapintensity = r_refdef.scene.rtworld ? r_shadow_realtime_world_lightmaps.value : 1; if (r_showsurfaces.integer) { - r_refdef.rtworld = false; - r_refdef.rtworldshadows = false; - r_refdef.rtdlight = false; - r_refdef.rtdlightshadows = false; + r_refdef.scene.rtworld = false; + r_refdef.scene.rtworldshadows = false; + r_refdef.scene.rtdlight = false; + r_refdef.scene.rtdlightshadows = false; r_refdef.lightmapintensity = 0; } @@ -4632,7 +4634,7 @@ void R_UpdateTextureInfo(const entity_render_t *ent, texture_t *t) if (ent->model->type == mod_brushq3) colorscale *= r_refdef.scene.rtlightstylevalue[0]; colorscale *= r_refdef.lightmapintensity; - VectorScale(t->lightmapcolor, r_ambient.value * (1.0f / 64.0f), ambientcolor); + VectorScale(t->lightmapcolor, r_refdef.scene.ambient * (1.0f / 64.0f), ambientcolor); VectorScale(t->lightmapcolor, colorscale, t->lightmapcolor); // basic lit geometry R_Texture_AddLayer(t, depthmask, blendfunc1, blendfunc2, TEXTURELAYERTYPE_LITTEXTURE, t->basetexture, &t->currenttexmatrix, t->lightmapcolor[0], t->lightmapcolor[1], t->lightmapcolor[2], t->lightmapcolor[3]); diff --git a/mvm_cmds.c b/mvm_cmds.c index 80d238c0..c92d5c27 100644 --- a/mvm_cmds.c +++ b/mvm_cmds.c @@ -1432,6 +1432,8 @@ void VM_M_Cmd_Init(void) scene->maxentities = MAX_EDICTS + 256 + 512; scene->entities = (entity_render_t **)Mem_Alloc(prog->progs_mempool, sizeof(entity_render_t *) * scene->maxentities); + + scene->ambient = 32.0f; } void VM_M_Cmd_Reset(void) diff --git a/r_shadow.c b/r_shadow.c index d9da45c1..d0bba737 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -3028,7 +3028,7 @@ void R_DrawRTLight(rtlight_t *rtlight, qboolean visible) // count this light in the r_speeds r_refdef.stats.lights++; - if (r_showshadowvolumes.integer && r_refdef.view.showdebug && numsurfaces + numshadowentities + numshadowentities_noselfshadow && rtlight->shadow && (rtlight->isstatic ? r_refdef.rtworldshadows : r_refdef.rtdlightshadows)) + if (r_showshadowvolumes.integer && r_refdef.view.showdebug && numsurfaces + numshadowentities + numshadowentities_noselfshadow && rtlight->shadow && (rtlight->isstatic ? r_refdef.scene.rtworldshadows : r_refdef.scene.rtdlightshadows)) { // optionally draw visible shape of the shadow volumes // for performance analysis by level designers @@ -3041,7 +3041,7 @@ void R_DrawRTLight(rtlight_t *rtlight, qboolean visible) R_Shadow_DrawEntityShadow(shadowentities_noselfshadow[i]); } - if (gl_stencil && numsurfaces + numshadowentities + numshadowentities_noselfshadow && rtlight->shadow && (rtlight->isstatic ? r_refdef.rtworldshadows : r_refdef.rtdlightshadows)) + if (gl_stencil && numsurfaces + numshadowentities + numshadowentities_noselfshadow && rtlight->shadow && (rtlight->isstatic ? r_refdef.scene.rtworldshadows : r_refdef.scene.rtdlightshadows)) { // draw stencil shadow volumes to mask off pixels that are in shadow // so that they won't receive lighting @@ -3134,7 +3134,7 @@ void R_ShadowVolumeLighting(qboolean visible) R_Shadow_RenderMode_Begin(); - flag = r_refdef.rtworld ? LIGHTFLAG_REALTIMEMODE : LIGHTFLAG_NORMALMODE; + flag = r_refdef.scene.rtworld ? LIGHTFLAG_REALTIMEMODE : LIGHTFLAG_NORMALMODE; if (r_shadow_debuglight.integer >= 0) { lightindex = r_shadow_debuglight.integer; @@ -3151,7 +3151,7 @@ void R_ShadowVolumeLighting(qboolean visible) R_DrawRTLight(&light->rtlight, visible); } } - if (r_refdef.rtdlight) + if (r_refdef.scene.rtdlight) for (lnum = 0;lnum < r_refdef.scene.numlights;lnum++) R_DrawRTLight(&r_refdef.scene.lights[lnum], visible); @@ -3256,7 +3256,7 @@ void R_DrawCoronas(void) if (r_coronas.value < (1.0f / 256.0f) && !gl_flashblend.integer) return; R_Mesh_Matrix(&identitymatrix); - flag = r_refdef.rtworld ? LIGHTFLAG_REALTIMEMODE : LIGHTFLAG_NORMALMODE; + flag = r_refdef.scene.rtworld ? LIGHTFLAG_REALTIMEMODE : LIGHTFLAG_NORMALMODE; // FIXME: these traces should scan all render entities instead of cl.world for (lightindex = 0;lightindex < Mem_ExpandableArray_IndexRange(&r_shadow_worldlightsarray);lightindex++) { @@ -4672,7 +4672,7 @@ void R_CompleteLightPoint(vec3_t ambientcolor, vec3_t diffusecolor, vec3_t diffu if (!r_fullbright.integer && r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->brush.LightPoint) { - ambientcolor[0] = ambientcolor[1] = ambientcolor[2] = r_ambient.value * (2.0f / 128.0f); + ambientcolor[0] = ambientcolor[1] = ambientcolor[2] = r_refdef.scene.ambient * (2.0f / 128.0f); r_refdef.scene.worldmodel->brush.LightPoint(r_refdef.scene.worldmodel, p, ambientcolor, diffusecolor, diffusenormal); } else -- 2.39.2