From: havoc Date: Fri, 17 Mar 2006 07:49:01 +0000 (+0000) Subject: added deluxemapping (per pixel lighting using lightmaps in specially compiled q3bsp... X-Git-Tag: xonotic-v0.1.0preview~4189 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=875c1aa1a2744ba68cc4afcedd299b7f7a320481;p=xonotic%2Fdarkplaces.git added deluxemapping (per pixel lighting using lightmaps in specially compiled q3bsp maps) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6130 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/gl_rmain.c b/gl_rmain.c index fb0295c1..57f17f31 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -887,7 +887,7 @@ void R_SetupSurfaceShader(const entity_render_t *ent, const texture_t *texture, if (texture->skin.glow) permutation |= SHADERPERMUTATION_GLOW; } - else if (false) + else if (r_refdef.worldmodel && r_refdef.worldmodel->brushq3.deluxemapping) { permutation |= SHADERPERMUTATION_MODE_LIGHTDIRECTIONMAP; if (texture->skin.glow) @@ -949,14 +949,28 @@ void R_SetupSurfaceShader(const entity_render_t *ent, const texture_t *texture, } else if (permutation & SHADERPERMUTATION_MODE_LIGHTDIRECTION) { - if (r_glsl_permutation->loc_AmbientColor >= 0) - qglUniform3fARB(r_glsl_permutation->loc_AmbientColor, ent->modellight_ambient[0], ent->modellight_ambient[1], ent->modellight_ambient[2]); - if (r_glsl_permutation->loc_DiffuseColor >= 0) - qglUniform3fARB(r_glsl_permutation->loc_DiffuseColor, ent->modellight_diffuse[0], ent->modellight_diffuse[1], ent->modellight_diffuse[2]); - if (r_glsl_permutation->loc_SpecularColor >= 0) - qglUniform3fARB(r_glsl_permutation->loc_SpecularColor, ent->modellight_diffuse[0] * texture->specularscale, ent->modellight_diffuse[1] * texture->specularscale, ent->modellight_diffuse[2] * texture->specularscale); - if (r_glsl_permutation->loc_LightDir >= 0) - qglUniform3fARB(r_glsl_permutation->loc_LightDir, ent->modellight_lightdir[0], ent->modellight_lightdir[1], ent->modellight_lightdir[2]); + if (texture->currentmaterialflags & MATERIALFLAG_FULLBRIGHT) + { + if (r_glsl_permutation->loc_AmbientColor >= 0) + qglUniform3fARB(r_glsl_permutation->loc_AmbientColor, 1, 1, 1); + if (r_glsl_permutation->loc_DiffuseColor >= 0) + qglUniform3fARB(r_glsl_permutation->loc_DiffuseColor, 0, 0, 0); + if (r_glsl_permutation->loc_SpecularColor >= 0) + qglUniform3fARB(r_glsl_permutation->loc_SpecularColor, 0, 0, 0); + if (r_glsl_permutation->loc_LightDir >= 0) + qglUniform3fARB(r_glsl_permutation->loc_LightDir, 0, 0, -1); + } + else + { + if (r_glsl_permutation->loc_AmbientColor >= 0) + qglUniform3fARB(r_glsl_permutation->loc_AmbientColor, ent->modellight_ambient[0], ent->modellight_ambient[1], ent->modellight_ambient[2]); + if (r_glsl_permutation->loc_DiffuseColor >= 0) + qglUniform3fARB(r_glsl_permutation->loc_DiffuseColor, ent->modellight_diffuse[0], ent->modellight_diffuse[1], ent->modellight_diffuse[2]); + if (r_glsl_permutation->loc_SpecularColor >= 0) + qglUniform3fARB(r_glsl_permutation->loc_SpecularColor, ent->modellight_diffuse[0] * texture->specularscale, ent->modellight_diffuse[1] * texture->specularscale, ent->modellight_diffuse[2] * texture->specularscale); + if (r_glsl_permutation->loc_LightDir >= 0) + qglUniform3fARB(r_glsl_permutation->loc_LightDir, ent->modellight_lightdir[0], ent->modellight_lightdir[1], ent->modellight_lightdir[2]); + } } else { @@ -980,8 +994,20 @@ void R_SetupSurfaceShader(const entity_render_t *ent, const texture_t *texture, qglUniform3fARB(r_glsl_permutation->loc_FogColor, fogcolor[0], fogcolor[1], fogcolor[2]); } if (r_glsl_permutation->loc_EyePosition >= 0) qglUniform3fARB(r_glsl_permutation->loc_EyePosition, modelorg[0], modelorg[1], modelorg[2]); - if (r_glsl_permutation->loc_Color_Pants >= 0) qglUniform3fARB(r_glsl_permutation->loc_Color_Pants, ent->colormap_pantscolor[0], ent->colormap_pantscolor[1], ent->colormap_pantscolor[2]); - if (r_glsl_permutation->loc_Color_Shirt >= 0) qglUniform3fARB(r_glsl_permutation->loc_Color_Shirt, ent->colormap_shirtcolor[0], ent->colormap_shirtcolor[1], ent->colormap_shirtcolor[2]); + if (r_glsl_permutation->loc_Color_Pants >= 0) + { + if (texture->skin.pants) + qglUniform3fARB(r_glsl_permutation->loc_Color_Pants, ent->colormap_pantscolor[0], ent->colormap_pantscolor[1], ent->colormap_pantscolor[2]); + else + qglUniform3fARB(r_glsl_permutation->loc_Color_Pants, 0, 0, 0); + } + if (r_glsl_permutation->loc_Color_Shirt >= 0) + { + if (texture->skin.shirt) + qglUniform3fARB(r_glsl_permutation->loc_Color_Shirt, ent->colormap_shirtcolor[0], ent->colormap_shirtcolor[1], ent->colormap_shirtcolor[2]); + else + qglUniform3fARB(r_glsl_permutation->loc_Color_Shirt, 0, 0, 0); + } if (r_glsl_permutation->loc_FogRangeRecip >= 0) qglUniform1fARB(r_glsl_permutation->loc_FogRangeRecip, fograngerecip); if (r_glsl_permutation->loc_SpecularPower >= 0) qglUniform1fARB(r_glsl_permutation->loc_SpecularPower, texture->specularpower); if (r_glsl_permutation->loc_OffsetMapping_Scale >= 0) qglUniform1fARB(r_glsl_permutation->loc_OffsetMapping_Scale, r_glsl_offsetmapping_scale.value); diff --git a/model_brush.c b/model_brush.c index 47cf815d..00074641 100644 --- a/model_brush.c +++ b/model_brush.c @@ -4291,6 +4291,15 @@ static void Mod_Q3BSP_LoadLightmaps(lump_t *l) for (i = 0;i < count;i++, in++, out++) *out = R_LoadTexture2D(loadmodel->texturepool, va("lightmap%04i", i), 128, 128, in->rgb, TEXTYPE_RGB, TEXF_FORCELINEAR | TEXF_PRECACHE, NULL); + // deluxemapped bsp files have an even number of lightmaps, and surfaces + // always index even numbered ones (0, 2, 4, ...), the odd numbered + // lightmaps are the deluxemaps (light direction textures), so if we + // encounter any odd numbered lightmaps it is not a deluxemapped bsp, it + // is also not a deluxemapped bsp if it has an odd number of lightmaps or + // less than 2 + loadmodel->brushq3.deluxemapping = true; + if ((count & 1) || count < 2) + loadmodel->brushq3.deluxemapping = false; } static void Mod_Q3BSP_LoadFaces(lump_t *l) @@ -4369,7 +4378,14 @@ static void Mod_Q3BSP_LoadFaces(lump_t *l) if (n == -1) out->lightmaptexture = NULL; else + { + // deluxemapped q3bsp files have lightmaps and deluxemaps in + // pairs, no odd numbers ever appear, so if we encounter an + // odd lightmap index, it's not deluxemapped. + if (n & 1) + loadmodel->brushq3.deluxemapping = false; out->lightmaptexture = loadmodel->brushq3.data_lightmaps[n]; + } firstvertex = LittleLong(in->firstvertex); numvertices = LittleLong(in->numvertices); diff --git a/model_shared.h b/model_shared.h index 422b3c4c..0ee97359 100644 --- a/model_shared.h +++ b/model_shared.h @@ -477,6 +477,11 @@ typedef struct model_brushq3_s int num_lightgrid_dimensions[3]; // transform modelspace coordinates to lightgrid index matrix4x4_t num_lightgrid_indexfromworld; + + // true if this q3bsp file has been detected as using deluxemapping + // (lightmap texture pairs, every odd one is never directly refernced, + // and contains lighting normals, not colors) + qboolean deluxemapping; } model_brushq3_t; diff --git a/todo b/todo index 5587f644..ab877956 100644 --- a/todo +++ b/todo @@ -38,6 +38,7 @@ -d (yummyluv) feature darkplaces protocol: add buttons 9-16 (yummyluv) -f (James D) bug darkplaces server: losing runes on episode completion, completing episode 1 then 2 then 3 causes it to forget 1, then 4 causes it to forget 2 and 3, making it impossible to open the boss gate (James D) -f (Wazat) bug darkplaces: client's slowmo detection (measuring packet times and comparing to game time changes) may be making the game unpleasant (Wazat) +0 bug darkplaces renderer: r_glsl 1 mode has black grapple beam in nexuiz (SavageX) 0 bug darkplaces client: GAME_NEHAHRA: make sure cutscenes and movies work, got a report of seeing a black screen (NightFright) 0 bug darkplaces client: cl.sfx sounds aren't playing (romi) 0 bug darkplaces client: cl_movement 0 shouldn't be doing an input replay (SavageX)