]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
added deluxemapping (per pixel lighting using lightmaps in specially compiled q3bsp...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 17 Mar 2006 07:49:01 +0000 (07:49 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 17 Mar 2006 07:49:01 +0000 (07:49 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6130 d7cf8633-e32d-0410-b094-e92efae38249

gl_rmain.c
model_brush.c
model_shared.h
todo

index fb0295c14296e7aa7ccdd3273dd26377215e3267..57f17f315fdb96a34aaeb4ed59c2c77dad025961 100644 (file)
@@ -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);
index 47cf815d4dff80942a594ecc821c80bc13c743e6..000746415b88427715d347c46d0a41180fe21ec1 100644 (file)
@@ -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);
index 422b3c4cdbcc369e575c69dfd9220663024c5d7a..0ee9735964a7b90f3c547292c38510283d717b4e 100644 (file)
@@ -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 5587f644118582bd89c5cc141401d52a8d02fea8..ab8779561fa24ca17b8646611d47e5fa0e1e4397 100644 (file)
--- 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)