]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
implemented q3 shader keyword polygonoffset
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 27 Aug 2007 21:52:06 +0000 (21:52 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 27 Aug 2007 21:52:06 +0000 (21:52 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7543 d7cf8633-e32d-0410-b094-e92efae38249

gl_rmain.c
model_shared.c
model_shared.h

index cd9404ba6272dab721ea5f78677122105360f1d9..9f3cef9b085e8a1ab6c209451c717dc4e6cf8e66 100644 (file)
@@ -3420,15 +3420,15 @@ void R_UpdateTextureInfo(const entity_render_t *ent, texture_t *t)
                t->specularscale = 0;
        }
 
-       t->currentpolygonfactor = r_refdef.polygonfactor;
-       t->currentpolygonoffset = r_refdef.polygonoffset;
+       t->currentpolygonfactor = r_refdef.polygonfactor + t->basepolygonfactor;
+       t->currentpolygonoffset = r_refdef.polygonoffset + t->basepolygonoffset;
        // submodels are biased to avoid z-fighting with world surfaces that they
        // may be exactly overlapping (avoids z-fighting artifacts on certain
        // doors and things in Quake maps)
        if (ent->model->brush.submodel)
        {
-               t->currentpolygonfactor = r_refdef.polygonfactor + r_polygonoffset_submodel_factor.value;
-               t->currentpolygonoffset = r_refdef.polygonoffset + r_polygonoffset_submodel_offset.value;
+               t->currentpolygonfactor += r_polygonoffset_submodel_factor.value;
+               t->currentpolygonoffset += r_polygonoffset_submodel_offset.value;
        }
 
        VectorClear(t->dlightcolor);
index 77a2336d956bdf683f8e9da95bbd99b086d92c32..b52762364fad43b3d0f243c5dee9e86d7f75015f 100644 (file)
@@ -1488,6 +1488,8 @@ void Mod_LoadQ3Shaders(void)
                                        shader->surfaceparms |= Q3SURFACEPARM_NOMIPMAPS;
                                else if (!strcasecmp(parameter[0], "nopicmip"))
                                        shader->textureflags |= Q3TEXTUREFLAG_NOPICMIP;
+                               else if (!strcasecmp(parameter[0], "polygonoffset"))
+                                       shader->textureflags |= Q3TEXTUREFLAG_POLYGONOFFSET;
                                else if (!strcasecmp(parameter[0], "deformvertexes") && numparameters >= 2)
                                {
                                        int i, deformindex;
@@ -1601,6 +1603,8 @@ qboolean Mod_LoadTextureFromQ3Shader(texture_t *texture, const char *name, qbool
                        texture->basematerialflags |= MATERIALFLAG_ALPHATEST | MATERIALFLAG_NOSHADOW;
                if (shader->textureflags & Q3TEXTUREFLAG_TWOSIDED)
                        texture->basematerialflags |= MATERIALFLAG_NOSHADOW | MATERIALFLAG_NOCULLFACE;
+               if (shader->textureflags & Q3TEXTUREFLAG_POLYGONOFFSET)
+                       texture->basepolygonoffset -= 2;
                texture->customblendfunc[0] = GL_ONE;
                texture->customblendfunc[1] = GL_ZERO;
                if (shader->numlayers > 0)
index eb2ddce1e942b96241eb0c39484fe78c3dec8bdd..36580fd17b64d82f15783b1595ecda44e2e0caa6 100644 (file)
@@ -186,6 +186,7 @@ shadowmesh_t;
 // TODO: support these features more directly
 #define Q3TEXTUREFLAG_TWOSIDED 1
 #define Q3TEXTUREFLAG_NOPICMIP 16
+#define Q3TEXTUREFLAG_POLYGONOFFSET 32
 
 #define Q3PATHLENGTH 64
 #define TEXTURE_MAXFRAMES 64
@@ -414,6 +415,8 @@ typedef struct texture_s
        // current PolygonOffset values for rendering this material
        float currentpolygonfactor;
        float currentpolygonoffset;
+       float basepolygonfactor;
+       float basepolygonoffset;
 
        // textures to use when rendering this material
        skinframe_t *currentskinframe;