+ for (i = 0;i < size;i++)
+ {
+ l = (*bl++ * *stain++) >> 16;*out++ = min(l, 255);
+ l = (*bl++ * *stain++) >> 16;*out++ = min(l, 255);
+ l = (*bl++ * *stain++) >> 16;*out++ = min(l, 255);
+ }
+ }
+
+ R_UpdateTexture(surface->lightmaptexture, templight, surface->lightmapinfo->lightmaporigin[0], surface->lightmapinfo->lightmaporigin[1], smax, tmax);
+
+ // update the surface's deluxemap if it has one
+ if (surface->deluxemaptexture != r_texture_blanknormalmap)
+ {
+ vec3_t n;
+ unsigned char *normalmap = surface->lightmapinfo->nmapsamples;
+ lightmap = surface->lightmapinfo->samples;
+ // clear to no normalmap
+ bl = intblocklights;
+ memset(bl, 0, size3*sizeof(*bl));
+ // add all the normalmaps
+ if (lightmap && normalmap)
+ {
+ for (maps = 0;maps < MAXLIGHTMAPS && surface->lightmapinfo->styles[maps] != 255;maps++, lightmap += size3, normalmap += size3)
+ {
+ for (scale = r_refdef.lightstylevalue[surface->lightmapinfo->styles[maps]], i = 0;i < size;i++)
+ {
+ // add the normalmap with weighting proportional to the style's lightmap intensity
+ l = (int)(VectorLength(lightmap + i*3) * scale);
+ bl[i*3+0] += ((int)normalmap[i*3+0] - 128) * l;
+ bl[i*3+1] += ((int)normalmap[i*3+1] - 128) * l;
+ bl[i*3+2] += ((int)normalmap[i*3+2] - 128) * l;
+ }
+ }
+ }
+ bl = intblocklights;
+ out = templight;
+ // we simply renormalize the weighted normals to get a valid deluxemap
+ if (model->brushq1.lightmaprgba)