]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
fix various fog bugs, and also fix missing colormap layer bugs (specifically if the...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 28 Aug 2002 13:35:31 +0000 (13:35 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 28 Aug 2002 13:35:31 +0000 (13:35 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2298 d7cf8633-e32d-0410-b094-e92efae38249

gl_models.c
gl_rsurf.c

index 893d9a0b822f9406e6644bc99ced54cb999292b0..b947c34ec2deafe9975e8e446862895aa9206aeb 100644 (file)
@@ -245,6 +245,7 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
        model_t *model;
        skinframe_t *skinframe;
        const entity_render_t *ent = calldata1;
        model_t *model;
        skinframe_t *skinframe;
        const entity_render_t *ent = calldata1;
+       int blendfunc1, blendfunc2;
 
 //     softwaretransformforentity(ent);
 
 
 //     softwaretransformforentity(ent);
 
@@ -302,7 +303,7 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
 
                        aliasvert = m.vertex;
                        aliasvertcolor = m.color;
 
                        aliasvert = m.vertex;
                        aliasvertcolor = m.color;
-                       R_SetupMDLMD2Frames(ent, m.colorscale * (1 - fog), m.colorscale * (1 - fog), m.colorscale * (1 - fog));
+                       R_SetupMDLMD2Frames(ent, m.colorscale, m.colorscale, m.colorscale);
                        aliasvert = aliasvertbuf;
                        aliasvertcolor = aliasvertcolorbuf;
 
                        aliasvert = aliasvertbuf;
                        aliasvertcolor = aliasvertcolorbuf;
 
@@ -331,28 +332,33 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
                pantsfullbright = shirtfullbright = false;
        }
 
                pantsfullbright = shirtfullbright = false;
        }
 
-       memset(&m, 0, sizeof(m));
        if (ent->effects & EF_ADDITIVE)
        {
        if (ent->effects & EF_ADDITIVE)
        {
-               m.blendfunc1 = GL_SRC_ALPHA;
-               m.blendfunc2 = GL_ONE;
+               blendfunc1 = GL_SRC_ALPHA;
+               blendfunc2 = GL_ONE;
        }
        else if (ent->alpha != 1.0 || skinframe->fog != NULL)
        {
        }
        else if (ent->alpha != 1.0 || skinframe->fog != NULL)
        {
-               m.blendfunc1 = GL_SRC_ALPHA;
-               m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
+               blendfunc1 = GL_SRC_ALPHA;
+               blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
        }
        else
        {
        }
        else
        {
-               m.blendfunc1 = GL_ONE;
-               m.blendfunc2 = GL_ZERO;
+               blendfunc1 = GL_ONE;
+               blendfunc2 = GL_ZERO;
        }
        }
+
+       memset(&m, 0, sizeof(m));
+       m.blendfunc1 = blendfunc1;
+       m.blendfunc2 = blendfunc2;
        m.numtriangles = model->numtris;
        m.numverts = model->numverts;
        m.numtriangles = model->numtris;
        m.numverts = model->numverts;
-       m.tex[0] = colormapped ? R_GetTexture(skinframe->base) : R_GetTexture(skinframe->merged);
        m.matrix = ent->matrix;
        m.matrix = ent->matrix;
-       if (R_Mesh_Draw_GetBuffer(&m, true))
+       m.tex[0] = colormapped ? R_GetTexture(skinframe->base) : R_GetTexture(skinframe->merged);
+       if (m.tex[0] && R_Mesh_Draw_GetBuffer(&m, true))
        {
        {
+               blendfunc1 = GL_SRC_ALPHA;
+               blendfunc2 = GL_ONE;
                c_alias_polys += m.numtriangles;
                R_ModulateColors(aliasvertcolor, m.color, m.numverts, m.colorscale, m.colorscale, m.colorscale);
                memcpy(m.index, model->mdlmd2data_indices, m.numtriangles * sizeof(int[3]));
                c_alias_polys += m.numtriangles;
                R_ModulateColors(aliasvertcolor, m.color, m.numverts, m.colorscale, m.colorscale, m.colorscale);
                memcpy(m.index, model->mdlmd2data_indices, m.numtriangles * sizeof(int[3]));
@@ -366,14 +372,16 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
                if (skinframe->pants)
                {
                        memset(&m, 0, sizeof(m));
                if (skinframe->pants)
                {
                        memset(&m, 0, sizeof(m));
-                       m.blendfunc1 = GL_SRC_ALPHA;
-                       m.blendfunc2 = GL_ONE;
+                       m.blendfunc1 = blendfunc1;
+                       m.blendfunc2 = blendfunc2;
                        m.numtriangles = model->numtris;
                        m.numverts = model->numverts;
                        m.numtriangles = model->numtris;
                        m.numverts = model->numverts;
-                       m.tex[0] = R_GetTexture(skinframe->pants);
                        m.matrix = ent->matrix;
                        m.matrix = ent->matrix;
-                       if (R_Mesh_Draw_GetBuffer(&m, true))
+                       m.tex[0] = R_GetTexture(skinframe->pants);
+                       if (m.tex[0] && R_Mesh_Draw_GetBuffer(&m, true))
                        {
                        {
+                               blendfunc1 = GL_SRC_ALPHA;
+                               blendfunc2 = GL_ONE;
                                c_alias_polys += m.numtriangles;
                                if (pantsfullbright)
                                        R_FillColors(m.color, m.numverts, pantscolor[0] * m.colorscale, pantscolor[1] * m.colorscale, pantscolor[2] * m.colorscale, ent->alpha);
                                c_alias_polys += m.numtriangles;
                                if (pantsfullbright)
                                        R_FillColors(m.color, m.numverts, pantscolor[0] * m.colorscale, pantscolor[1] * m.colorscale, pantscolor[2] * m.colorscale, ent->alpha);
@@ -388,14 +396,16 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
                if (skinframe->shirt)
                {
                        memset(&m, 0, sizeof(m));
                if (skinframe->shirt)
                {
                        memset(&m, 0, sizeof(m));
-                       m.blendfunc1 = GL_SRC_ALPHA;
-                       m.blendfunc2 = GL_ONE;
+                       m.blendfunc1 = blendfunc1;
+                       m.blendfunc2 = blendfunc2;
                        m.numtriangles = model->numtris;
                        m.numverts = model->numverts;
                        m.numtriangles = model->numtris;
                        m.numverts = model->numverts;
-                       m.tex[0] = R_GetTexture(skinframe->shirt);
                        m.matrix = ent->matrix;
                        m.matrix = ent->matrix;
-                       if (R_Mesh_Draw_GetBuffer(&m, true))
+                       m.tex[0] = R_GetTexture(skinframe->shirt);
+                       if (m.tex[0] && R_Mesh_Draw_GetBuffer(&m, true))
                        {
                        {
+                               blendfunc1 = GL_SRC_ALPHA;
+                               blendfunc2 = GL_ONE;
                                c_alias_polys += m.numtriangles;
                                if (shirtfullbright)
                                        R_FillColors(m.color, m.numverts, shirtcolor[0] * m.colorscale, shirtcolor[1] * m.colorscale, shirtcolor[2] * m.colorscale, ent->alpha);
                                c_alias_polys += m.numtriangles;
                                if (shirtfullbright)
                                        R_FillColors(m.color, m.numverts, shirtcolor[0] * m.colorscale, shirtcolor[1] * m.colorscale, shirtcolor[2] * m.colorscale, ent->alpha);
@@ -411,14 +421,16 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
        if (skinframe->glow)
        {
                memset(&m, 0, sizeof(m));
        if (skinframe->glow)
        {
                memset(&m, 0, sizeof(m));
-               m.blendfunc1 = GL_SRC_ALPHA;
-               m.blendfunc2 = GL_ONE;
+               m.blendfunc1 = blendfunc1;
+               m.blendfunc2 = blendfunc2;
                m.numtriangles = model->numtris;
                m.numverts = model->numverts;
                m.numtriangles = model->numtris;
                m.numverts = model->numverts;
-               m.tex[0] = R_GetTexture(skinframe->glow);
                m.matrix = ent->matrix;
                m.matrix = ent->matrix;
-               if (R_Mesh_Draw_GetBuffer(&m, true))
+               m.tex[0] = R_GetTexture(skinframe->glow);
+               if (m.tex[0] && R_Mesh_Draw_GetBuffer(&m, true))
                {
                {
+                       blendfunc1 = GL_SRC_ALPHA;
+                       blendfunc2 = GL_ONE;
                        c_alias_polys += m.numtriangles;
                        R_FillColors(m.color, m.numverts, (1 - fog) * m.colorscale, (1 - fog) * m.colorscale, (1 - fog) * m.colorscale, ent->alpha);
                        memcpy(m.index, model->mdlmd2data_indices, m.numtriangles * sizeof(int[3]));
                        c_alias_polys += m.numtriangles;
                        R_FillColors(m.color, m.numverts, (1 - fog) * m.colorscale, (1 - fog) * m.colorscale, (1 - fog) * m.colorscale, ent->alpha);
                        memcpy(m.index, model->mdlmd2data_indices, m.numtriangles * sizeof(int[3]));
@@ -434,12 +446,12 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
                m.blendfunc2 = GL_ONE;
                m.numtriangles = model->numtris;
                m.numverts = model->numverts;
                m.blendfunc2 = GL_ONE;
                m.numtriangles = model->numtris;
                m.numverts = model->numverts;
-               m.tex[0] = R_GetTexture(skinframe->fog);
                m.matrix = ent->matrix;
                m.matrix = ent->matrix;
-               if (R_Mesh_Draw_GetBuffer(&m, false))
+               m.tex[0] = R_GetTexture(skinframe->fog);
+               if (m.tex[0] && R_Mesh_Draw_GetBuffer(&m, true))
                {
                        c_alias_polys += m.numtriangles;
                {
                        c_alias_polys += m.numtriangles;
-                       R_FillColors(m.color, m.numverts, fog * m.colorscale, fog * m.colorscale, fog * m.colorscale, ent->alpha);
+                       R_FillColors(m.color, m.numverts, fogcolor[0] * fog * m.colorscale, fogcolor[1] * fog * m.colorscale, fogcolor[2] * fog * m.colorscale, ent->alpha);
                        memcpy(m.index, model->mdlmd2data_indices, m.numtriangles * sizeof(int[3]));
                        memcpy(m.vertex, aliasvert, m.numverts * sizeof(float[4]));
                        memcpy(m.texcoords[0], model->mdlmd2data_texcoords, m.numverts * sizeof(float[2]));
                        memcpy(m.index, model->mdlmd2data_indices, m.numtriangles * sizeof(int[3]));
                        memcpy(m.vertex, aliasvert, m.numverts * sizeof(float[4]));
                        memcpy(m.texcoords[0], model->mdlmd2data_texcoords, m.numverts * sizeof(float[2]));
index 08620f340d2b18f0bb91c6423142434b1615d7cd..eae22edb9f2e8511b41cd77cc93a745a0259bdec 100644 (file)
@@ -749,10 +749,10 @@ static void RSurf_FogPassColors(const float *v, float *c, float r, float g, floa
        {
                VectorSubtract(v, modelorg, diff);
                f = exp(fogdensity/DotProduct(diff, diff));
        {
                VectorSubtract(v, modelorg, diff);
                f = exp(fogdensity/DotProduct(diff, diff));
-               c[0] = r * f;
-               c[1] = g * f;
-               c[2] = b * f;
-               c[3] = a;
+               c[0] = r;
+               c[1] = g;
+               c[2] = b;
+               c[3] = a * f;
        }
 }
 
        }
 }
 
@@ -828,13 +828,23 @@ static void RSurfShader_Sky(const entity_render_t *ent, const msurface_t *firsts
        if (skyrendernow)
        {
                skyrendernow = false;
        if (skyrendernow)
        {
                skyrendernow = false;
-               R_Sky();
+               if (skyrendermasked)
+                       R_Sky();
        }
 
        // draw depth-only polys
        memset(&m, 0, sizeof(m));
        }
 
        // draw depth-only polys
        memset(&m, 0, sizeof(m));
-       m.blendfunc1 = GL_ZERO;
-       m.blendfunc2 = GL_ONE;
+       if (skyrendermasked)
+       {
+               m.blendfunc1 = GL_ZERO;
+               m.blendfunc2 = GL_ONE;
+       }
+       else
+       {
+               // fog sky
+               m.blendfunc1 = GL_ONE;
+               m.blendfunc2 = GL_ZERO;
+       }
        m.depthwrite = true;
        m.matrix = ent->matrix;
        for (surf = firstsurf;surf;surf = surf->chain)
        m.depthwrite = true;
        m.matrix = ent->matrix;
        for (surf = firstsurf;surf;surf = surf->chain)
@@ -847,7 +857,10 @@ static void RSurfShader_Sky(const entity_render_t *ent, const msurface_t *firsts
                        {
                                memcpy(m.index, mesh->index, m.numtriangles * sizeof(int[3]));
                                RSurf_CopyXYZ(mesh->vertex, m.vertex, m.numverts);
                        {
                                memcpy(m.index, mesh->index, m.numtriangles * sizeof(int[3]));
                                RSurf_CopyXYZ(mesh->vertex, m.vertex, m.numverts);
-                               memset(m.color, 0, m.numverts * sizeof(float[4]));
+                               if (skyrendermasked)
+                                       memset(m.color, 0, m.numverts * sizeof(float[4]));
+                               else
+                                       R_FillColors(m.color, m.numverts, fogcolor[0] * m.colorscale, fogcolor[1] * m.colorscale, fogcolor[2] * m.colorscale, 1);
                                R_Mesh_Render();
                        }
                }
                                R_Mesh_Render();
                        }
                }