Index: tr_shade.c =================================================================== --- tr_shade.c (revision 315) +++ tr_shade.c (working copy) @@ -430,6 +430,7 @@ float radius; vec3_t floatColor; float modulate; + float flux; if ( !backEnd.refdef.num_dlights ) { return; @@ -531,37 +532,43 @@ vec_ste((vector unsigned int)colorChar,0,(unsigned int *)colors); // store color #else VectorSubtract( origin, tess.xyz[i], dist ); - texCoords[0] = 0.5f + dist[0] * scale; - texCoords[1] = 0.5f + dist[1] * scale; + clip = 0; + flux = DotProduct(dist, tess.normal[i]); // If dynamic light is behind surface, turn off. - clip = 0; - if ( texCoords[0] < 0.0f ) { - clip |= 1; - } else if ( texCoords[0] > 1.0f ) { - clip |= 2; - } - if ( texCoords[1] < 0.0f ) { - clip |= 4; - } else if ( texCoords[1] > 1.0f ) { - clip |= 8; - } - // modulate the strength based on the height and color - if ( dist[2] > radius ) { - clip |= 16; - modulate = 0.0f; - } else if ( dist[2] < -radius ) { + if ( flux < 0 ) { clip |= 32; modulate = 0.0f; } else { - dist[2] = Q_fabs(dist[2]); - if ( dist[2] < radius * 0.5f ) { - modulate = 1.0f; + texCoords[0] = 0.5f + dist[0] * scale; + texCoords[1] = 0.5f + dist[1] * scale; + + if ( texCoords[0] < 0.0f ) { + clip |= 1; + } else if ( texCoords[0] > 1.0f ) { + clip |= 2; + } + if ( texCoords[1] < 0.0f ) { + clip |= 4; + } else if ( texCoords[1] > 1.0f ) { + clip |= 8; + } + // modulate the strength based on the height and color + if ( dist[2] > radius ) { + clip |= 16; + modulate = 0.0f; + } else if ( dist[2] < -radius ) { + clip |= 32; + modulate = 0.0f; } else { - modulate = 2.0f * (radius - dist[2]) * scale; + dist[2] = Q_fabs(dist[2]); + if ( dist[2] < radius * 0.5f ) { + modulate = 1.0f; + } else { + modulate = 2.0f * (radius - dist[2]) * scale; + } } + clipBits[i] = clip; } - clipBits[i] = clip; - colors[0] = myftol(floatColor[0] * modulate); colors[1] = myftol(floatColor[1] * modulate); colors[2] = myftol(floatColor[2] * modulate);