light: revert ee89d41b6d since it's now handled within the trace code

This commit is contained in:
Eric Wasylishen 2016-11-03 18:27:40 -06:00
parent 4f530fadb9
commit 186485ec47
2 changed files with 9 additions and 26 deletions

View File

@ -139,7 +139,6 @@ typedef struct {
/* for lit water. receive light from either front or back. */
bool twosided;
vec_t alpha;
// ray batch stuff
raystream_t *stream;

View File

@ -762,9 +762,8 @@ Lightsurf_Init(const modelinfo_t *modelinfo, const bsp2_dface_t *face,
lightsurf->nodirt = true;
}
/* handle alpha */
lightsurf->alpha = modelinfo->alpha.floatValue();
if (lightsurf->alpha < 1) {
/* handle glass alpha */
if (modelinfo->alpha.floatValue() < 1) {
/* skip culling of rays coming from the back side of the face */
lightsurf->twosided = true;
}
@ -955,7 +954,7 @@ GetLightValue(const globalconfig_t &cfg, const light_t *entity, vec_t dist)
}
float
GetLightValueWithAngle(const globalconfig_t &cfg, const light_t *entity, const vec3_t surfnorm, const vec3_t surfpointToLightDir, float dist, bool twosided, float alpha)
GetLightValueWithAngle(const globalconfig_t &cfg, const light_t *entity, const vec3_t surfnorm, const vec3_t surfpointToLightDir, float dist, bool twosided)
{
float angle = DotProduct(surfpointToLightDir, surfnorm);
if (entity->bleed.boolValue() || twosided) {
@ -987,13 +986,7 @@ GetLightValueWithAngle(const globalconfig_t &cfg, const light_t *entity, const v
}
}
/* Check glass transparency */
float glass_transparency = 1;
if (alpha < 1) {
glass_transparency = (1-alpha);
}
float add = GetLightValue(cfg, entity, dist) * angle * spotscale * glass_transparency;
float add = GetLightValue(cfg, entity, dist) * angle * spotscale;
return add;
}
@ -1001,10 +994,10 @@ static void LightFace_SampleMipTex(miptex_t *tex, const float *projectionmatrix,
void
GetLightContrib(const globalconfig_t &cfg, const light_t *entity, const vec3_t surfnorm, const vec3_t surfpoint, bool twosided,
float alpha, vec3_t color_out, vec3_t surfpointToLightDir_out, vec3_t normalmap_addition_out, float *dist_out)
vec3_t color_out, vec3_t surfpointToLightDir_out, vec3_t normalmap_addition_out, float *dist_out)
{
float dist = GetDir(surfpoint, *entity->origin.vec3Value(), surfpointToLightDir_out);
float add = GetLightValueWithAngle(cfg, entity, surfnorm, surfpointToLightDir_out, dist, twosided, alpha);
float add = GetLightValueWithAngle(cfg, entity, surfnorm, surfpointToLightDir_out, dist, twosided);
/* write out the final color */
if (entity->projectedmip) {
@ -1280,8 +1273,7 @@ GetDirectLighting(const globalconfig_t &cfg, raystream_t *rs, const vec3_t origi
continue;
}
// FIXME: handle glass
GetLightContrib(cfg, &entity, normal, origin, false, 1.0f, color, surfpointToLightDir, normalcontrib, &surfpointToLightDist);
GetLightContrib(cfg, &entity, normal, origin, false, color, surfpointToLightDir, normalcontrib, &surfpointToLightDist);
const float dirt = Dirt_GetScaleFactor(cfg, occlusion, &entity, /* FIXME: pass */ nullptr);
VectorScale(color, dirt, color);
@ -1316,8 +1308,6 @@ GetDirectLighting(const globalconfig_t &cfg, raystream_t *rs, const vec3_t origi
// apply anglescale
cosangle = (1.0 - sun.anglescale) + sun.anglescale * cosangle;
// FIXME: handle glass
if (!TestSky(origin, sun.sunvec, NULL)) {
continue;
}
@ -1382,7 +1372,7 @@ LightFace_Entity(const bsp2_t *bsp,
float surfpointToLightDist;
vec3_t color, normalcontrib;
GetLightContrib(cfg, entity, surfnorm, surfpoint, lightsurf->twosided, lightsurf->alpha, color, surfpointToLightDir, normalcontrib, &surfpointToLightDist);
GetLightContrib(cfg, entity, surfnorm, surfpoint, lightsurf->twosided, color, surfpointToLightDir, normalcontrib, &surfpointToLightDist);
const float occlusion = Dirt_GetScaleFactor(cfg, lightsurf->occlusion[i], entity, lightsurf);
VectorScale(color, occlusion, color);
@ -1441,12 +1431,6 @@ LightFace_Sky(const sun_t *sun, const lightsurf_t *lightsurf, lightmapdict_t *li
return;
}
/* Check glass transparency for lighting the back side of glass */
float glass_transparency = 1;
if (lightsurf->alpha < 1) {
glass_transparency = (1-lightsurf->alpha);
}
/* if sunlight is set, use a style 0 light map */
lightmap_t *lightmap = Lightmap_ForStyle(lightmaps, 0, lightsurf);
@ -1477,7 +1461,7 @@ LightFace_Sky(const sun_t *sun, const lightsurf_t *lightsurf, lightmapdict_t *li
}
angle = (1.0 - sun->anglescale) + sun->anglescale * angle;
float value = angle * sun->sunlight * glass_transparency;
float value = angle * sun->sunlight;
if (sun->dirt) {
value *= Dirt_GetScaleFactor(cfg, lightsurf->occlusion[i], NULL, lightsurf);
}