From d9c2443445df49c61e0107ebcb7e5dc06d978b6c Mon Sep 17 00:00:00 2001 From: havoc Date: Fri, 24 Nov 2006 20:32:54 +0000 Subject: [PATCH] added proper support for q3 shader animmap commands git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6625 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rmain.c | 54 ++++++++++++++++++++++------------------- gl_rsurf.c | 6 ++--- model_alias.c | 28 ++++++++++++---------- model_brush.c | 65 ++++++++++++++++++++++++++++++++++---------------- model_shared.h | 9 +++++-- model_sprite.c | 62 +++++++++++++++++++++++++++-------------------- model_sprite.h | 2 +- r_shadow.c | 20 ++++++++-------- r_sprites.c | 7 +++--- todo | 1 + 10 files changed, 150 insertions(+), 104 deletions(-) diff --git a/gl_rmain.c b/gl_rmain.c index b43d6656..5d98fae9 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -804,7 +804,7 @@ int R_SetupSurfaceShader(const vec3_t lightcolorbase, qboolean modellighting) permutation |= SHADERPERMUTATION_MODE_LIGHTDIRECTIONMAP_TANGENTSPACE; } } - if (rsurface_texture->skin.glow) + if (rsurface_texture->currentskinframe->glow) permutation |= SHADERPERMUTATION_GLOW; } if (specularscale > 0) @@ -872,16 +872,16 @@ int R_SetupSurfaceShader(const vec3_t lightcolorbase, qboolean modellighting) if (r_glsl_permutation->loc_DiffuseScale >= 0) qglUniform1fARB(r_glsl_permutation->loc_DiffuseScale, r_refdef.lightmapintensity * 2.0f); if (r_glsl_permutation->loc_SpecularScale >= 0) qglUniform1fARB(r_glsl_permutation->loc_SpecularScale, r_refdef.lightmapintensity * specularscale * 2.0f); } - if (r_glsl_permutation->loc_Texture_Normal >= 0) R_Mesh_TexBind(0, R_GetTexture(rsurface_texture->skin.nmap)); + if (r_glsl_permutation->loc_Texture_Normal >= 0) R_Mesh_TexBind(0, R_GetTexture(rsurface_texture->currentskinframe->nmap)); if (r_glsl_permutation->loc_Texture_Color >= 0) R_Mesh_TexBind(1, R_GetTexture(rsurface_texture->basetexture)); if (r_glsl_permutation->loc_Texture_Gloss >= 0) R_Mesh_TexBind(2, R_GetTexture(rsurface_texture->glosstexture)); //if (r_glsl_permutation->loc_Texture_Cube >= 0 && permutation & SHADERPERMUTATION_MODE_LIGHTSOURCE) R_Mesh_TexBindCubeMap(3, R_GetTexture(r_shadow_rtlight->currentcubemap)); if (r_glsl_permutation->loc_Texture_FogMask >= 0) R_Mesh_TexBind(4, R_GetTexture(r_texture_fogattenuation)); - if (r_glsl_permutation->loc_Texture_Pants >= 0) R_Mesh_TexBind(5, R_GetTexture(rsurface_texture->skin.pants)); - if (r_glsl_permutation->loc_Texture_Shirt >= 0) R_Mesh_TexBind(6, R_GetTexture(rsurface_texture->skin.shirt)); + if (r_glsl_permutation->loc_Texture_Pants >= 0) R_Mesh_TexBind(5, R_GetTexture(rsurface_texture->currentskinframe->pants)); + if (r_glsl_permutation->loc_Texture_Shirt >= 0) R_Mesh_TexBind(6, R_GetTexture(rsurface_texture->currentskinframe->shirt)); //if (r_glsl_permutation->loc_Texture_Lightmap >= 0) R_Mesh_TexBind(7, R_GetTexture(r_texture_white)); //if (r_glsl_permutation->loc_Texture_Deluxemap >= 0) R_Mesh_TexBind(8, R_GetTexture(r_texture_blanknormalmap)); - if (r_glsl_permutation->loc_Texture_Glow >= 0) R_Mesh_TexBind(9, R_GetTexture(rsurface_texture->skin.glow)); + if (r_glsl_permutation->loc_Texture_Glow >= 0) R_Mesh_TexBind(9, R_GetTexture(rsurface_texture->currentskinframe->glow)); if (r_glsl_permutation->loc_GlowScale >= 0) qglUniform1fARB(r_glsl_permutation->loc_GlowScale, r_hdr_glowintensity.value); if (r_glsl_permutation->loc_SceneBrightness >= 0) qglUniform1fARB(r_glsl_permutation->loc_SceneBrightness, r_view.colorscale); if (r_glsl_permutation->loc_FogColor >= 0) @@ -895,14 +895,14 @@ int R_SetupSurfaceShader(const vec3_t lightcolorbase, qboolean modellighting) if (r_glsl_permutation->loc_EyePosition >= 0) qglUniform3fARB(r_glsl_permutation->loc_EyePosition, rsurface_modelorg[0], rsurface_modelorg[1], rsurface_modelorg[2]); if (r_glsl_permutation->loc_Color_Pants >= 0) { - if (rsurface_texture->skin.pants) + if (rsurface_texture->currentskinframe->pants) qglUniform3fARB(r_glsl_permutation->loc_Color_Pants, rsurface_entity->colormap_pantscolor[0], rsurface_entity->colormap_pantscolor[1], rsurface_entity->colormap_pantscolor[2]); else qglUniform3fARB(r_glsl_permutation->loc_Color_Pants, 0, 0, 0); } if (r_glsl_permutation->loc_Color_Shirt >= 0) { - if (rsurface_texture->skin.shirt) + if (rsurface_texture->currentskinframe->shirt) qglUniform3fARB(r_glsl_permutation->loc_Color_Shirt, rsurface_entity->colormap_shirtcolor[0], rsurface_entity->colormap_shirtcolor[1], rsurface_entity->colormap_shirtcolor[2]); else qglUniform3fARB(r_glsl_permutation->loc_Color_Shirt, 0, 0, 0); @@ -2326,6 +2326,7 @@ void R_UpdateTextureInfo(const entity_render_t *ent, texture_t *t) // FIXME: identify models using a better check than ent->model->brush.shadowmesh //int lightmode = ((ent->effects & EF_FULLBRIGHT) || ent->model->brush.shadowmesh) ? 0 : 2; + // switch to an alternate material if this is a q1bsp animated material { texture_t *texture = t; model_t *model = ent->model; @@ -2353,6 +2354,10 @@ void R_UpdateTextureInfo(const entity_render_t *ent, texture_t *t) texture->currentframe = t; } + // pick a new currentskinframe if the material is animated + if (t->numskinframes >= 2) + t->currentskinframe = t->skinframes + ((int)(t->skinframerate * (cl.time - ent->frame2time)) % t->numskinframes); + t->currentmaterialflags = t->basematerialflags; t->currentalpha = ent->alpha; if (t->basematerialflags & MATERIALFLAG_WATERALPHA) @@ -2371,17 +2376,17 @@ void R_UpdateTextureInfo(const entity_render_t *ent, texture_t *t) t->currenttexmatrix = identitymatrix; t->colormapping = VectorLength2(ent->colormap_pantscolor) + VectorLength2(ent->colormap_shirtcolor) >= (1.0f / 1048576.0f); - t->basetexture = (!t->colormapping && t->skin.merged) ? t->skin.merged : t->skin.base; + t->basetexture = (!t->colormapping && t->currentskinframe->merged) ? t->currentskinframe->merged : t->currentskinframe->base; t->glosstexture = r_texture_white; t->specularpower = 8; t->specularscale = 0; if (r_shadow_gloss.integer > 0) { - if (t->skin.gloss) + if (t->currentskinframe->gloss) { if (r_shadow_glossintensity.value > 0) { - t->glosstexture = t->skin.gloss; + t->glosstexture = t->currentskinframe->gloss; t->specularscale = r_shadow_glossintensity.value; } } @@ -2424,15 +2429,15 @@ void R_UpdateTextureInfo(const entity_render_t *ent, texture_t *t) int layerflags = 0; if (r_refdef.fogenabled && (t->currentmaterialflags & MATERIALFLAG_BLENDED)) layerflags |= TEXTURELAYERFLAG_FOGDARKEN; - currentbasetexture = (VectorLength2(ent->colormap_pantscolor) + VectorLength2(ent->colormap_shirtcolor) < (1.0f / 1048576.0f) && t->skin.merged) ? t->skin.merged : t->skin.base; + currentbasetexture = (VectorLength2(ent->colormap_pantscolor) + VectorLength2(ent->colormap_shirtcolor) < (1.0f / 1048576.0f) && t->currentskinframe->merged) ? t->currentskinframe->merged : t->currentskinframe->base; if (t->currentmaterialflags & MATERIALFLAG_FULLBRIGHT) { // fullbright is not affected by r_refdef.lightmapintensity R_Texture_AddLayer(t, depthmask, blendfunc1, blendfunc2, TEXTURELAYERTYPE_TEXTURE, currentbasetexture, &t->currenttexmatrix, ent->colormod[0], ent->colormod[1], ent->colormod[2], t->currentalpha); - if (VectorLength2(ent->colormap_pantscolor) >= (1.0f / 1048576.0f) && t->skin.pants) - R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_TEXTURE, t->skin.pants, &t->currenttexmatrix, ent->colormap_pantscolor[0] * ent->colormod[0], ent->colormap_pantscolor[1] * ent->colormod[1], ent->colormap_pantscolor[2] * ent->colormod[2], t->currentalpha); - if (VectorLength2(ent->colormap_shirtcolor) >= (1.0f / 1048576.0f) && t->skin.shirt) - R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_TEXTURE, t->skin.shirt, &t->currenttexmatrix, ent->colormap_shirtcolor[0] * ent->colormod[0], ent->colormap_shirtcolor[1] * ent->colormod[1], ent->colormap_shirtcolor[2] * ent->colormod[2], t->currentalpha); + if (VectorLength2(ent->colormap_pantscolor) >= (1.0f / 1048576.0f) && t->currentskinframe->pants) + R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_TEXTURE, t->currentskinframe->pants, &t->currenttexmatrix, ent->colormap_pantscolor[0] * ent->colormod[0], ent->colormap_pantscolor[1] * ent->colormod[1], ent->colormap_pantscolor[2] * ent->colormod[2], t->currentalpha); + if (VectorLength2(ent->colormap_shirtcolor) >= (1.0f / 1048576.0f) && t->currentskinframe->shirt) + R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_TEXTURE, t->currentskinframe->shirt, &t->currenttexmatrix, ent->colormap_shirtcolor[0] * ent->colormod[0], ent->colormap_shirtcolor[1] * ent->colormod[1], ent->colormap_shirtcolor[2] * ent->colormod[2], t->currentalpha); } else { @@ -2447,21 +2452,21 @@ void R_UpdateTextureInfo(const entity_render_t *ent, texture_t *t) R_Texture_AddLayer(t, depthmask, blendfunc1, blendfunc2, TEXTURELAYERTYPE_LITTEXTURE, currentbasetexture, &t->currenttexmatrix, ent->colormod[0] * colorscale, ent->colormod[1] * colorscale, ent->colormod[2] * colorscale, t->currentalpha); if (r_ambient.value >= (1.0f/64.0f)) R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_TEXTURE, currentbasetexture, &t->currenttexmatrix, ent->colormod[0] * r_ambient.value * (1.0f / 64.0f), ent->colormod[1] * r_ambient.value * (1.0f / 64.0f), ent->colormod[2] * r_ambient.value * (1.0f / 64.0f), t->currentalpha); - if (VectorLength2(ent->colormap_pantscolor) >= (1.0f / 1048576.0f) && t->skin.pants) + if (VectorLength2(ent->colormap_pantscolor) >= (1.0f / 1048576.0f) && t->currentskinframe->pants) { - R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_LITTEXTURE, t->skin.pants, &t->currenttexmatrix, ent->colormap_pantscolor[0] * ent->colormod[0] * colorscale, ent->colormap_pantscolor[1] * ent->colormod[1] * colorscale, ent->colormap_pantscolor[2] * ent->colormod[2] * colorscale, t->currentalpha); + R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_LITTEXTURE, t->currentskinframe->pants, &t->currenttexmatrix, ent->colormap_pantscolor[0] * ent->colormod[0] * colorscale, ent->colormap_pantscolor[1] * ent->colormod[1] * colorscale, ent->colormap_pantscolor[2] * ent->colormod[2] * colorscale, t->currentalpha); if (r_ambient.value >= (1.0f/64.0f)) - R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_TEXTURE, t->skin.pants, &t->currenttexmatrix, ent->colormap_pantscolor[0] * ent->colormod[0] * r_ambient.value * (1.0f / 64.0f), ent->colormap_pantscolor[1] * ent->colormod[1] * r_ambient.value * (1.0f / 64.0f), ent->colormap_pantscolor[2] * ent->colormod[2] * r_ambient.value * (1.0f / 64.0f), t->currentalpha); + R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_TEXTURE, t->currentskinframe->pants, &t->currenttexmatrix, ent->colormap_pantscolor[0] * ent->colormod[0] * r_ambient.value * (1.0f / 64.0f), ent->colormap_pantscolor[1] * ent->colormod[1] * r_ambient.value * (1.0f / 64.0f), ent->colormap_pantscolor[2] * ent->colormod[2] * r_ambient.value * (1.0f / 64.0f), t->currentalpha); } - if (VectorLength2(ent->colormap_shirtcolor) >= (1.0f / 1048576.0f) && t->skin.shirt) + if (VectorLength2(ent->colormap_shirtcolor) >= (1.0f / 1048576.0f) && t->currentskinframe->shirt) { - R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_LITTEXTURE, t->skin.shirt, &t->currenttexmatrix, ent->colormap_shirtcolor[0] * ent->colormod[0] * colorscale, ent->colormap_shirtcolor[1] * ent->colormod[1] * colorscale, ent->colormap_shirtcolor[2] * ent->colormod[2] * colorscale, t->currentalpha); + R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_LITTEXTURE, t->currentskinframe->shirt, &t->currenttexmatrix, ent->colormap_shirtcolor[0] * ent->colormod[0] * colorscale, ent->colormap_shirtcolor[1] * ent->colormod[1] * colorscale, ent->colormap_shirtcolor[2] * ent->colormod[2] * colorscale, t->currentalpha); if (r_ambient.value >= (1.0f/64.0f)) - R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_TEXTURE, t->skin.shirt, &t->currenttexmatrix, ent->colormap_shirtcolor[0] * ent->colormod[0] * r_ambient.value * (1.0f / 64.0f), ent->colormap_shirtcolor[1] * ent->colormod[1] * r_ambient.value * (1.0f / 64.0f), ent->colormap_shirtcolor[2] * ent->colormod[2] * r_ambient.value * (1.0f / 64.0f), t->currentalpha); + R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_TEXTURE, t->currentskinframe->shirt, &t->currenttexmatrix, ent->colormap_shirtcolor[0] * ent->colormod[0] * r_ambient.value * (1.0f / 64.0f), ent->colormap_shirtcolor[1] * ent->colormod[1] * r_ambient.value * (1.0f / 64.0f), ent->colormap_shirtcolor[2] * ent->colormod[2] * r_ambient.value * (1.0f / 64.0f), t->currentalpha); } } - if (t->skin.glow != NULL) - R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_TEXTURE, t->skin.glow, &t->currenttexmatrix, r_hdr_glowintensity.value, r_hdr_glowintensity.value, r_hdr_glowintensity.value, t->currentalpha); + if (t->currentskinframe->glow != NULL) + R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_TEXTURE, t->currentskinframe->glow, &t->currenttexmatrix, r_hdr_glowintensity.value, r_hdr_glowintensity.value, r_hdr_glowintensity.value, t->currentalpha); if (r_refdef.fogenabled && !(t->currentmaterialflags & MATERIALFLAG_ADD)) { // if this is opaque use alpha blend which will darken the earlier @@ -2475,7 +2480,7 @@ void R_UpdateTextureInfo(const entity_render_t *ent, texture_t *t) // were darkened by fog already, and we should not add fog color // (because the background was not darkened, there is no fog color // that was lost behind it). - R_Texture_AddLayer(t, false, GL_SRC_ALPHA, (t->currentmaterialflags & MATERIALFLAG_BLENDED) ? GL_ONE : GL_ONE_MINUS_SRC_ALPHA, TEXTURELAYERTYPE_FOG, t->skin.fog, &identitymatrix, r_refdef.fogcolor[0], r_refdef.fogcolor[1], r_refdef.fogcolor[2], t->currentalpha); + R_Texture_AddLayer(t, false, GL_SRC_ALPHA, (t->currentmaterialflags & MATERIALFLAG_BLENDED) ? GL_ONE : GL_ONE_MINUS_SRC_ALPHA, TEXTURELAYERTYPE_FOG, t->currentskinframe->fog, &identitymatrix, r_refdef.fogcolor[0], r_refdef.fogcolor[1], r_refdef.fogcolor[2], t->currentalpha); } } } @@ -3619,4 +3624,3 @@ void R_DrawSurfaces(entity_render_t *ent, qboolean skysurfaces) } } } - diff --git a/gl_rsurf.c b/gl_rsurf.c index 0a083abc..e8626a04 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -903,7 +903,7 @@ void R_ReplaceWorldTexture (void) { if(t->width && !strcasecmp(t->name, r)) { - if(Mod_LoadSkinFrame(&t->skin, (char*)newt, TEXF_MIPMAP | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP, false, r_fullbrights.integer)) + if(Mod_LoadSkinFrame(&t->skinframes[0], (char*)newt, TEXF_MIPMAP | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP, false, r_fullbrights.integer)) { Con_Printf("%s replaced with %s\n", r, newt); return; @@ -911,7 +911,7 @@ void R_ReplaceWorldTexture (void) else { Con_Printf("%s was not found\n", newt); - Mod_LoadSkinFrame(&t->skin, (char*)r, TEXF_MIPMAP | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP, false, r_fullbrights.integer);//back to default + Mod_LoadSkinFrame(&t->skinframes[0], (char*)r, TEXF_MIPMAP | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP, false, r_fullbrights.integer);//back to default return; } } @@ -928,7 +928,7 @@ void R_ListWorldTextures (void) Con_Print("Worldmodel textures :\n"); for(i=0,t=m->data_textures;inum_textures;i++,t++) - if(t->skin.base != r_texture_notexture) + if (t->numskinframes) Con_Printf("%s\n", t->name); } diff --git a/model_alias.c b/model_alias.c index 54054371..12462f9e 100644 --- a/model_alias.c +++ b/model_alias.c @@ -561,23 +561,25 @@ static void Mod_MDL_LoadFrames (unsigned char* datapointer, int inverts, int *ve } } -static skinframe_t missingskinframe; -static void Mod_BuildAliasSkinFromSkinFrame(texture_t *skin, skinframe_t *skinframe) +static void Mod_BuildAliasSkinFromSkinFrame(texture_t *texture, skinframe_t *skinframe) { - // hack - if (skinframe == NULL) + texture->currentframe = texture; + texture->numskinframes = 1; + texture->skinframerate = 1; + texture->currentskinframe = texture->skinframes + 0; + if (skinframe) + texture->skinframes[0] = *skinframe; + else { - skinframe = &missingskinframe; - memset(skinframe, 0, sizeof(*skinframe)); - skinframe->base = r_texture_notexture; + // hack + memset(texture->skinframes, 0, sizeof(texture->skinframes)); + texture->skinframes[0].base = r_texture_notexture; } - skin->skin = *skinframe; - skin->currentframe = skin; - skin->basematerialflags = MATERIALFLAG_WALL; - if (skin->skin.fog) - skin->basematerialflags |= MATERIALFLAG_ALPHA | MATERIALFLAG_BLENDED | MATERIALFLAG_TRANSPARENT; - skin->currentmaterialflags = skin->basematerialflags; + texture->basematerialflags = MATERIALFLAG_WALL; + if (texture->currentskinframe->fog) + texture->basematerialflags |= MATERIALFLAG_ALPHA | MATERIALFLAG_BLENDED | MATERIALFLAG_TRANSPARENT; + texture->currentmaterialflags = texture->basematerialflags; } static void Mod_BuildAliasSkinsFromSkinFiles(texture_t *skin, skinfile_t *skinfile, char *meshname, char *shadername) diff --git a/model_brush.c b/model_brush.c index 203e8350..e644b225 100644 --- a/model_brush.c +++ b/model_brush.c @@ -1259,7 +1259,10 @@ static void Mod_Q1BSP_LoadTextures(lump_t *l) strlcpy(tx->name, "NO TEXTURE FOUND", sizeof(tx->name)); tx->width = 16; tx->height = 16; - tx->skin.base = r_texture_notexture; + tx->numskinframes = 1; + tx->skinframerate = 1; + tx->currentskinframe = tx->skinframes; + tx->skinframes[0].base = r_texture_notexture; tx->basematerialflags = 0; if (i == loadmodel->num_textures - 1) { @@ -1352,8 +1355,8 @@ static void Mod_Q1BSP_LoadTextures(lump_t *l) } else { - if (!Mod_LoadSkinFrame(&tx->skin, gamemode == GAME_TENEBRAE ? tx->name : va("textures/%s/%s", mapname, tx->name), TEXF_MIPMAP | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP, false, true) - && !Mod_LoadSkinFrame(&tx->skin, gamemode == GAME_TENEBRAE ? tx->name : va("textures/%s", tx->name), TEXF_MIPMAP | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP, false, true)) + if (!Mod_LoadSkinFrame(&tx->skinframes[0], gamemode == GAME_TENEBRAE ? tx->name : va("textures/%s/%s", mapname, tx->name), TEXF_MIPMAP | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP, false, true) + && !Mod_LoadSkinFrame(&tx->skinframes[0], gamemode == GAME_TENEBRAE ? tx->name : va("textures/%s", tx->name), TEXF_MIPMAP | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP, false, true)) { // did not find external texture, load it from the bsp or wad3 if (loadmodel->brush.ishlbsp) @@ -1369,21 +1372,21 @@ static void Mod_Q1BSP_LoadTextures(lump_t *l) { tx->width = image_width; tx->height = image_height; - Mod_LoadSkinFrame_Internal(&tx->skin, tx->name, TEXF_MIPMAP | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP, false, false, pixels, image_width, image_height, 32, NULL, NULL); + Mod_LoadSkinFrame_Internal(&tx->skinframes[0], tx->name, TEXF_MIPMAP | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP, false, false, pixels, image_width, image_height, 32, NULL, NULL); } if (freepixels) Mem_Free(freepixels); } else if (mtdata) // texture included - Mod_LoadSkinFrame_Internal(&tx->skin, tx->name, TEXF_MIPMAP | TEXF_PRECACHE | TEXF_PICMIP, false, r_fullbrights.integer, mtdata, tx->width, tx->height, 8, NULL, NULL); + Mod_LoadSkinFrame_Internal(&tx->skinframes[0], tx->name, TEXF_MIPMAP | TEXF_PRECACHE | TEXF_PICMIP, false, r_fullbrights.integer, mtdata, tx->width, tx->height, 8, NULL, NULL); } } - if (tx->skin.base == NULL) + if (tx->skinframes[0].base == NULL) { // no texture found tx->width = 16; tx->height = 16; - tx->skin.base = r_texture_notexture; + tx->skinframes[0].base = r_texture_notexture; } } @@ -1424,7 +1427,7 @@ static void Mod_Q1BSP_LoadTextures(lump_t *l) tx->surfaceflags = mod_q1bsp_texture_solid.surfaceflags; tx->basematerialflags |= MATERIALFLAG_WALL; } - if (tx->skin.fog) + if (tx->skinframes[0].fog) tx->basematerialflags |= MATERIALFLAG_ALPHA | MATERIALFLAG_BLENDED | MATERIALFLAG_TRANSPARENT; // start out with no animation @@ -3942,7 +3945,10 @@ static void Mod_Q3BSP_LoadEntities(lump_t *l) typedef struct q3shaderinfo_layer_s { - char texturename[Q3PATHLENGTH]; + int clampmap; + float framerate; + int numframes; + char texturename[TEXTURE_MAXFRAMES][Q3PATHLENGTH]; int blendfunc[2]; qboolean rgbgenvertex; qboolean alphagenvertex; @@ -3977,7 +3983,7 @@ static void Mod_Q3BSP_LoadShaders(void) q3shaderinfo_t *shader; q3shaderinfo_layer_t *layer; int numparameters; - char parameter[4][Q3PATHLENGTH]; + char parameter[TEXTURE_MAXFRAMES + 4][Q3PATHLENGTH]; search = FS_Search("scripts/*.shader", true, false); if (!search) return; @@ -4029,7 +4035,7 @@ static void Mod_Q3BSP_LoadShaders(void) numparameters = 0; for (j = 0;strcasecmp(com_token, "\n") && strcasecmp(com_token, "}");j++) { - if (j < 4) + if (j < TEXTURE_MAXFRAMES + 4) { strlcpy(parameter[j], com_token, sizeof(parameter[j])); numparameters = j + 1; @@ -4101,12 +4107,22 @@ static void Mod_Q3BSP_LoadShaders(void) } if (numparameters >= 2 && (!strcasecmp(parameter[0], "map") || !strcasecmp(parameter[0], "clampmap"))) { - strlcpy(layer->texturename, parameter[1], sizeof(layer->texturename)); + if (!strcasecmp(parameter[0], "clampmap")) + layer->clampmap = true; + layer->numframes = 1; + layer->framerate = 1; + strlcpy(layer->texturename[0], parameter[1], sizeof(layer->texturename)); if (!strcasecmp(parameter[1], "$lightmap")) shader->lighting = true; } - else if (numparameters >= 3 && !strcasecmp(parameter[0], "animmap")) - strlcpy(layer->texturename, parameter[2], sizeof(layer->texturename)); + else if (numparameters >= 3 && (!strcasecmp(parameter[0], "animmap") || !strcasecmp(parameter[0], "animclampmap"))) + { + int i; + layer->numframes = min(numparameters - 2, TEXTURE_MAXFRAMES); + layer->framerate = atoi(parameter[1]); + for (i = 0;i < layer->numframes;i++) + strlcpy(layer->texturename[i], parameter[i + 2], sizeof(layer->texturename)); + } else if (numparameters >= 2 && !strcasecmp(parameter[0], "rgbgen") && !strcasecmp(parameter[1], "vertex")) layer->rgbgenvertex = true; else if (numparameters >= 2 && !strcasecmp(parameter[0], "alphagen") && !strcasecmp(parameter[1], "vertex")) @@ -4262,7 +4278,7 @@ static void Mod_Q3BSP_LoadShaders(void) shader->primarylayer = shader->layers + 1; } // now see if the lightmap came first, and if so choose the second texture instead - if (!strcasecmp(shader->primarylayer->texturename, "$lightmap")) + if (!strcasecmp(shader->primarylayer->texturename[0], "$lightmap")) shader->primarylayer = shader->layers + 1; } } @@ -4372,9 +4388,15 @@ Q3 shader blendfuncs actually used in the game (* = supported by DP) } if (!shader->lighting) out->basematerialflags |= MATERIALFLAG_FULLBRIGHT; - if (cls.state != ca_dedicated) - if (shader->primarylayer && !Mod_LoadSkinFrame(&out->skin, shader->primarylayer->texturename, ((shader->surfaceparms & Q3SURFACEPARM_NOMIPMAPS) ? 0 : TEXF_MIPMAP) | TEXF_ALPHA | TEXF_PRECACHE | (shader->textureflags & Q3TEXTUREFLAG_NOPICMIP ? 0 : TEXF_PICMIP), false, true)) - Con_Printf("%s: could not load texture \"%s\" for shader \"%s\"\n", loadmodel->name, shader->primarylayer->texturename, out->name); + if (shader->primarylayer && cls.state != ca_dedicated) + { + int j; + out->numskinframes = shader->primarylayer->numframes; + out->skinframerate = shader->primarylayer->framerate; + for (j = 0;j < shader->primarylayer->numframes;j++) + if (!Mod_LoadSkinFrame(&out->skinframes[j], shader->primarylayer->texturename[j], ((shader->surfaceparms & Q3SURFACEPARM_NOMIPMAPS) ? 0 : TEXF_MIPMAP) | TEXF_ALPHA | TEXF_PRECACHE | (shader->textureflags & Q3TEXTUREFLAG_NOPICMIP ? 0 : TEXF_PICMIP) | (shader->primarylayer->clampmap ? TEXF_CLAMP : 0), false, true)) + Con_Printf("%s: could not load texture \"%s\" (frame %i) for shader \"%s\"\n", loadmodel->name, shader->primarylayer->texturename[j], j, out->name); + } } else { @@ -4393,14 +4415,15 @@ Q3 shader blendfuncs actually used in the game (* = supported by DP) //if (!strcmp(out->name, "caulk") || !strcmp(out->name, "common/caulk") || !strcmp(out->name, "textures/common/caulk") // || !strcmp(out->name, "nodraw") || !strcmp(out->name, "common/nodraw") || !strcmp(out->name, "textures/common/nodraw")) // out->surfaceparms |= Q3SURFACEPARM_NODRAW; - //if (R_TextureHasAlpha(out->skin.base)) + //if (R_TextureHasAlpha(out->skinframes[0].base)) // out->surfaceparms |= Q3SURFACEPARM_TRANS; if (cls.state != ca_dedicated) - if (!Mod_LoadSkinFrame(&out->skin, out->name, TEXF_MIPMAP | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP, false, true)) + if (!Mod_LoadSkinFrame(&out->skinframes[0], out->name, TEXF_MIPMAP | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP, false, true)) Con_Printf("%s: could not load texture for missing shader \"%s\"\n", loadmodel->name, out->name); } - // no animation + // init the animation variables out->currentframe = out; + out->currentskinframe = &out->skinframes[0]; } if (c) Con_DPrintf("%s: %i textures missing shaders\n", loadmodel->name, c); diff --git a/model_shared.h b/model_shared.h index 4b539e23..00eadd22 100644 --- a/model_shared.h +++ b/model_shared.h @@ -141,6 +141,8 @@ typedef struct shadowmesh_s } shadowmesh_t; +#define TEXTURE_MAXFRAMES 64 + typedef enum texturelayertype_e { TEXTURELAYERTYPE_INVALID, @@ -188,8 +190,11 @@ typedef struct texture_s // current material flags (updated each bmodel render) int currentmaterialflags; - // loaded the same as model skins - skinframe_t skin; + // textures to use when rendering this material + skinframe_t *currentskinframe; + int numskinframes; + float skinframerate; + skinframe_t skinframes[TEXTURE_MAXFRAMES]; // total frames in sequence and alternate sequence int anim_total[2]; diff --git a/model_sprite.c b/model_sprite.c index e833271e..4640a5a7 100644 --- a/model_sprite.c +++ b/model_sprite.c @@ -37,9 +37,23 @@ void Mod_SpriteInit (void) Cvar_RegisterVariable(&r_mipsprites); } -static void Mod_Sprite_SharedSetup(const unsigned char *datapointer, int version, const unsigned int *palette, const unsigned int *alphapalette) +static void Mod_SpriteSetupTexture(mspriteframe_t *frame, qboolean fullbright, qboolean additive) { - int i, j, groupframes, realframes, x, y, origin[2], width, height; + texture_t *texture = &frame->texture; + texture->basematerialflags = MATERIALFLAG_WALL; + if (fullbright) + texture->basematerialflags |= MATERIALFLAG_FULLBRIGHT; + if (additive) + texture->basematerialflags |= MATERIALFLAG_ADD | MATERIALFLAG_BLENDED | MATERIALFLAG_TRANSPARENT; + else if (texture->skinframes[0].fog) + texture->basematerialflags |= MATERIALFLAG_ALPHA | MATERIALFLAG_BLENDED | MATERIALFLAG_TRANSPARENT; + texture->currentmaterialflags = texture->basematerialflags; + texture->currentskinframe = texture->skinframes + 0; +} + +static void Mod_Sprite_SharedSetup(const unsigned char *datapointer, int version, const unsigned int *palette, const unsigned int *alphapalette, qboolean additive) +{ + int i, j, groupframes, realframes, x, y, origin[2], width, height, fullbright; dspriteframetype_t *pinframetype; dspriteframe_t *pinframe; dspritegroup_t *pingroup; @@ -53,14 +67,10 @@ static void Mod_Sprite_SharedSetup(const unsigned char *datapointer, int version Host_Error ("Mod_Sprite_SharedSetup: Invalid # of frames: %d", loadmodel->numframes); // LordHavoc: hack to allow sprites to be non-fullbright + fullbright = true; for (i = 0;i < MAX_QPATH && loadmodel->name[i];i++) - { if (loadmodel->name[i] == '!') - { - loadmodel->flags2 &= ~EF_FULLBRIGHT; - break; - } - } + fullbright = false; // // load the frames @@ -157,21 +167,23 @@ static void Mod_Sprite_SharedSetup(const unsigned char *datapointer, int version sprintf (name, "%s_%i_%i", loadmodel->name, i, j); else sprintf (name, "%s_%i", loadmodel->name, i); - Mod_LoadSkinFrame(&loadmodel->sprite.sprdata_frames[realframes].skin, name, (r_mipsprites.integer ? TEXF_MIPMAP : 0) | TEXF_ALPHA | TEXF_CLAMP | TEXF_PRECACHE | TEXF_PICMIP, false, false); + Mod_LoadSkinFrame(&loadmodel->sprite.sprdata_frames[realframes].texture.skinframes[0], name, (r_mipsprites.integer ? TEXF_MIPMAP : 0) | TEXF_ALPHA | TEXF_CLAMP | TEXF_PRECACHE | TEXF_PICMIP, false, false); - if (!loadmodel->sprite.sprdata_frames[realframes].skin.base) + if (!loadmodel->sprite.sprdata_frames[realframes].texture.skinframes[0].base) { if (groupframes > 1) sprintf (fogname, "%s_%i_%ifog", loadmodel->name, i, j); else sprintf (fogname, "%s_%ifog", loadmodel->name, i); if (version == SPRITE32_VERSION) - Mod_LoadSkinFrame_Internal(&loadmodel->sprite.sprdata_frames[realframes].skin, name, (r_mipsprites.integer ? TEXF_MIPMAP : 0) | TEXF_ALPHA | TEXF_CLAMP | TEXF_PRECACHE | TEXF_PICMIP, false, false, datapointer, width, height, 32, NULL, NULL); + Mod_LoadSkinFrame_Internal(&loadmodel->sprite.sprdata_frames[realframes].texture.skinframes[0], name, (r_mipsprites.integer ? TEXF_MIPMAP : 0) | TEXF_ALPHA | TEXF_CLAMP | TEXF_PRECACHE | TEXF_PICMIP, false, false, datapointer, width, height, 32, NULL, NULL); else //if (version == SPRITE_VERSION || version == SPRITEHL_VERSION) - Mod_LoadSkinFrame_Internal(&loadmodel->sprite.sprdata_frames[realframes].skin, name, (r_mipsprites.integer ? TEXF_MIPMAP : 0) | TEXF_ALPHA | TEXF_CLAMP | TEXF_PRECACHE | TEXF_PICMIP, false, false, datapointer, width, height, 8, palette, alphapalette); + Mod_LoadSkinFrame_Internal(&loadmodel->sprite.sprdata_frames[realframes].texture.skinframes[0], name, (r_mipsprites.integer ? TEXF_MIPMAP : 0) | TEXF_ALPHA | TEXF_CLAMP | TEXF_PRECACHE | TEXF_PICMIP, false, false, datapointer, width, height, 8, palette, alphapalette); } } + Mod_SpriteSetupTexture(&loadmodel->sprite.sprdata_frames[realframes], fullbright, additive); + if (version == SPRITE32_VERSION) datapointer += width * height * 4; else //if (version == SPRITE_VERSION || version == SPRITEHL_VERSION) @@ -219,7 +231,7 @@ void Mod_IDSP_Load(model_t *mod, void *buffer, void *bufferend) loadmodel->sprite.sprnum_type = LittleLong (pinqsprite->type); loadmodel->synctype = (synctype_t)LittleLong (pinqsprite->synctype); - Mod_Sprite_SharedSetup(datapointer, LittleLong (pinqsprite->version), NULL, NULL); + Mod_Sprite_SharedSetup(datapointer, LittleLong (pinqsprite->version), NULL, NULL, false); } else if (version == SPRITEHL_VERSION) { @@ -262,7 +274,7 @@ void Mod_IDSP_Load(model_t *mod, void *buffer, void *bufferend) palette[i][2] = *in++; palette[i][3] = 255; } - loadmodel->flags2 |= EF_ADDITIVE; + // also passes additive == true to Mod_Sprite_SharedSetup break; case SPRHL_INDEXALPHA: for (i = 0;i < 256;i++) @@ -283,6 +295,7 @@ void Mod_IDSP_Load(model_t *mod, void *buffer, void *bufferend) palette[i][3] = 255; } palette[255][0] = palette[255][1] = palette[255][2] = palette[255][3] = 0; + // should this use alpha test or alpha blend? (currently blend) break; default: Host_Error("Mod_IDSP_Load: unknown texFormat (%i, should be 0, 1, 2, or 3)", i); @@ -297,7 +310,7 @@ void Mod_IDSP_Load(model_t *mod, void *buffer, void *bufferend) alphapalette[i][3] = palette[i][3]; } - Mod_Sprite_SharedSetup(datapointer, LittleLong (pinhlsprite->version), (unsigned int *)(&palette[0][0]), (unsigned int *)(&alphapalette[0][0])); + Mod_Sprite_SharedSetup(datapointer, LittleLong (pinhlsprite->version), (unsigned int *)(&palette[0][0]), (unsigned int *)(&alphapalette[0][0]), rendermode == SPRHL_ADDITIVE); } else Host_Error("Mod_IDSP_Load: %s has wrong version number (%i). Only %i (quake), %i (HalfLife), and %i (sprite32) supported", @@ -307,12 +320,11 @@ void Mod_IDSP_Load(model_t *mod, void *buffer, void *bufferend) void Mod_IDS2_Load(model_t *mod, void *buffer, void *bufferend) { - int i, version; + int i, version, fullbright; const dsprite2_t *pinqsprite; float modelradius; loadmodel->type = mod_sprite; - loadmodel->flags2 = EF_FULLBRIGHT; loadmodel->DrawSky = NULL; loadmodel->Draw = R_Model_Sprite_Draw; @@ -332,15 +344,11 @@ void Mod_IDS2_Load(model_t *mod, void *buffer, void *bufferend) loadmodel->sprite.sprnum_type = SPR_VP_PARALLEL; loadmodel->synctype = ST_SYNC; - // Hack to allow sprites to be non-fullbright + // LordHavoc: hack to allow sprites to be non-fullbright + fullbright = true; for (i = 0;i < MAX_QPATH && loadmodel->name[i];i++) - { if (loadmodel->name[i] == '!') - { - loadmodel->flags2 &= ~EF_FULLBRIGHT; - break; - } - } + fullbright = false; loadmodel->animscenes = (animscene_t *)Mem_Alloc(loadmodel->mempool, sizeof(animscene_t) * loadmodel->numframes); loadmodel->sprite.sprdata_frames = (mspriteframe_t *)Mem_Alloc(loadmodel->mempool, sizeof(mspriteframe_t) * loadmodel->numframes); @@ -381,11 +389,13 @@ void Mod_IDS2_Load(model_t *mod, void *buffer, void *bufferend) if (width > 0 && height > 0 && cls.state != ca_dedicated) { - Mod_LoadSkinFrame(&sprframe->skin, pinframe->name, (r_mipsprites.integer ? TEXF_MIPMAP : 0) | TEXF_ALPHA | TEXF_CLAMP | TEXF_PRECACHE | TEXF_PICMIP, false, false); + Mod_LoadSkinFrame(&sprframe->texture.skinframes[0], pinframe->name, (r_mipsprites.integer ? TEXF_MIPMAP : 0) | TEXF_ALPHA | TEXF_CLAMP | TEXF_PRECACHE | TEXF_PICMIP, false, false); // TODO: use a default texture if we can't load it? - if (sprframe->skin.base == NULL) + if (sprframe->texture.skinframes[0].base == NULL) Host_Error("Mod_IDS2_Load: failed to load %s", pinframe->name); } + + Mod_SpriteSetupTexture(sprframe, fullbright, false); } modelradius = sqrt(modelradius); diff --git a/model_sprite.h b/model_sprite.h index e6df9e48..b21a8c94 100644 --- a/model_sprite.h +++ b/model_sprite.h @@ -35,7 +35,7 @@ SPRITE MODELS typedef struct mspriteframe_s { float up, down, left, right; - skinframe_t skin; + texture_t texture; } mspriteframe_t; #endif diff --git a/r_shadow.c b/r_shadow.c index f89bef9b..6ead8436 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -1968,8 +1968,8 @@ void R_Shadow_RenderSurfacesLighting(int numsurfaces, msurface_t **surfacelist) GL_CullFace(((rsurface_texture->textureflags & Q3TEXTUREFLAG_TWOSIDED) || (rsurface_entity->flags & RENDER_NOCULLFACE)) ? GL_NONE : GL_FRONT); // quake is backwards, this culls back faces if (rsurface_texture->colormapping) { - qboolean dopants = rsurface_texture->skin.pants != NULL && VectorLength2(rsurface_entity->colormap_pantscolor) >= (1.0f / 1048576.0f); - qboolean doshirt = rsurface_texture->skin.shirt != NULL && VectorLength2(rsurface_entity->colormap_shirtcolor) >= (1.0f / 1048576.0f); + qboolean dopants = rsurface_texture->currentskinframe->pants != NULL && VectorLength2(rsurface_entity->colormap_pantscolor) >= (1.0f / 1048576.0f); + qboolean doshirt = rsurface_texture->currentskinframe->shirt != NULL && VectorLength2(rsurface_entity->colormap_shirtcolor) >= (1.0f / 1048576.0f); if (dopants) { lightcolorpants[0] = lightcolorbase[0] * rsurface_entity->colormap_pantscolor[0]; @@ -1990,16 +1990,16 @@ void R_Shadow_RenderSurfacesLighting(int numsurfaces, msurface_t **surfacelist) { case R_SHADOW_RENDERMODE_VISIBLELIGHTING: GL_DepthTest(!(rsurface_texture->currentmaterialflags & MATERIALFLAG_NODEPTHTEST) && !r_showdisabledepthtest.integer); - R_Shadow_RenderSurfacesLighting_VisibleLighting(numsurfaces, surfacelist, lightcolorbase, lightcolorpants, lightcolorshirt, rsurface_texture->basetexture, rsurface_texture->skin.pants, rsurface_texture->skin.shirt, rsurface_texture->skin.nmap, rsurface_texture->glosstexture, r_shadow_rtlight->specularscale * rsurface_texture->specularscale, dopants, doshirt); + R_Shadow_RenderSurfacesLighting_VisibleLighting(numsurfaces, surfacelist, lightcolorbase, lightcolorpants, lightcolorshirt, rsurface_texture->basetexture, rsurface_texture->currentskinframe->pants, rsurface_texture->currentskinframe->shirt, rsurface_texture->currentskinframe->nmap, rsurface_texture->glosstexture, r_shadow_rtlight->specularscale * rsurface_texture->specularscale, dopants, doshirt); break; case R_SHADOW_RENDERMODE_LIGHT_GLSL: - R_Shadow_RenderSurfacesLighting_Light_GLSL(numsurfaces, surfacelist, lightcolorbase, lightcolorpants, lightcolorshirt, rsurface_texture->basetexture, rsurface_texture->skin.pants, rsurface_texture->skin.shirt, rsurface_texture->skin.nmap, rsurface_texture->glosstexture, r_shadow_rtlight->specularscale * rsurface_texture->specularscale, dopants, doshirt); + R_Shadow_RenderSurfacesLighting_Light_GLSL(numsurfaces, surfacelist, lightcolorbase, lightcolorpants, lightcolorshirt, rsurface_texture->basetexture, rsurface_texture->currentskinframe->pants, rsurface_texture->currentskinframe->shirt, rsurface_texture->currentskinframe->nmap, rsurface_texture->glosstexture, r_shadow_rtlight->specularscale * rsurface_texture->specularscale, dopants, doshirt); break; case R_SHADOW_RENDERMODE_LIGHT_DOT3: - R_Shadow_RenderSurfacesLighting_Light_Dot3(numsurfaces, surfacelist, lightcolorbase, lightcolorpants, lightcolorshirt, rsurface_texture->basetexture, rsurface_texture->skin.pants, rsurface_texture->skin.shirt, rsurface_texture->skin.nmap, rsurface_texture->glosstexture, r_shadow_rtlight->specularscale * rsurface_texture->specularscale, dopants, doshirt); + R_Shadow_RenderSurfacesLighting_Light_Dot3(numsurfaces, surfacelist, lightcolorbase, lightcolorpants, lightcolorshirt, rsurface_texture->basetexture, rsurface_texture->currentskinframe->pants, rsurface_texture->currentskinframe->shirt, rsurface_texture->currentskinframe->nmap, rsurface_texture->glosstexture, r_shadow_rtlight->specularscale * rsurface_texture->specularscale, dopants, doshirt); break; case R_SHADOW_RENDERMODE_LIGHT_VERTEX: - R_Shadow_RenderSurfacesLighting_Light_Vertex(numsurfaces, surfacelist, lightcolorbase, lightcolorpants, lightcolorshirt, rsurface_texture->basetexture, rsurface_texture->skin.pants, rsurface_texture->skin.shirt, rsurface_texture->skin.nmap, rsurface_texture->glosstexture, r_shadow_rtlight->specularscale * rsurface_texture->specularscale, dopants, doshirt); + R_Shadow_RenderSurfacesLighting_Light_Vertex(numsurfaces, surfacelist, lightcolorbase, lightcolorpants, lightcolorshirt, rsurface_texture->basetexture, rsurface_texture->currentskinframe->pants, rsurface_texture->currentskinframe->shirt, rsurface_texture->currentskinframe->nmap, rsurface_texture->glosstexture, r_shadow_rtlight->specularscale * rsurface_texture->specularscale, dopants, doshirt); break; default: Con_Printf("R_Shadow_RenderSurfacesLighting: unknown r_shadow_rendermode %i\n", r_shadow_rendermode); @@ -2012,16 +2012,16 @@ void R_Shadow_RenderSurfacesLighting(int numsurfaces, msurface_t **surfacelist) { case R_SHADOW_RENDERMODE_VISIBLELIGHTING: GL_DepthTest(!(rsurface_texture->currentmaterialflags & MATERIALFLAG_NODEPTHTEST) && !r_showdisabledepthtest.integer); - R_Shadow_RenderSurfacesLighting_VisibleLighting(numsurfaces, surfacelist, lightcolorbase, vec3_origin, vec3_origin, rsurface_texture->basetexture, r_texture_black, r_texture_black, rsurface_texture->skin.nmap, rsurface_texture->glosstexture, r_shadow_rtlight->specularscale * rsurface_texture->specularscale, false, false); + R_Shadow_RenderSurfacesLighting_VisibleLighting(numsurfaces, surfacelist, lightcolorbase, vec3_origin, vec3_origin, rsurface_texture->basetexture, r_texture_black, r_texture_black, rsurface_texture->currentskinframe->nmap, rsurface_texture->glosstexture, r_shadow_rtlight->specularscale * rsurface_texture->specularscale, false, false); break; case R_SHADOW_RENDERMODE_LIGHT_GLSL: - R_Shadow_RenderSurfacesLighting_Light_GLSL(numsurfaces, surfacelist, lightcolorbase, vec3_origin, vec3_origin, rsurface_texture->basetexture, r_texture_black, r_texture_black, rsurface_texture->skin.nmap, rsurface_texture->glosstexture, r_shadow_rtlight->specularscale * rsurface_texture->specularscale, false, false); + R_Shadow_RenderSurfacesLighting_Light_GLSL(numsurfaces, surfacelist, lightcolorbase, vec3_origin, vec3_origin, rsurface_texture->basetexture, r_texture_black, r_texture_black, rsurface_texture->currentskinframe->nmap, rsurface_texture->glosstexture, r_shadow_rtlight->specularscale * rsurface_texture->specularscale, false, false); break; case R_SHADOW_RENDERMODE_LIGHT_DOT3: - R_Shadow_RenderSurfacesLighting_Light_Dot3(numsurfaces, surfacelist, lightcolorbase, vec3_origin, vec3_origin, rsurface_texture->basetexture, r_texture_black, r_texture_black, rsurface_texture->skin.nmap, rsurface_texture->glosstexture, r_shadow_rtlight->specularscale * rsurface_texture->specularscale, false, false); + R_Shadow_RenderSurfacesLighting_Light_Dot3(numsurfaces, surfacelist, lightcolorbase, vec3_origin, vec3_origin, rsurface_texture->basetexture, r_texture_black, r_texture_black, rsurface_texture->currentskinframe->nmap, rsurface_texture->glosstexture, r_shadow_rtlight->specularscale * rsurface_texture->specularscale, false, false); break; case R_SHADOW_RENDERMODE_LIGHT_VERTEX: - R_Shadow_RenderSurfacesLighting_Light_Vertex(numsurfaces, surfacelist, lightcolorbase, vec3_origin, vec3_origin, rsurface_texture->basetexture, r_texture_black, r_texture_black, rsurface_texture->skin.nmap, rsurface_texture->glosstexture, r_shadow_rtlight->specularscale * rsurface_texture->specularscale, false, false); + R_Shadow_RenderSurfacesLighting_Light_Vertex(numsurfaces, surfacelist, lightcolorbase, vec3_origin, vec3_origin, rsurface_texture->basetexture, r_texture_black, r_texture_black, rsurface_texture->currentskinframe->nmap, rsurface_texture->glosstexture, r_shadow_rtlight->specularscale * rsurface_texture->specularscale, false, false); break; default: Con_Printf("R_Shadow_RenderSurfacesLighting: unknown r_shadow_rendermode %i\n", r_shadow_rendermode); diff --git a/r_sprites.c b/r_sprites.c index 2f59f1c7..1b728f56 100644 --- a/r_sprites.c +++ b/r_sprites.c @@ -7,7 +7,6 @@ void R_Model_Sprite_Draw_TransparentCallback(const entity_render_t *ent, const r int i; model_t *model = ent->model; vec3_t left, up, org, color, diffusecolor, diffusenormal, mforward, mleft, mup; - mspriteframe_t *frame; float scale; // nudge it toward the view to make sure it isn't in a wall @@ -85,9 +84,11 @@ void R_Model_Sprite_Draw_TransparentCallback(const entity_render_t *ent, const r { if (ent->frameblend[i].lerp >= 0.01f) { - frame = model->sprite.sprdata_frames + ent->frameblend[i].frame; + mspriteframe_t *frame = model->sprite.sprdata_frames + ent->frameblend[i].frame; + texture_t *texture = &frame->texture; + R_UpdateTextureInfo(ent, texture); // FIXME: negate left and right in loader - R_DrawSprite(GL_SRC_ALPHA, (ent->effects & EF_ADDITIVE) ? GL_ONE : GL_ONE_MINUS_SRC_ALPHA, frame->skin.base, frame->skin.fog, (ent->effects & EF_NODEPTHTEST), org, left, up, frame->left, frame->right, frame->down, frame->up, color[0], color[1], color[2], ent->alpha * ent->frameblend[i].lerp); + R_DrawSprite(texture->currentlayers[0].blendfunc1, texture->currentlayers[0].blendfunc2, frame->texture.currentskinframe->base, frame->texture.currentskinframe->fog, (ent->effects & EF_NODEPTHTEST), org, left, up, frame->left, frame->right, frame->down, frame->up, color[0], color[1], color[2], ent->alpha * ent->frameblend[i].lerp); } } } diff --git a/todo b/todo index 868cb5da..c385964c 100644 --- a/todo +++ b/todo @@ -33,6 +33,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 change darkplaces client: put depthtest flag in texturelayer_t 0 bug hmap2: handle \" properly in hmap2 cmdlib.c COM_Parse (sort) 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: hipnotic: health is one character to the right on the sbar, covering up the key icons (M`Shacron) -- 2.39.2