int R_LightModel(float *ambient4f, float *diffusecolor, float *diffusenormal, const entity_render_t *ent, float colorr, float colorg, float colorb, float colora, int worldcoords)
{
int i, j, maxnearlights;
- float v[3], f, mscale, stylescale, intensity, ambientcolor[3];
+ float v[3], f, mscale, stylescale, intensity, ambientcolor[3], tempdiffusenormal[3];
nearlight_t *nl;
mlight_t *sl;
rdlight_t *rd;
else
{
if (cl.worldmodel && cl.worldmodel->brush.LightPoint)
- cl.worldmodel->brush.LightPoint(cl.worldmodel, ent->origin, ambient4f, diffusecolor, diffusenormal);
+ {
+ cl.worldmodel->brush.LightPoint(cl.worldmodel, ent->origin, ambient4f, diffusecolor, tempdiffusenormal);
+ Matrix4x4_Transform3x3(&ent->inversematrix, tempdiffusenormal, diffusenormal);
+ VectorNormalize(diffusenormal);
+ }
else
VectorSet(ambient4f, 1, 1, 1);
}
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