]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
fix GL11/GL13 fogged sprite rendering and q1bsp sky rendering - the
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 20 Dec 2009 13:00:23 +0000 (13:00 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 20 Dec 2009 13:00:23 +0000 (13:00 +0000)
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
model_shared.h
r_sprites.c
render.h

index 16c419aa2d41ecf10917dd81c10f810f99af094b..a19cc83cca574bbde755b9861da0c93e43e9d9d2 100644 (file)
@@ -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);
+}
index b455609ad7b367bb634a33f72cafe38570dcdec4..5c2adaf71f7d89e87b7290972295d4172d1f3138 100644 (file)
@@ -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;
 
index 75535e303ad2097932c46ab682fab5860cb34417..654d1b630045cacf992e4fe2f862ba25e4616483 100644 (file)
@@ -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);
                }
        }
 
index 835c9dc05f46949f4949c667c5370d6564afdd9c..d502447c0302047b6a42a6130e4e4bcad28cc091 100644 (file)
--- 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);