if (!r_coronas.integer)
return;
R_Mesh_Matrix(&r_identitymatrix);
- viewdist = DotProduct(r_origin, vpn);
+ viewdist = DotProduct(r_vieworigin, r_viewforward);
for (i = 0;i < r_numdlights;i++)
{
rd = r_dlight + i;
- dist = (DotProduct(rd->origin, vpn) - viewdist);
- if (dist >= 24.0f && CL_TraceLine(rd->origin, r_origin, NULL, NULL, true, NULL, SUPERCONTENTS_SOLID) == 1)
+ dist = (DotProduct(rd->origin, r_viewforward) - viewdist);
+ if (dist >= 24.0f && CL_TraceLine(rd->origin, r_vieworigin, NULL, NULL, true, NULL, SUPERCONTENTS_SOLID) == 1)
{
cscale = (1.0f / 131072.0f);
scale = rd->cullradius * 0.25f;
cscale *= 4.0f;
scale *= 2.0f;
}
- R_DrawSprite(GL_ONE, GL_ONE, lightcorona, true, rd->origin, vright, vup, scale, -scale, -scale, scale, rd->light[0] * cscale, rd->light[1] * cscale, rd->light[2] * cscale, 1);
+ R_DrawSprite(GL_ONE, GL_ONE, lightcorona, true, rd->origin, r_viewright, r_viewup, scale, -scale, -scale, scale, rd->light[0] * cscale, rd->light[1] * cscale, rd->light[2] * cscale, 1);
}
}
}
{
surf->dlightbits[0] = surf->dlightbits[1] = surf->dlightbits[2] = surf->dlightbits[3] = surf->dlightbits[4] = surf->dlightbits[5] = surf->dlightbits[6] = surf->dlightbits[7] = 0;
surf->dlightframe = r_framecount;
- if (r_dlightmap.integer)
- surf->cached_dlight = true;
+ surf->cached_dlight = true;
}
surf->dlightbits[bitindex] |= bit;
}
float color[4], v[3], dot, dist2, f, dnormal[3];
nearlight_t *nl;
usediffuse = DotProduct(diffusecolor, diffusecolor) > 0;
- VectorCopy(diffusenormal, dnormal);
+ // negate the diffuse normal to avoid the need to negate the
+ // dotproduct on each vertex
+ VectorNegate(diffusenormal, dnormal);
if (usediffuse)
VectorNormalize(dnormal);
// directional shading code here
// silly directional diffuse shading
if (usediffuse)
{
- dot = -DotProduct(normal3f, dnormal);
+ dot = DotProduct(normal3f, dnormal);
if (dot > 0)
VectorMA(color, dot, diffusecolor, color);
}