Stage 5 of the EU07M model format. A model with lights (lights, Light_On## / Light_Off##), such as a signal head, was
drawn instance by instance, a draw call for each part of each one. With gfx.instancedlights 1 the instances of such a
model go into the instanced batches like the others, in both renderers, with the culling of the GPU and without it. The
default 0 draws them as before. It applies to EU07M and E3D models alike.
- The light state of an instance is a word in the element [0][3] of its instance matrix, which an affine matrix leaves
unused: bits 0-7 the lit parts shown, bits 8-15 the dark parts, in the mantissa of a float of exponent 128
(0x40000000), a normal number the GPU carries through its matrix products whole. Without that marker the shader
draws everything, as before.
- model_ubs.light_part says which part of which slot a draw is (0 none, 1 + slot lit, 9 + slot dark); a part the
instance doesn't show gets a zero matrix in the vertex shader (instance_hides_part() and effective_modelview() in
shaders/vk14/common.glsl and shaders/ogl46/common.glsl). The batch instance shows every light part
(TAnimModel::RaPrepareInstanced()).
- CPU path: each instance drawn is animated (RaAnimate) and its word put in its matrix (Render_Instanced). GPU culling:
the word is in rotationscale[0].w of the instance record, refreshed once a frame for buckets with lights
(Refresh_Light_Records), which marks the records to send again when a word changes.
- An instance shows the whole lit part or the whole dark one: blinking and switching (ls_On / ls_Off / ls_Blink) change
over at half the fade, where the draw instance by instance fades the lit part in over the dark one. Steady states look
the same as before.
- The freespot lights (TP_FREESPOTLIGHT with flag 0x4000 and no animation) don't keep a model out of the instancing
when gfx.instancedlights is on. Light parts aren't put in the ray tracing of an instance batch.
Measured on Vulkan, 200 heads s4ipcpb_dd: with gfx.gpucull 0 frame 9.2 ms -> 1.5-2.5 ms and 2400 -> 16 draw calls, with
gfx.gpucull 1 9.1 ms -> 3.0 ms and 2410 -> 26 draw calls. Steady light states pixel for pixel the same as drawn
instance by instance on all three paths in Vulkan, and on GL 4.6 where the editor panels don't cover them; blinking
checked in Vulkan on all three paths (with time let run in the editor for the test only). Not run in the driver mode,
blinking not checked on GL 4.6, not built with GCC here. Unit tests 1189/1189.
* 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