light: support "_suntexture" key on "_sun" "1" entities to limit them
to being cast from a specific sky texture. Fixes #110
This commit is contained in:
parent
d2ecc73db3
commit
f220b2f531
|
|
@ -80,6 +80,7 @@ public:
|
|||
lockable_bool_t bleed;
|
||||
lockable_vec3_t origin, color, mangle, projangle;
|
||||
lockable_string_t project_texture;
|
||||
lockable_string_t suntexture;
|
||||
|
||||
light_formula_t getFormula() const { return static_cast<light_formula_t>(formula.intValue()); }
|
||||
|
||||
|
|
@ -120,7 +121,8 @@ public:
|
|||
color { "color", 255.0f, 255.0f, 255.0f, vec3_transformer_t::NORMALIZE_COLOR_TO_255 },
|
||||
mangle { "mangle", 0, 0, 0 }, // not transformed to vec
|
||||
projangle { "project_mangle", 20, 0, 0 }, // not transformed to vec
|
||||
project_texture { "project_texture", "" }
|
||||
project_texture { "project_texture", "" },
|
||||
suntexture { "suntexture", "" }
|
||||
{
|
||||
VectorSet(spotvec, 0, 0, 0);
|
||||
|
||||
|
|
@ -136,7 +138,7 @@ public:
|
|||
&dirt_off_radius, &dirt_on_radius,
|
||||
&sun, //mxd
|
||||
&falloff, //mxd
|
||||
&origin, &color, &mangle, &projangle, &project_texture
|
||||
&origin, &color, &mangle, &projangle, &project_texture, &suntexture
|
||||
}};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ public:
|
|||
qboolean dirt;
|
||||
float anglescale;
|
||||
int style;
|
||||
std::string suntexture;
|
||||
};
|
||||
|
||||
/* for vanilla this would be 18. some engines allow higher limits though, which will be needed if we're scaling lightmap resolution. */
|
||||
|
|
|
|||
|
|
@ -402,7 +402,7 @@ Dirt_ResolveFlag(const globalconfig_t &cfg, int dirtInt)
|
|||
* =============
|
||||
*/
|
||||
static void
|
||||
AddSun(const globalconfig_t &cfg, vec3_t sunvec, vec_t light, const vec3_t color, int dirtInt, float sun_anglescale, const int style)
|
||||
AddSun(const globalconfig_t &cfg, vec3_t sunvec, vec_t light, const vec3_t color, int dirtInt, float sun_anglescale, const int style, const std::string& suntexture)
|
||||
{
|
||||
if (light == 0.0f)
|
||||
return;
|
||||
|
|
@ -416,6 +416,7 @@ AddSun(const globalconfig_t &cfg, vec3_t sunvec, vec_t light, const vec3_t color
|
|||
sun.anglescale = sun_anglescale;
|
||||
sun.dirt = Dirt_ResolveFlag(cfg, dirtInt);
|
||||
sun.style = style;
|
||||
sun.suntexture = suntexture;
|
||||
|
||||
// add to list
|
||||
all_suns.push_back(sun);
|
||||
|
|
@ -440,7 +441,7 @@ AddSun(const globalconfig_t &cfg, vec3_t sunvec, vec_t light, const vec3_t color
|
|||
*/
|
||||
static void
|
||||
SetupSun(const globalconfig_t &cfg, vec_t light, const vec3_t color, const vec3_t sunvec_in, const float sun_anglescale, const float sun_deviance, const int sunlight_dirt,
|
||||
const int style)
|
||||
const int style, const std::string& suntexture)
|
||||
{
|
||||
vec3_t sunvec;
|
||||
int i;
|
||||
|
|
@ -489,7 +490,7 @@ SetupSun(const globalconfig_t &cfg, vec_t light, const vec3_t color, const vec3_
|
|||
|
||||
//printf( "sun %d is using vector %f %f %f\n", i, direction[0], direction[1], direction[2]);
|
||||
|
||||
AddSun(cfg, direction, light, color, sunlight_dirt, sun_anglescale, style);
|
||||
AddSun(cfg, direction, light, color, sunlight_dirt, sun_anglescale, style, suntexture);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -514,18 +515,18 @@ SetupSuns(const globalconfig_t &cfg)
|
|||
}
|
||||
|
||||
// Add the sun
|
||||
SetupSun(cfg, entity.light.floatValue(), *entity.color.vec3Value(), sunvec, entity.anglescale.floatValue(), entity.deviance.floatValue(), entity.dirt.intValue(), entity.style.intValue());
|
||||
SetupSun(cfg, entity.light.floatValue(), *entity.color.vec3Value(), sunvec, entity.anglescale.floatValue(), entity.deviance.floatValue(), entity.dirt.intValue(), entity.style.intValue(), entity.suntexture.stringValue());
|
||||
|
||||
// Disable the light itself...
|
||||
entity.light.setFloatValue(0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
SetupSun(cfg, cfg.sunlight.floatValue(), *cfg.sunlight_color.vec3Value(), *cfg.sunvec.vec3Value(), cfg.global_anglescale.floatValue(), cfg.sun_deviance.floatValue(), cfg.sunlight_dirt.intValue(), 0);
|
||||
SetupSun(cfg, cfg.sunlight.floatValue(), *cfg.sunlight_color.vec3Value(), *cfg.sunvec.vec3Value(), cfg.global_anglescale.floatValue(), cfg.sun_deviance.floatValue(), cfg.sunlight_dirt.intValue(), 0, "");
|
||||
|
||||
if (cfg.sun2.floatValue() != 0) {
|
||||
logprint("creating sun2\n");
|
||||
SetupSun(cfg, cfg.sun2.floatValue(), *cfg.sun2_color.vec3Value(), *cfg.sun2vec.vec3Value(), cfg.global_anglescale.floatValue(), cfg.sun_deviance.floatValue(), cfg.sunlight_dirt.intValue(), 0);
|
||||
SetupSun(cfg, cfg.sun2.floatValue(), *cfg.sun2_color.vec3Value(), *cfg.sun2vec.vec3Value(), cfg.global_anglescale.floatValue(), cfg.sun_deviance.floatValue(), cfg.sunlight_dirt.intValue(), 0, "");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -591,14 +592,14 @@ SetupSkyDome(const globalconfig_t &cfg)
|
|||
|
||||
/* insert top hemisphere light */
|
||||
if (sunlight2value > 0) {
|
||||
AddSun(cfg, direction, sunlight2value, *cfg.sunlight2_color.vec3Value(), cfg.sunlight2_dirt.intValue(), cfg.global_anglescale.floatValue(), 0);
|
||||
AddSun(cfg, direction, sunlight2value, *cfg.sunlight2_color.vec3Value(), cfg.sunlight2_dirt.intValue(), cfg.global_anglescale.floatValue(), 0, "");
|
||||
}
|
||||
|
||||
direction[ 2 ] = -direction[ 2 ];
|
||||
|
||||
/* insert bottom hemisphere light */
|
||||
if (sunlight3value > 0) {
|
||||
AddSun(cfg, direction, sunlight3value, *cfg.sunlight3_color.vec3Value(), cfg.sunlight2_dirt.intValue(), cfg.global_anglescale.floatValue(), 0);
|
||||
AddSun(cfg, direction, sunlight3value, *cfg.sunlight3_color.vec3Value(), cfg.sunlight2_dirt.intValue(), cfg.global_anglescale.floatValue(), 0, "");
|
||||
}
|
||||
|
||||
/* move */
|
||||
|
|
@ -614,13 +615,13 @@ SetupSkyDome(const globalconfig_t &cfg)
|
|||
VectorSet( direction, 0.0f, 0.0f, -1.0f );
|
||||
|
||||
if (sunlight2value > 0) {
|
||||
AddSun(cfg, direction, sunlight2value, *cfg.sunlight2_color.vec3Value(), cfg.sunlight2_dirt.intValue(), cfg.global_anglescale.floatValue(), 0);
|
||||
AddSun(cfg, direction, sunlight2value, *cfg.sunlight2_color.vec3Value(), cfg.sunlight2_dirt.intValue(), cfg.global_anglescale.floatValue(), 0, "");
|
||||
}
|
||||
|
||||
VectorSet( direction, 0.0f, 0.0f, 1.0f );
|
||||
|
||||
if (sunlight3value > 0) {
|
||||
AddSun(cfg, direction, sunlight3value, *cfg.sunlight3_color.vec3Value(), cfg.sunlight2_dirt.intValue(), cfg.global_anglescale.floatValue(), 0);
|
||||
AddSun(cfg, direction, sunlight3value, *cfg.sunlight3_color.vec3Value(), cfg.sunlight2_dirt.intValue(), cfg.global_anglescale.floatValue(), 0, "");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1598,6 +1598,16 @@ LightFace_Sky(const sun_t *sun, const lightsurf_t *lightsurf, lightmapdict_t *li
|
|||
continue;
|
||||
}
|
||||
|
||||
// check if we hit the wrong texture
|
||||
// TODO: this could be faster!
|
||||
if (!sun->suntexture.empty()) {
|
||||
const bsp2_dface_t *face = rs->getPushedRayHitFace(j);
|
||||
const char* facetex = Face_TextureName(lightsurf->bsp, face);
|
||||
if (sun->suntexture != facetex) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
const int i = rs->getPushedRayPointIndex(j);
|
||||
|
||||
// check if we hit a dynamic shadow caster
|
||||
|
|
|
|||
|
|
@ -431,6 +431,9 @@ The following light properties correspond to these sunlight settings:
|
|||
_color => _sunlight_color
|
||||
_dirt => _sunlight_dirt
|
||||
_anglescale => _anglescale
|
||||
style => flicker style for styled sunlight
|
||||
targetname => targetname for switchable sunlight
|
||||
_suntexture => this sunlight is only emitted from faces with this texture name
|
||||
.fi
|
||||
|
||||
.SH "OTHER INFORMATION"
|
||||
|
|
|
|||
Loading…
Reference in New Issue