Tweaks to get lights to fade in quantity-wise as well as brightness-wise.
This commit is contained in:
parent
31b9c763df
commit
40d68c5627
2 changed files with 30 additions and 10 deletions
|
@ -170,7 +170,7 @@ bool FGMaterialLib::load( const string& mpath ) {
|
||||||
lights->setColourMaterial( GL_AMBIENT_AND_DIFFUSE );
|
lights->setColourMaterial( GL_AMBIENT_AND_DIFFUSE );
|
||||||
lights->setMaterial( GL_EMISSION, 0, 0, 0, 1 );
|
lights->setMaterial( GL_EMISSION, 0, 0, 0, 1 );
|
||||||
lights->setMaterial( GL_SPECULAR, 0, 0, 0, 1 );
|
lights->setMaterial( GL_SPECULAR, 0, 0, 0, 1 );
|
||||||
lights->disable( GL_BLEND );
|
lights->enable( GL_BLEND );
|
||||||
lights->disable( GL_ALPHA_TEST );
|
lights->disable( GL_ALPHA_TEST );
|
||||||
lights->disable( GL_LIGHTING );
|
lights->disable( GL_LIGHTING );
|
||||||
|
|
||||||
|
|
|
@ -133,20 +133,40 @@ static void print_refs( ssgSelector *sel, ssgTransform *trans,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static ssgLeaf *gen_lights( ssgVertexArray *lights, float bright ) {
|
static ssgLeaf *gen_lights( ssgVertexArray *lights, int inc, float bright ) {
|
||||||
|
int size = lights->getNum() / inc;
|
||||||
|
|
||||||
// Allocate ssg structure
|
// Allocate ssg structure
|
||||||
|
ssgVertexArray *vl = new ssgVertexArray( size + 1 );
|
||||||
ssgNormalArray *nl = NULL;
|
ssgNormalArray *nl = NULL;
|
||||||
ssgTexCoordArray *tl = NULL;
|
ssgTexCoordArray *tl = NULL;
|
||||||
ssgColourArray *cl = new ssgColourArray( 1 );
|
ssgColourArray *cl = new ssgColourArray( size + 1 );
|
||||||
|
|
||||||
// default to slightly yellow lights for now
|
|
||||||
sgVec4 color;
|
sgVec4 color;
|
||||||
sgSetVec4( color, 1.0 * bright, 1.0 * bright, 0.7 * bright, 1.0 );
|
for ( int i = 0; i < lights->getNum(); i += inc ) {
|
||||||
cl->add( color );
|
vl->add( lights->get(i) );
|
||||||
|
|
||||||
|
// yellow = 1,1,0
|
||||||
|
float zombie = sg_random();
|
||||||
|
if ( zombie > 0.5 ) {
|
||||||
|
// 50% chance of yellowish
|
||||||
|
sgSetVec4( color, 0.9, 0.9, 0.3, bright );
|
||||||
|
} else if ( zombie > 0.15 ) {
|
||||||
|
// 35% chance of whitish
|
||||||
|
sgSetVec4( color, 0.9, 0.9, 0.6, bright );
|
||||||
|
} else if ( zombie > 0.05 ) {
|
||||||
|
// 10% chance of orangish
|
||||||
|
sgSetVec4( color, 0.9, 0.6, 0.2, bright );
|
||||||
|
} else {
|
||||||
|
// 5% chance of redish
|
||||||
|
sgSetVec4( color, 0.9, 0.2, 0.2, bright );
|
||||||
|
}
|
||||||
|
cl->add( color );
|
||||||
|
}
|
||||||
|
|
||||||
// create ssg leaf
|
// create ssg leaf
|
||||||
ssgLeaf *leaf =
|
ssgLeaf *leaf =
|
||||||
new ssgVtxTable ( GL_POINTS, lights, nl, tl, cl );
|
new ssgVtxTable ( GL_POINTS, vl, nl, tl, cl );
|
||||||
|
|
||||||
// assign state
|
// assign state
|
||||||
FGNewMat *newmat = material_lib.find( "LIGHTS" );
|
FGNewMat *newmat = material_lib.find( "LIGHTS" );
|
||||||
|
@ -259,13 +279,13 @@ void FGNewCache::fill_in( const FGBucket& b ) {
|
||||||
e->lights_brightness = new ssgSelector;
|
e->lights_brightness = new ssgSelector;
|
||||||
ssgLeaf *lights;
|
ssgLeaf *lights;
|
||||||
|
|
||||||
lights = gen_lights( light_pts, 0.6 );
|
lights = gen_lights( light_pts, 4, 0.7 );
|
||||||
e->lights_brightness->addKid( lights );
|
e->lights_brightness->addKid( lights );
|
||||||
|
|
||||||
lights = gen_lights( light_pts, 0.8 );
|
lights = gen_lights( light_pts, 2, 0.85 );
|
||||||
e->lights_brightness->addKid( lights );
|
e->lights_brightness->addKid( lights );
|
||||||
|
|
||||||
lights = gen_lights( light_pts, 1.0 );
|
lights = gen_lights( light_pts, 1, 1.0 );
|
||||||
e->lights_brightness->addKid( lights );
|
e->lights_brightness->addKid( lights );
|
||||||
|
|
||||||
e->lights_range->addKid( e->lights_brightness );
|
e->lights_range->addKid( e->lights_brightness );
|
||||||
|
|
Loading…
Add table
Reference in a new issue