mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-21 05:04:58 +01:00
feat(gl46): street lamps of the scenery light their surroundings (#371)
* Local lights: street lamps of the scenery light their surroundings Optional settings, all off by default (nothing changes without them): - gfx.lights.stars: Stars submodels (e.g. "lamp" of the SGP340 street lights) whose glowing points light downwards as lamps; signal LEDs, chimneys and the sky only glow - gfx.lights.points.near: scenery lamps shining downwards light also closer than their glare is seen from - gfx.lights.freespot.mincone: wider cones for scenery lamps shining downwards (many have the narrow cone of their glare) - gfx.lights.lamps.gain: brightness of the scenery lamps shining downwards - gfx.lights.hideglow: textures of the planes faking the light of lamps (pools of light, glows), hidden while the lamps light Lights shining sideways (signals) keep their cones, brightness and distances. The lamps made of glowing points are gathered also from the opaque instances of a cell. * Local lights: the lamp settings in a parser of their own, the draw phase test in a helper The entries of the lamps are read by ConfigParse_gfx_lamps, which the parser of the sky hands the tokens it doesn't know, and the opaque and translucent draws ask drawn_in_phase whether a submodel has a part in them, so the long functions keep their complexity. The fake glow cache is private, the colour of a light point is lightcolor (no shadowing of rendermode::color), the minimal distance of a submodel comes from walk_min_distance and the lit instances of a cell from add_lit_instances. * Settings: the lamp entries are tried by the main loop of the parser, the parser of the sky stays as it was * Local lights: the fake glows are left out only within the reach the lamps are gathered from Beyond gfx.lights.range nothing lights the ground in place of the pools of light and glows of the lamps, so a scenery model keeps them there. Render_Alpha(TAnimModel *) tells hide_fake_glows() which model it draws, and is_fake_glow() leaves out the glows of that model only, when it is within the range (and its radius) of the camera the lamps are gathered around. The glow planes are translucent, so the opaque draws are as they were. * Local lights: hide_fake_glows() takes the model as it is drawn (radius() isn't const) * Local lights: the fake glows hidden at any distance again, gfx.lights.lamps.range to see the lamps from afar Glow planes kept beyond the reach of the lamps don't light a distant station either, they only float above it, so the glows listed in gfx.lights.hideglow are left out at any distance again. A lit station is seen from afar with gfx.lights.lamps.range instead: the lamps are gathered from that far when it's above gfx.lights.range (0, the default: from gfx.lights.range). * Local lights: gfx.lights.lamps.range for the lamps of the scenery only, the vehicles keep gfx.lights.range * Local lights: the fake glows are kept with gfx.lights.range 0, the limits of gfx.lights.hideglow in the docs
This commit is contained in:
@@ -1552,6 +1552,9 @@ void global_settings::ConfigParse(cParser& Parser)
|
||||
if (ConfigParse_gfx(Parser, token))
|
||||
continue;
|
||||
|
||||
if (ConfigParse_gfx_lamps(Parser, token))
|
||||
continue;
|
||||
|
||||
if (ConfigParseGeneral(Parser, token))
|
||||
continue;
|
||||
|
||||
@@ -2276,6 +2279,32 @@ global_settings::ConfigParse_gfx_sky( cParser &Parser, std::string_view const To
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
global_settings::ConfigParse_gfx_lamps( cParser &Parser, std::string_view const Token ) {
|
||||
|
||||
// a list of names separated with |, or "no" for none
|
||||
auto const readlist = [&Parser]( std::string &Value ) {
|
||||
Parser.getTokens( 1 );
|
||||
Parser >> Value;
|
||||
if( Value == "no" ) { Value.clear(); } };
|
||||
auto const readvalue = [&Parser]( float &Value, float const Min, float const Max ) {
|
||||
Parser.getTokens( 1 );
|
||||
Parser >> Value;
|
||||
Value = std::clamp( Value, Min, Max ); };
|
||||
|
||||
if( Token == "gfx.lights.points.near" ) {
|
||||
Parser.getTokens( 1 );
|
||||
Parser >> gfx_lights_points_near; }
|
||||
else if( Token == "gfx.lights.stars" ) { readlist( gfx_lights_stars ); }
|
||||
else if( Token == "gfx.lights.freespot.mincone" ) { readvalue( gfx_lights_freespot_mincone, 0.f, 89.f ); }
|
||||
else if( Token == "gfx.lights.lamps.gain" ) { readvalue( gfx_lights_lamps_gain, 0.1f, 10.f ); }
|
||||
else if( Token == "gfx.lights.lamps.range" ) { readvalue( gfx_lights_lamps_range, 0.f, 10000.f ); }
|
||||
else if( Token == "gfx.lights.hideglow" ) { readlist( gfx_lights_hideglow ); }
|
||||
else { return false; }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
global_settings::export_as_text( std::ostream &Output ) const {
|
||||
|
||||
@@ -2633,6 +2662,12 @@ global_settings::export_as_text( std::ostream &Output ) const {
|
||||
export_as_text( Output, "gfx.lights.compartment.intensity", gfx_lights_compartment_intensity );
|
||||
export_as_text( Output, "gfx.lights.cab.intensity", gfx_lights_cab_intensity );
|
||||
export_as_text( Output, "gfx.lights.cab.bounce", gfx_lights_cab_bounce );
|
||||
export_as_text( Output, "gfx.lights.points.near", gfx_lights_points_near );
|
||||
export_as_text( Output, "gfx.lights.stars", gfx_lights_stars.empty() ? std::string{ "no" } : gfx_lights_stars );
|
||||
export_as_text( Output, "gfx.lights.freespot.mincone", gfx_lights_freespot_mincone );
|
||||
export_as_text( Output, "gfx.lights.lamps.gain", gfx_lights_lamps_gain );
|
||||
export_as_text( Output, "gfx.lights.lamps.range", gfx_lights_lamps_range );
|
||||
export_as_text( Output, "gfx.lights.hideglow", gfx_lights_hideglow.empty() ? std::string{ "no" } : gfx_lights_hideglow );
|
||||
export_as_text( Output, "gfx.cabprobe", std::string{ gfx_cabprobe == 3 ? "high" : gfx_cabprobe == 2 ? "medium" : gfx_cabprobe == 1 ? "low" : "no" } );
|
||||
export_as_text( Output, "gfx.cabprobe.interval", gfx_cabprobe_interval );
|
||||
export_as_text( Output, "gfx.cabprobe.bounce", gfx_cabprobe_bounce );
|
||||
|
||||
@@ -537,6 +537,26 @@ struct global_settings {
|
||||
float gfx_lights_compartment_intensity { 1.f }; // brightness of the light of a lit vehicle compartment
|
||||
float gfx_lights_cab_intensity { 1.5f }; // brightness of the cab lamp
|
||||
float gfx_lights_cab_bounce { 0.3f }; // share of the former ambient light of the cab lamp kept, for the light which bounces around the cab
|
||||
// a light point of a scenery lamp shining downwards lights its surroundings also closer than its glare is seen from (the
|
||||
// minimal distance of its submodel, which many lamps have set for the glare seen from afar), so the lamp doesn't go out as the
|
||||
// camera comes near it. off: as before
|
||||
bool gfx_lights_points_near { false };
|
||||
// names of the smt_Stars submodels of scenery models (many street lamps have nothing else) whose glowing points light their
|
||||
// surroundings, each one downwards as the lamp of a street light, separated with |. other glowing points (lights of signals,
|
||||
// of chimneys, the stars of the sky) only glow. empty (as before): none. the lamps of many models are named "lamp"
|
||||
std::string gfx_lights_stars {};
|
||||
// the half angle of the cone of the light of a light point of a scenery lamp shining downwards is at least this, degrees.
|
||||
// 0: the cone of its glare, which many lamps have narrow. lights shining sideways (signals) keep their cones
|
||||
float gfx_lights_freespot_mincone { 0.f };
|
||||
// the brightness of the light the lamps of the scenery shining downwards (and their glowing points, gfx_lights_stars) light
|
||||
// their surroundings with is multiplied by this. lights shining sideways (signals) keep theirs
|
||||
float gfx_lights_lamps_gain { 1.f };
|
||||
// the lamps of the scenery are gathered from this far from the camera when it's above gfx_lights_range, metres, so the lit
|
||||
// stations are seen from afar; the vehicles keep gfx_lights_range. 0: from gfx_lights_range
|
||||
float gfx_lights_lamps_range { 0.f };
|
||||
// textures of the planes models fake the light of their lamps with (pools of light on the ground, glows), separated with |:
|
||||
// they aren't drawn while the light points of scenery models light their surroundings. empty: they're drawn
|
||||
std::string gfx_lights_hideglow;
|
||||
// the probe of the occupied cab (opengl 4.6 and vulkan, gfx::cab_probe): cube maps of the cab lit by its lamp (and what glows in
|
||||
// it) and of its albedo, drawn every few frames: the light of the lamp bounces around the cab from it (in place of
|
||||
// gfx_lights_cab_bounce) and the cab reflects itself in its glasses and glossy parts. 0 off, 1 low, 2 medium, 3 high (faces of
|
||||
@@ -718,6 +738,7 @@ struct global_settings {
|
||||
bool ConfigParse_gfx( cParser &parser, std::string_view const Token );
|
||||
// sky light and exposure switches of the opengl 4.6 renderer (gfx.ambient.*, gfx.envmap.ggx, gfx.atmosphere*, gfx.postfx.autoexposure*, gfx.postfx.bloom*, gfx.postfx.whitebalance*, gfx.postfx.ao*)
|
||||
bool ConfigParse_gfx_sky( cParser &parser, std::string_view const Token );
|
||||
bool ConfigParse_gfx_lamps( cParser &parser, std::string_view const Token );
|
||||
// sends basic content of the class in legacy (text) format to provided stream
|
||||
void
|
||||
export_as_text( std::ostream &Output ) const;
|
||||
|
||||
Reference in New Issue
Block a user