18
0
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:
pawelw
2026-11-20 04:25:18 +01:00
committed by GitHub
parent 142a3bc287
commit 3710f87fc5
7 changed files with 313 additions and 24 deletions

View File

@@ -14,7 +14,10 @@ http://mozilla.org/MPL/2.0/.
#include <algorithm>
#include <array>
#include <chrono>
#include <cmath>
#include <limits>
#include <string_view>
#include <unordered_set>
#include "utilities/Globals.h"
#include "rendering/common/skyocclusion.h"
@@ -40,6 +43,14 @@ float const LIGHT_DUSK_LUMINANCE{0.325f};
float const LIGHT_DAY_LUMINANCE{1.0f};
// lights of the occupied cab, at most
std::size_t const CAB_LIGHTS_MAX{16};
// the cone of the light of a glowing point of a street lamp (gfx_lights_stars), shining downwards: the half angles where it ends
// and where it is at its full brightness, degrees, and the radius of the sphere it shines from, metres
float const LAMP_POINT_OUTER_ANGLE{80.f};
float const LAMP_POINT_INNER_ANGLE{55.f};
float const LAMP_POINT_RADIUS{0.2f};
// a light point whose axis is at most this far from straight down (the cosine of the angle) is a lamp lighting the ground under it;
// one shining more sideways is a signal or a headlight, left as its model has it
float const LAMP_DOWN_COS{0.7f};
glm::vec3 to_linear(glm::vec3 const &Color)
{
@@ -57,6 +68,69 @@ float light_range(glm::vec3 const &Color)
return std::min(std::sqrt(max_component(Color) / LIGHT_THRESHOLD), LIGHT_RANGE_MAX);
}
// how far from the camera the lights are gathered from: gfx_lights_range, or gfx_lights_lamps_range when it's farther, which
// only the lamps of the scenery go as far as (gather_vehicle()). none with gfx_lights_range 0
float gather_range()
{
return (Global.gfx_lights_range > 0.f ? std::max(Global.gfx_lights_range, Global.gfx_lights_lamps_range) : 0.f);
}
// whether Name is one of the names separated with | in List
bool is_listed(std::string_view const Name, std::string_view const List)
{
std::size_t start{0};
while (start <= List.size())
{
auto end{List.find('|', start)};
if (end == std::string_view::npos)
{
end = List.size();
}
if (List.substr(start, end - start) == Name)
{
return true;
}
start = end + 1;
}
return false;
}
// a smt_Stars submodel whose glowing points are the lamp of a street light (gfx_lights_stars)
bool is_lamp_points(TSubModel const &Submodel)
{
return (Submodel.eType == TP_STARS) && (false == Global.gfx_lights_stars.empty()) && is_listed(ToLower(Submodel.pName), Global.gfx_lights_stars);
}
// the axis of the cone of a light point, in the world
glm::vec3 light_axis(glm::mat4 const &Transform, glm::dmat4 const &Placement)
{
auto const axis{glm::vec3{glm::dmat3{Placement} * glm::dvec3{-glm::vec3{Transform[2]}}}};
return (glm::length2(axis) > 0.f ? glm::normalize(axis) : glm::vec3{0.f, -1.f, 0.f});
}
// whether a light with the axis shines downwards, the way a lamp lights the ground under it
bool shines_down(glm::vec3 const &Axis)
{
return (Axis.y <= -LAMP_DOWN_COS);
}
// the cosines of the outer and inner half angles of the cone of a light, the outer one widened to gfx_lights_freespot_mincone when
// Widen. the inner one is above the outer one, as some models have them the wrong way round
glm::vec2 light_cone(float const Cosouter, float const Cosinner, bool const Widen)
{
auto cosouter{std::clamp(Cosouter, -1.f, 0.999f)};
auto cosinner{std::clamp(std::max(Cosinner, cosouter + 0.05f), cosouter + 0.001f, 1.f)};
if (Widen && (Global.gfx_lights_freespot_mincone > 0.f))
{
if (auto const minouter{std::cos(glm::radians(Global.gfx_lights_freespot_mincone))}; minouter < cosouter)
{
cosouter = minouter;
cosinner = std::min(cosinner, std::cos(glm::radians(Global.gfx_lights_freespot_mincone * 0.6f)));
}
}
return {cosouter, cosinner};
}
// model space transform of the parent of the submodel, from the static transforms of the submodels above it; false if the
// submodel is not in the tree
bool find_parent_transform(TSubModel const *Submodel, TSubModel const *Target, glm::mat4 const &Parent, glm::mat4 &Result)
@@ -118,6 +192,7 @@ void gfx::local_lights::gather(glm::dvec3 const &Camera, scene::basic_region &Re
m_cablights.clear();
m_cablampon = false;
m_scenerycount = m_vehiclecount = m_compartmentcount = 0;
m_walkgeometry = &Geometry;
// the editor adds, moves and removes instances in the cells. it can also do it in the frame it is turned off in
auto const rebuild{EditorModeFlag || m_editorseen};
@@ -132,7 +207,7 @@ void gfx::local_lights::gather(glm::dvec3 const &Camera, scene::basic_region &Re
// lamps are lost in the daylight; this also spares the work of gathering them in the middle of the day
auto const darkness{1.f - glm::smoothstep(LIGHT_DUSK_LUMINANCE, LIGHT_DAY_LUMINANCE, static_cast<float>(Global.fLuminance))};
auto const range{Global.gfx_lights_range};
auto const range{gather_range()};
if ((darkness > 0.f) && (range > 0.f) && Global.gfx_lights_scenery)
{
@@ -208,7 +283,7 @@ void gfx::local_lights::gather_instance(TAnimModel *Instance, glm::dvec3 const &
return;
}
auto const offset{Instance->location() - Camera};
if (glm::length(offset) > Global.gfx_lights_range + Instance->radius())
if (glm::length(offset) > gather_range() + Instance->radius())
{
return;
}
@@ -234,6 +309,11 @@ void gfx::local_lights::gather_instance(TAnimModel *Instance, glm::dvec3 const &
void gfx::local_lights::gather_vehicle(TDynamicObject *Vehicle, glm::dvec3 const &Camera, gfx::geometrybank_manager const &Geometry, float const Freespotbrightness,
float const Compartmentbrightness)
{
// the vehicles light within gfx_lights_range, only the lamps of the scenery may be gathered from farther
if (glm::length(Vehicle->GetPosition() - Camera) > Global.gfx_lights_range + Vehicle->radius())
{
return;
}
if ((false == Global.render_cab) && (Global.pCamera.m_owner == Vehicle))
{
// the render leaves the vehicle out as well
@@ -389,12 +469,19 @@ void gfx::local_lights::gather_cab_lights(gfx::geometrybank_manager const &Geome
m_cablampon = (false == m_cablights.empty());
}
float gfx::local_lights::walk_min_distance(TSubModel const &Submodel) const
{
// a lamp of the scenery lights also closer than its glare is seen from (gfx_lights_points_near)
auto const lampnear{(m_walkowner != nullptr) && Global.gfx_lights_points_near && ((Submodel.eType == TP_FREESPOTLIGHT) || is_lamp_points(Submodel))};
return (lampnear ? 0.f : Submodel.fSquareMinDist);
}
void gfx::local_lights::walk(TSubModel *Submodel, glm::mat4 const &Transform, glm::dmat4 const &Placement, float const Brightness)
{
// visibility, lod ranges, transforms and animations as in opengl46_renderer::Render_Alpha(TSubModel *)
for (auto *submodel{Submodel}; submodel != nullptr; submodel = submodel->Next)
{
if ((submodel->iVisible == 0) || (TSubModel::fSquareDist < submodel->fSquareMinDist) || (TSubModel::fSquareDist >= submodel->fSquareMaxDist))
if (auto const mindistance{walk_min_distance(*submodel)}; (submodel->iVisible == 0) || (TSubModel::fSquareDist < mindistance) || (TSubModel::fSquareDist >= submodel->fSquareMaxDist))
{
continue;
}
@@ -410,10 +497,19 @@ void gfx::local_lights::walk(TSubModel *Submodel, glm::mat4 const &Transform, gl
submodel->RaAnimation(transform, submodel->b_aAnim);
}
}
// closer than its glare is seen from only a lamp shining downwards lights, not a signal
if ((TSubModel::fSquareDist < submodel->fSquareMinDist) && (submodel->eType == TP_FREESPOTLIGHT) && (false == shines_down(light_axis(transform, Placement))))
{
continue;
}
if (submodel->eType == TP_FREESPOTLIGHT)
{
add_light_point(*submodel, transform, Placement, Brightness);
}
else if ((m_walkowner != nullptr) && is_lamp_points(*submodel))
{
add_lamp_points(*submodel, transform, Placement, Brightness);
}
if (submodel->Child != nullptr)
{
walk(submodel->Child, transform, Placement, Brightness);
@@ -439,22 +535,26 @@ void gfx::local_lights::add_light_point(TSubModel const &Submodel, glm::mat4 con
auto const diffuse{Submodel.DiffuseOverride.r < 0.f ? // -1 indicates no override
glm::vec3{Submodel.f4Diffuse} :
Submodel.DiffuseOverride};
auto const color{to_linear(diffuse) * (Brightness * Submodel.fHotspotPower * Submodel.fVisible * std::min(Submodel.f4Emision.a, 1.f))};
if (max_component(color) <= LIGHT_THRESHOLD)
auto const direction{light_axis(Transform, Placement)};
// a lamp of the scenery shining downwards: brighter by gfx_lights_lamps_gain, its cone widened to gfx_lights_freespot_mincone
auto const lamp{(m_walkowner != nullptr) && shines_down(direction)};
auto const gain{lamp ? Global.gfx_lights_lamps_gain : 1.f};
auto const lightcolor{to_linear(diffuse) * (Brightness * gain * Submodel.fHotspotPower * Submodel.fVisible * std::min(Submodel.f4Emision.a, 1.f))};
if (max_component(lightcolor) <= LIGHT_THRESHOLD)
{
return;
}
light lightpoint;
lightpoint.position = glm::dvec3{Placement * glm::dvec4{glm::dvec3{Transform[3]}, 1.0}};
auto const axis{glm::vec3{glm::dmat3{Placement} * glm::dvec3{-glm::vec3{Transform[2]}}}};
lightpoint.direction = (glm::length2(axis) > 0.f ? glm::normalize(axis) : glm::vec3{0.f, -1.f, 0.f});
lightpoint.color = color;
lightpoint.direction = direction;
lightpoint.color = lightcolor;
// the cone of the glare: where the point is seen from is where it shines. the glare goes from no brightness at the falloff
// angle to full at the hotspot angle, which some models have the wrong way round
lightpoint.cos_outer = std::clamp(Submodel.fCosFalloffAngle, -1.f, 0.999f);
lightpoint.cos_inner = std::clamp(std::max(Submodel.fCosHotspotAngle, lightpoint.cos_outer + 0.05f), lightpoint.cos_outer + 0.001f, 1.f);
lightpoint.range = light_range(color);
auto const cone{light_cone(Submodel.fCosFalloffAngle, Submodel.fCosHotspotAngle, lamp)};
lightpoint.cos_outer = cone.x;
lightpoint.cos_inner = cone.y;
lightpoint.range = light_range(lightcolor);
lightpoint.radius = Submodel.fLightRadius;
lightpoint.soft_falloff = Submodel.bSoftFalloff;
lightpoint.cast_shadows = Submodel.bCastShadows;
@@ -472,6 +572,39 @@ void gfx::local_lights::add_light_point(TSubModel const &Submodel, glm::mat4 con
m_lights.emplace_back(lightpoint);
}
void gfx::local_lights::add_lamp_points(TSubModel const &Submodel, glm::mat4 const &Transform, glm::dmat4 const &Placement, float const Brightness)
{
// lit as the render draws them: past the self-illumination threshold
if ((m_walkgeometry == nullptr) || (Submodel.m_geometry.handle == null_handle) || (Global.fLuminance >= Submodel.fLight))
{
return;
}
auto const cone{light_cone(std::cos(glm::radians(LAMP_POINT_OUTER_ANGLE)), std::cos(glm::radians(LAMP_POINT_INNER_ANGLE)), true)};
for (auto const &vertex : m_walkgeometry->vertices(Submodel.m_geometry.handle))
{
// a glowing point keeps its colour in its normal; one without any takes the colour of the submodel
auto const pointcolor{max_component(vertex.normal) > 0.f ? vertex.normal : glm::vec3{Submodel.f4Diffuse}};
auto const lightcolor{to_linear(pointcolor) * (Brightness * Global.gfx_lights_lamps_gain)};
if (max_component(lightcolor) <= LIGHT_THRESHOLD)
{
continue;
}
light lightpoint;
lightpoint.position = glm::dvec3{Placement * glm::dvec4{glm::dvec3{Transform * glm::vec4{vertex.position, 1.f}}, 1.0}};
lightpoint.direction = glm::vec3{0.f, -1.f, 0.f};
lightpoint.color = lightcolor;
lightpoint.cos_outer = cone.x;
lightpoint.cos_inner = cone.y;
lightpoint.range = light_range(lightcolor);
lightpoint.radius = LAMP_POINT_RADIUS;
lightpoint.soft_falloff = true;
// the point names the lamp from frame to frame (the shadow maps of the lamps)
lightpoint.owner = m_walkowner;
lightpoint.part = &vertex;
m_lights.emplace_back(lightpoint);
}
}
bool gfx::local_lights::has_light_points(TModel3d *Model)
{
auto lookup{m_modellights.find(Model)};
@@ -487,7 +620,7 @@ bool gfx::local_lights::has_light_points(TModel3d *Model)
pending.pop_back();
for (; submodel != nullptr; submodel = submodel->Next)
{
if (submodel->eType == TP_FREESPOTLIGHT)
if ((submodel->eType == TP_FREESPOTLIGHT) || is_lamp_points(*submodel))
{
found = true;
break;
@@ -502,23 +635,35 @@ bool gfx::local_lights::has_light_points(TModel3d *Model)
return found;
}
void gfx::local_lights::add_lit_instances(std::vector<TAnimModel *> const &Instances, std::unordered_set<TAnimModel const *> &Added, std::vector<TAnimModel *> &Lit)
{
for (auto *instance : Instances)
{
if ((instance->pModel != nullptr) && has_light_points(instance->pModel) && Added.insert(instance).second)
{
Lit.emplace_back(instance);
}
}
}
gfx::local_lights::cell_data const &gfx::local_lights::cell_instances(scene::basic_cell &Cell, bool const Rebuild)
{
// light points are drawn in the translucent phase, so the instances which have them are on the translucent list of the cell
// light points are drawn in the translucent phase, so the instances which have them are on the translucent list of the cell.
// the glowing points of the lamps (smt_Stars) are drawn with the opaque ones, so a lamp made of them can be on the opaque list only
auto &instances{Cell.m_instancetranslucent};
auto &opaque{Cell.m_instancesopaque};
auto &data{m_cells[&Cell]};
if (Rebuild || (data.source_size != instances.size()) || (data.source_data != static_cast<void const *>(instances.data())))
if (Rebuild || (data.source_size != instances.size()) || (data.source_data != static_cast<void const *>(instances.data())) || (data.opaque_size != opaque.size()) ||
(data.opaque_data != static_cast<void const *>(opaque.data())))
{
data.instances.clear();
for (auto *instance : instances)
{
if ((instance->pModel != nullptr) && has_light_points(instance->pModel))
{
data.instances.emplace_back(instance);
}
}
std::unordered_set<TAnimModel const *> added;
add_lit_instances(instances, added, data.instances);
add_lit_instances(opaque, added, data.instances);
data.source_size = instances.size();
data.source_data = instances.data();
data.opaque_size = opaque.size();
data.opaque_data = opaque.data();
}
return data;
}

View File

@@ -12,6 +12,7 @@ http://mozilla.org/MPL/2.0/.
#include <cstdint>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
namespace scene
@@ -70,7 +71,8 @@ class local_lights
local_lights(const local_lights &) = delete;
local_lights &operator=(const local_lights &) = delete;
// collects the lights within Global.gfx_lights_range of Camera, for the frame about to be drawn. it sets the state of the
// collects the lights within Global.gfx_lights_range of Camera (the lamps of the scenery within Global.gfx_lights_lamps_range,
// when it's farther), for the frame about to be drawn. it sets the state of the
// shared models of the instances and vehicles it goes through, as the render does before it draws each of them.
// Geometry: the geometry the models were loaded to, for the bounds of compartments and cabs; Framestamp: the number of the frame
void gather(glm::dvec3 const &Camera, scene::basic_region &Region, gfx::geometrybank_manager const &Geometry, unsigned int const Framestamp);
@@ -122,20 +124,28 @@ class local_lights
struct cell_data
{
std::vector<TAnimModel *> instances; // instances of models with light points
// what the list was made from: when the instance list of the cell changes, the list is made anew
// what the list was made from: when the instance lists of the cell change, the list is made anew
std::size_t source_size{0};
void const *source_data{nullptr};
std::size_t opaque_size{0};
void const *opaque_data{nullptr};
};
// lights of the light points of the submodel tree, gone through the way the render goes through it. Transform: model space of
// Submodel's parent, Placement: model space to world space, Brightness: of a light point of white colour
void walk(TSubModel *Submodel, glm::mat4 const &Transform, glm::dmat4 const &Placement, float const Brightness);
// the square of the distance from the camera the submodel lights from at the least
float walk_min_distance(TSubModel const &Submodel) const;
void add_light_point(TSubModel const &Submodel, glm::mat4 const &Transform, glm::dmat4 const &Placement, float Brightness);
// lights of the glowing points of a smt_Stars submodel of a scenery lamp (gfx_lights_stars), each one shining downwards
void add_lamp_points(TSubModel const &Submodel, glm::mat4 const &Transform, glm::dmat4 const &Placement, float Brightness);
void gather_instance(TAnimModel *Instance, glm::dvec3 const &Camera, float const Brightness, unsigned int const Framestamp);
void gather_vehicle(TDynamicObject *Vehicle, glm::dvec3 const &Camera, gfx::geometrybank_manager const &Geometry, float const Freespotbrightness, float const Compartmentbrightness);
void gather_cab_lights(gfx::geometrybank_manager const &Geometry);
bool has_light_points(TModel3d *Model);
cell_data const &cell_instances(scene::basic_cell &Cell, bool const Rebuild);
// the instances of the list with light points not yet in Added, appended to Lit
void add_lit_instances(std::vector<TAnimModel *> const &Instances, std::unordered_set<TAnimModel const *> &Added, std::vector<TAnimModel *> &Lit);
section_data const &section(TModel3d *Model, TSubModel *Section, gfx::geometrybank_manager const &Geometry);
section_data const &model_bounds(TModel3d *Model, gfx::geometrybank_manager const &Geometry);
@@ -150,6 +160,7 @@ class local_lights
std::unordered_map<TSubModel const *, section_data> m_sections; // compartments, by their submodel
std::unordered_map<TModel3d const *, section_data> m_models; // bounds of cab models
TAnimModel const *m_walkowner{nullptr}; // scenery instance whose light points walk() goes through; nullptr for vehicles
gfx::geometrybank_manager const *m_walkgeometry{nullptr}; // geometry of the models, for the glowing points of the lamps
bool m_editorseen{false}; // the editor was on in the last frame: the instance lists of the cells may have changed
// statistics
std::uint32_t m_scenerycount{0};

View File

@@ -16,6 +16,7 @@ http://mozilla.org/MPL/2.0/.
#include "rendering/common/walksync.h"
#include "utilities/color.h"
#include "utilities/Globals.h"
#include "utilities/utilities.h"
#include "vehicle/Train.h"
#include "vehicle/Camera.h"
#include "vehicle/DynObj.h"
@@ -29,7 +30,10 @@ http://mozilla.org/MPL/2.0/.
#include "model/AnimModel.h"
#include "model/Model3d.h"
#include "rendering/common/skyocclusion.h"
#include <algorithm>
#include <chrono>
#include <string>
#include <string_view>
namespace gfx
{
@@ -44,8 +48,67 @@ TEnvironmentType track_environment(TTrack const *Track)
return (Global.gfx_tunnelflags ? Track->eEnvironment : e_flat);
}
// the name of a texture or a material the way gfx_lights_hideglow lists it: lower case, with /, without the folder of the textures
// and without the extension
std::string glow_name(std::string_view const Name)
{
auto name{ToLower(std::string{Name})};
std::ranges::replace(name, '\\', '/');
if (name.starts_with("textures/"))
{
name.erase(0, std::string_view{"textures/"}.size());
}
if (auto const dot{name.rfind('.')}; (dot != std::string::npos) && (name.find('/', dot) == std::string::npos))
{
name.erase(dot);
}
return name;
}
// whether the material named Name is one of the textures separated with | in List: the same name, or the end of it after a /
bool is_listed_glow(std::string_view const Name, std::string_view const List)
{
std::size_t start{0};
while (start <= List.size())
{
auto end{List.find('|', start)};
if (end == std::string_view::npos)
{
end = List.size();
}
if (auto const entry{glow_name(List.substr(start, end - start))}; (false == entry.empty()) && ((Name == entry) || Name.ends_with("/" + entry)))
{
return true;
}
start = end + 1;
}
return false;
}
} // namespace
bool scene_walk::drawn_in_phase(TSubModel const *Submodel, int const Mask)
{
return ((Submodel->iAlpha & Submodel->iFlags & Mask) != 0) && (false == is_fake_glow(Submodel));
}
bool scene_walk::is_fake_glow(TSubModel const *Submodel)
{
// kept when no lamp lights in their place: the local lights off, or gathered from nowhere (gfx_lights_range 0)
if (Global.gfx_lights_hideglow.empty() || (false == Global.gfx_lights_clustered) || (false == Global.gfx_lights_scenery) || (Global.gfx_lights_range <= 0.f) ||
(Submodel->m_material <= 0))
{
return false;
}
auto lookup{m_fakeglows.find(Submodel->m_material)};
if (lookup == m_fakeglows.end())
{
auto const fake{is_listed_glow(glow_name(walk_material_data(Submodel->m_material).GetName()), Global.gfx_lights_hideglow)};
lookup = m_fakeglows.emplace(Submodel->m_material, fake).first;
}
return lookup->second;
}
// the top view of the editor shows everything this close to the camera, the corners of the screen included
float scene_walk::editor_ortho_reach()
{
@@ -3142,7 +3205,7 @@ void scene_walk::Render_Alpha(TSubModel *Submodel)
if (Submodel->eType < TP_ROTATOR)
{
// renderowanie obiektów OpenGL
if (Submodel->iAlpha & Submodel->iFlags & 0x2F)
if (drawn_in_phase(Submodel, 0x2F))
{
// rysuj gdy element przezroczysty

View File

@@ -635,6 +635,14 @@ class scene_walk
private:
static float editor_ortho_reach();
// a plane faking the light of a lamp (its texture is one of gfx_lights_hideglow), left out while the lamps of the scenery
// light their surroundings
bool is_fake_glow(TSubModel const *Submodel);
// whether the submodel is drawn in the phase of the mask (0x2F translucent): it has a part of it, and isn't a fake glow (the
// glow planes are translucent)
bool drawn_in_phase(TSubModel const *Submodel, int Mask);
std::unordered_map<material_handle, bool> m_fakeglows; // whether the material is one of gfx_lights_hideglow
};
} // namespace gfx