]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_rsurf.c
don't print PRVM_NAME in each dprint call, it looks terrible (prints multiple times...
[xonotic/darkplaces.git] / gl_rsurf.c
index c55d8902b492eccf75ebdc627254d8617bd6b117..50d3f2db1fb0338e395c8088463d8d94619108b9 100644 (file)
@@ -489,6 +489,7 @@ void R_Q1BSP_Draw(entity_render_t *ent)
                model_t *model = ent->model;
                msurface_t *surface;
                q3mbrush_t *brush;
+               R_Mesh_Matrix(&ent->matrix);
                GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
                GL_DepthMask(false);
                GL_DepthTest(true);
@@ -667,7 +668,7 @@ void R_Q1BSP_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightorigin,
        model_t *model = ent->model;
        msurface_t *surface;
        int surfacelistindex;
-       float projectdistance = lightradius + model->radius + r_shadow_projectdistance.value;
+       float projectdistance = lightradius + model->radius*2 + r_shadow_projectdistance.value;
        vec3_t modelorg;
        texture_t *texture;
        // check the box in modelspace, it was already checked in worldspace
@@ -710,7 +711,7 @@ void R_Q1BSP_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightorigin,
        }
        else
        {
-               projectdistance = lightradius + ent->model->radius;
+               projectdistance = lightradius + ent->model->radius*2;
                Matrix4x4_Transform(&ent->inversematrix, r_vieworigin, modelorg);
                for (surfacelistindex = 0;surfacelistindex < numsurfaces;surfacelistindex++)
                {
@@ -786,8 +787,35 @@ void R_Q1BSP_DrawLight(entity_render_t *ent, float *lightcolor, int numsurfaces,
                                rsurface_normal3f = varray_normal3f;
                                Mod_BuildTextureVectorsAndNormals(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, rsurface_vertex3f, surface->groupmesh->data_texcoordtexture2f, surface->groupmesh->data_element3i + surface->num_firsttriangle * 3, rsurface_svector3f, rsurface_tvector3f, rsurface_normal3f);
                        }
-                       // FIXME: add colormapping
-                       R_Shadow_RenderLighting(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle), rsurface_vertex3f, rsurface_svector3f, rsurface_tvector3f, rsurface_normal3f, surface->groupmesh->data_texcoordtexture2f, lightcolor, vec3_origin, vec3_origin, texture->skin.base, NULL, NULL, texture->skin.nmap, texture->skin.gloss);
+                       if (ent->colormap >= 0)
+                       {
+                               vec3_t lightcolorpants, lightcolorshirt;
+                               // 128-224 are backwards ranges
+                               int b = (ent->colormap & 0xF) << 4;b += (b >= 128 && b < 224) ? 4 : 12;
+                               if (texture->skin.pants && b >= 224)
+                               {
+                                       qbyte *bcolor = (qbyte *) (&palette_complete[b]);
+                                       lightcolorpants[0] = lightcolor[0] * bcolor[0] * (1.0f / 255.0f);
+                                       lightcolorpants[1] = lightcolor[1] * bcolor[1] * (1.0f / 255.0f);
+                                       lightcolorpants[2] = lightcolor[2] * bcolor[2] * (1.0f / 255.0f);
+                               }
+                               else
+                                       VectorClear(lightcolorpants);
+                               // 128-224 are backwards ranges
+                               b = (ent->colormap & 0xF0);b += (b >= 128 && b < 224) ? 4 : 12;
+                               if (texture->skin.shirt && b >= 224)
+                               {
+                                       qbyte *bcolor = (qbyte *) (&palette_complete[b]);
+                                       lightcolorshirt[0] = lightcolor[0] * bcolor[0] * (1.0f / 255.0f);
+                                       lightcolorshirt[1] = lightcolor[1] * bcolor[1] * (1.0f / 255.0f);
+                                       lightcolorshirt[2] = lightcolor[2] * bcolor[2] * (1.0f / 255.0f);
+                               }
+                               else
+                                       VectorClear(lightcolorshirt);
+                               R_Shadow_RenderLighting(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle), rsurface_vertex3f, rsurface_svector3f, rsurface_tvector3f, rsurface_normal3f, surface->groupmesh->data_texcoordtexture2f, lightcolor, lightcolorpants, lightcolorshirt, texture->skin.base, texture->skin.pants, texture->skin.shirt, texture->skin.nmap, texture->skin.gloss);
+                       }
+                       else
+                               R_Shadow_RenderLighting(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle), rsurface_vertex3f, rsurface_svector3f, rsurface_tvector3f, rsurface_normal3f, surface->groupmesh->data_texcoordtexture2f, lightcolor, vec3_origin, vec3_origin, texture->skin.merged ? texture->skin.merged : texture->skin.base, NULL, NULL, texture->skin.nmap, texture->skin.gloss);
                        if (texture->textureflags & Q3TEXTUREFLAG_TWOSIDED)
                                qglEnable(GL_CULL_FACE);
                }