18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 11:47:06 +01:00
Commit Graph

21 Commits

Author SHA1 Message Date
maj00r 05a8ddaabd Merge the review fixes of the PRs below from feat/eu07m-instancing into feat/eu07m-skinning 2026-11-29 18:22:12 +01:00
maj00r 99bc0b125c fix(render): EU07M review of #538: an instance with light colours of its own drawn alone, the light records locked only when stale
- An instance with lightcolors of its own isn't instanced: the colours go onto the shared submodels as the instance is
  prepared, which the instances of a bucket don't each get, so they all showed the colours of one of them.
- The walk takes the exclusive lock for the light records of a bucket only when they are stale in this frame
  (Refresh_Light_Records() checks again under it): the later passes of the frame no longer stop the other walkers.
- instance_cull.comp (both renderers) puts the word of the light parts into [0][3] after the product with the view, so a
  view with a translation can't stretch the first column of a lit instance.
- The spec: ls_Dark / ls_Home switch without the fade too, and the instances with light colours of their own.
2026-11-29 18:14:35 +01:00
maj00r d324c53233 feat(model): skinned parts of EU07M models move with their joints, skinned on the CPU
Stage 4 of the EU07M model format. A primitive with a skin (SKIN, SKJT, weights in VSKN or VSKW) was drawn in its bind
pose. Now it follows the joints of its skin, in both renderers.

- The joints are nodes of the model, so they're posed as before: animation events, the .mmd, SetRotate / SetTranslate
  from the vehicle code. The matrix of a joint is world(joint) * inverse bind(joint), world being the transform of the
  joint from the root of the model with the animations of the instance drawn (TSubModel::posed_transform()); the
  vertices lie in the bind pose in the space of the model, the transform of the node of the mesh left out, as in glTF.
- The loader keeps the bind pose and the weights of a skinned primitive (skinning::skinned_geometry on the submodel) and
  the skins of the model (TModel3d::skins()).
- The first pass of a frame to draw a skinned submodel of an instance works out the palette and, when it changed, moves
  the vertices on the CPU: positions by the blended matrix, normals and tangents by its rotation (model/skinning.cpp,
  gfx::skin_cache in rendering/common/skincache.cpp). The geometry of the instance is made or replaced before the passes
  of the next frame (flush() in the frame setup of both renderers), as nothing the passes draw may change while they draw
  (gfx::walk_sync): the vertices follow the joints a frame late. In the bind pose the shared geometry of the model is
  drawn; an instance not drawn for 600 frames lets go of its own.
- Fix: a node with range_max_sq 0, which the spec gives as no limit, was never drawn (a model made anew rather than
  converted from E3D); it keeps the default range of a submodel now.
- The editor self-test gets "animate <node> <submodel> <x> <y> <z>", which turns a submodel of an instance as an
  animation event does, since the editor doesn't run the events.

Not in this commit: the skinning in a compute shader, bounds of the posed submodel, motion vectors and ray tracing of the
moved vertices.

Checked: a tube of two joints in two instances, one turned by 60 degrees at its middle, bends smoothly while the other
stays straight, in Vulkan and GL 4.6, with gfx.gpucull 0 and 1 (time let run in the editor for the test only). Unit
tests 1194/1194, 5 new ones for the weights, the bind pose, the blending and the file. Not built with GCC here.
2026-11-28 23:52:35 +01:00
maj00r 8a82433a11 feat(render): models with lights drawn instanced, behind gfx.instancedlights in eu07.ini
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.
2026-11-28 23:10:53 +01:00
Hirek 0ce190eab2 fix: the review of the renderers PR: physics switches off by default, crashes on exit and at start, renderer, shader and editor fixes 2026-11-27 09:15:11 +01:00
pawelw 3710f87fc5 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
2026-11-20 04:25:18 +01:00
Hirek 053e4cacee Merge branch 'master' into feat/renderers-cleanup 2026-11-16 21:44:48 +01:00
Hirek ff2ff308ed Some optimalisations 2026-11-09 20:58:02 +01:00
Hirek 0bc29af650 Merge remote-tracking branch 'origin/feat/switch-fastenings' into feat/renderers-cleanup 2026-10-31 17:13:45 +01:00
Hirek 765153ad91 Merge remote-tracking branch 'origin/feat/switch-blades' into feat/renderers-cleanup 2026-10-29 23:55:04 +01:00
Hirek 91c6324965 Add the optional LightOnly of FreeSpotLight 2026-10-28 21:50:08 +01:00
Hirek c4e23932bf Add the optional Radius, ShadeSelf, CastShadows and SoftFalloff of FreeSpotLight and make FalloffAngle 360 a point light 2026-10-28 16:18:03 +01:00
Hirek e8a90507f0 Light the cab with the sun coming in through its windows 2026-10-28 12:19:43 +01:00
Hirek 1447dcf075 Walk the shadow passes and the culled model groups on worker threads in the Vulkan renderer 2026-10-27 20:56:11 +01:00
Hirek 2a876befb0 Shade the sky and the sun by the scenery around the camera instead of the track environment flags 2026-10-27 16:02:36 +01:00
Hirek 9dde5b0e5e Take the ambient occlusion into the lighting and add a probe of the cab 2026-10-27 13:23:52 +01:00
Hirek 550d47e97c Merge remote-tracking branch 'jano211/siec-radio' into feat/renderers-cleanup 2026-10-26 16:36:36 +01:00
Hirek 08f4f6ed60 Vulkan ray tracing: include tracks and roads, build triangle strips and fans 2026-10-25 15:35:26 +01:00
Hirek f20b1a3071 Replace cubemap scenery reflections with SSR, add Vulkan ray traced reflections 2026-10-25 13:54:49 +01:00
Hirek 252b9373ea Add gfx.antialiasing (off, msaax2/x4/x8, taa) with temporal anti-aliasing in the GL 4.6 and Vulkan renderers 2026-10-25 05:17:41 +01:00
Hirek 9b7d02e5fb Vulkan: scene rendering (D1–D7) on a scene walk shared with GL (N6a, N6b) 2026-10-24 20:10:24 +02:00