From f5b602ea082842a416c64c63e2b3e00585624945 Mon Sep 17 00:00:00 2001 From: havoc Date: Sun, 20 Dec 2009 13:00:23 +0000 Subject: [PATCH] fix GL11/GL13 fogged sprite rendering and q1bsp sky rendering - the FOGDARKEN flag was not implemented properly changed sprite rendering to use a new function that takes a texture_t instead of a skinframe git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9605 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rmain.c | 28 ++++++++++++++++++++++------ model_shared.h | 11 ----------- r_sprites.c | 2 +- render.h | 1 + 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/gl_rmain.c b/gl_rmain.c index 16c419aa..a19cc83c 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -6056,7 +6056,7 @@ texture_t *R_GetCurrentTexture(texture_t *t) t->currentmaterialflags &= ~(MATERIALFLAG_WATERSHADER | MATERIALFLAG_REFRACTION | MATERIALFLAG_REFLECTION); if (!(rsurface.ent_flags & RENDER_LIGHT)) t->currentmaterialflags |= MATERIALFLAG_FULLBRIGHT; - else if (rsurface.modeltexcoordlightmap2f == NULL) + else if (rsurface.modeltexcoordlightmap2f == NULL && !(t->currentmaterialflags & MATERIALFLAG_FULLBRIGHT)) { // pick a model lighting mode if (VectorLength2(rsurface.modellight_diffuse) >= (1.0f / 256.0f)) @@ -6149,7 +6149,6 @@ texture_t *R_GetCurrentTexture(texture_t *t) t->currentnumlayers = 0; if (t->currentmaterialflags & MATERIALFLAG_WALL) { - int layerflags = 0; int blendfunc1, blendfunc2; qboolean depthmask; if (t->currentmaterialflags & MATERIALFLAG_ADD) @@ -6173,8 +6172,6 @@ texture_t *R_GetCurrentTexture(texture_t *t) blendfunc2 = GL_ZERO; } depthmask = !(t->currentmaterialflags & MATERIALFLAG_BLENDED); - if (r_refdef.fogenabled && (t->currentmaterialflags & MATERIALFLAG_BLENDED)) - layerflags |= TEXTURELAYERFLAG_FOGDARKEN; if (t->currentmaterialflags & MATERIALFLAG_FULLBRIGHT) { // fullbright is not affected by r_refdef.lightmapintensity @@ -7826,7 +7823,7 @@ static void R_DrawTextureSurfaceList_GL13(int texturenumsurfaces, const msurface layercolor[3] = layer->color[3]; applycolor = layercolor[0] != 1 || layercolor[1] != 1 || layercolor[2] != 1 || layercolor[3] != 1; R_Mesh_ColorPointer(NULL, 0, 0); - applyfog = (layer->flags & TEXTURELAYERFLAG_FOGDARKEN) != 0; + applyfog = r_refdef.fogenabled && (rsurface.texture->currentmaterialflags & MATERIALFLAG_BLENDED); switch (layer->type) { case TEXTURELAYERTYPE_LITTEXTURE: @@ -7930,7 +7927,7 @@ static void R_DrawTextureSurfaceList_GL11(int texturenumsurfaces, const msurface GL_DepthMask(layer->depthmask && writedepth); GL_BlendFunc(layer->blendfunc1, layer->blendfunc2); R_Mesh_ColorPointer(NULL, 0, 0); - applyfog = (layer->flags & TEXTURELAYERFLAG_FOGDARKEN) != 0; + applyfog = r_refdef.fogenabled && (rsurface.texture->currentmaterialflags & MATERIALFLAG_BLENDED); switch (layer->type) { case TEXTURELAYERTYPE_LITTEXTURE: @@ -9547,3 +9544,22 @@ void R_DrawCustomSurface(skinframe_t *skinframe, const matrix4x4_t *texmatrix, i rsurface.uselightmaptexture = false; R_DrawModelTextureSurfaceList(1, &surfacelist, writedepth, prepass); } + +void R_DrawCustomSurface_Texture(texture_t *texture, const matrix4x4_t *texmatrix, int materialflags, int firstvertex, int numvertices, int firsttriangle, int numtriangles, qboolean writedepth, qboolean prepass) +{ + static msurface_t surface; + const msurface_t *surfacelist = &surface; + + // fake enough texture and surface state to render this geometry + + surface.texture = texture; + surface.num_triangles = numtriangles; + surface.num_firsttriangle = firsttriangle; + surface.num_vertices = numvertices; + surface.num_firstvertex = firstvertex; + + // now render it + rsurface.texture = R_GetCurrentTexture(surface.texture); + rsurface.uselightmaptexture = false; + R_DrawModelTextureSurfaceList(1, &surfacelist, writedepth, prepass); +} diff --git a/model_shared.h b/model_shared.h index b455609a..5c2adaf7 100644 --- a/model_shared.h +++ b/model_shared.h @@ -408,16 +408,6 @@ typedef enum texturelayertype_e } texturelayertype_t; -typedef enum texturelayerflag_e -{ - // indicates that the pass should apply fog darkening; used on - // transparent surfaces where simply blending an alpha fog as a final - // pass would not behave properly, so all the surfaces must be darkened, - // and the fog color added as a separate pass - TEXTURELAYERFLAG_FOGDARKEN = 1, -} -texturelayerflag_t; - typedef struct texturelayer_s { texturelayertype_t type; @@ -427,7 +417,6 @@ typedef struct texturelayer_s rtexture_t *texture; matrix4x4_t texmatrix; vec4_t color; - int flags; } texturelayer_t; diff --git a/r_sprites.c b/r_sprites.c index 75535e30..654d1b63 100644 --- a/r_sprites.c +++ b/r_sprites.c @@ -380,7 +380,7 @@ void R_Model_Sprite_Draw_TransparentCallback(const entity_render_t *ent, const r R_CalcSprite_Vertex3f(vertex3f, org, left, up, frame->left, frame->right, frame->down, frame->up); - R_DrawCustomSurface(texture->currentskinframe, &identitymatrix, texture->currentmaterialflags, 0, 4, 0, 2, false, false); + R_DrawCustomSurface_Texture(texture, &identitymatrix, texture->currentmaterialflags, 0, 4, 0, 2, false, false); } } diff --git a/render.h b/render.h index 835c9dc0..d502447c 100644 --- a/render.h +++ b/render.h @@ -390,6 +390,7 @@ void R_DrawWorldSurfaces(qboolean skysurfaces, qboolean writedepth, qboolean dep void R_DrawModelSurfaces(entity_render_t *ent, qboolean skysurfaces, qboolean writedepth, qboolean depthonly, qboolean debug, qboolean prepass); void R_AddWaterPlanes(entity_render_t *ent); void R_DrawCustomSurface(skinframe_t *skinframe, const matrix4x4_t *texmatrix, int materialflags, int firstvertex, int numvertices, int firsttriangle, int numtriangles, qboolean writedepth, qboolean prepass); +void R_DrawCustomSurface_Texture(texture_t *texture, const matrix4x4_t *texmatrix, int materialflags, int firstvertex, int numvertices, int firsttriangle, int numtriangles, qboolean writedepth, qboolean prepass); void RSurf_PrepareVerticesForBatch(qboolean generatenormals, qboolean generatetangents, int texturenumsurfaces, const msurface_t **texturesurfacelist); void RSurf_DrawBatch_Simple(int texturenumsurfaces, const msurface_t **texturesurfacelist); -- 2.39.2