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

42 Commits

Author SHA1 Message Date
Claude 2fe11d39a1 Rain windscreen: the rain fallen since a blade went over each place of its sweep
The glass took the rain fallen since one of the two moments the blades were at the ends of their
sweep, picked by the way the blade was going. After a pass that gave a place the blade had just
wiped the rain of the sweep before, until the blade reached the other end: the haze and the drops
there jumped back and forth with every sweep (a jump in brightness under the wiper mask, best seen
in a light rain).

Now the renderers keep, for 64 places along the sweep of each blade (the value of the wiper mask),
the rain fallen when the blade last went over them (gl::scene_ubs::wiper_rain_pass, marked for all
the places a blade went over since the last frame), and the glass reads the one of its pixel.
wiper_rain_out / wiper_rain_return are gone; the timers and the insects keep the ends of the sweep.

No assets change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BqfRrTiBDaAyQ2gT6ZrnZD
2026-11-29 11:39:10 +01:00
Claude dbad19b92a Rain windscreen: the glass fills up to full in any rain, more slowly in a lighter one
The game now counts the rain the glass meets (more at speed) and how wet the glass is (scene_ubs.rain_state: it fills with the
rain and dries when the rain stops), and the rain fallen when each blade was at the end of its sweep (wiper_rain_out/return).
The glass with rain gets as many drops, droplets, rivulets and as much haze as the heaviest rain gives, scaled by how wet it
is; where a blade went over it they come back with the rain fallen since. A lighter rain only takes longer: 95% full in 10 s of
the heaviest rain standing still, 20 s at cloud cover 1.5, 2.5x as fast at 100 km/h; half dry in 3 minutes standing still.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BqfRrTiBDaAyQ2gT6ZrnZD
2026-11-29 11:39:10 +01:00
Claude 77e4abadae Rain: the cab in the depth prepass also in the rain
In the rain the cab is drawn after the precipitation (so the rain inside it is hidden), and it was left out of the depth
prepass too, so the opaque pass shaded everything behind it. Its depth now goes into the prepass in any weather (Vulkan 1.4,
and OpenGL 4.6 without gfx.depthprepass.replay); the colour of the cab is still drawn after the rain, so nothing changes in
the picture.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BqfRrTiBDaAyQ2gT6ZrnZD
2026-11-29 11:39:10 +01:00
Claude 394e252daf Rain windscreen: the cells of the drops and rivulets worked out once a frame
The glass with rain worked out, in every pixel, the hashes and the life cycles of the 9 drop cells around it, of the rivulet
cells of its 5 layers and of those the drops are swept by. A compute pass (rain_cells.comp) now does it once a frame for every
cell into a buffer (rain_cells.glsl: RAIN_CELLS_SSBO in the pass set of Vulkan 1.4, binding 18 in OpenGL 4.6); the glass only
reads it, and asks the wipers only for the drops the pixel lies on. The hashes are the same, so the drops and the rivulets
are where they were.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BqfRrTiBDaAyQ2gT6ZrnZD
2026-11-29 11:39:09 +01:00
lcddisplay 0df374a5e9 Vulkan 1.4: a material can have its own vertex shader, mat_<name>.vert, also in the sun shadows
As in the OpenGL 4.6 renderer: Fetch_Shader() takes shaders/vk14/mat_<name>.vert when the file is there (the animals and
people animated by textures, mat_vat.vert), vertex.vert otherwise; the multi draw variant is made of the same one. Such a
material gets the programs of its sun shadows with it: its vertex shader with MATERIAL_SHADOW and (alpha)shadowmap.frag,
drawn with all its textures and its params, also from the gpu culling (the draws of one such material go together). The
cube maps of the lamps keep their programs, the depth prepass leaves these materials out (prepass class 0).

The scene block carries the rotation and the place of the camera of each sun cascade and headlight map (inv_view,
camera_hi, camera_lo, gl::set_camera_place()), and those of the view in the colour pass, so the shaders see a model in the
world the same way in every pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GXgG7F4L42c2F9sDSAJbT2
2026-11-29 11:39:09 +01:00
Claude 03766899af Windscreen post pass in every frame: drops and haze also standing still, with any anti-aliasing
The velocity target is always drawn and the motion blur pass always runs;
the motion itself is blurred only when the motion blur is on and something
moves (by 0 otherwise). The rain and bugs windscreens send their drops and
haze through it, so they look the same with MSAA, TAA or none, moving or not.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BqfRrTiBDaAyQ2gT6ZrnZD
2026-11-29 11:39:08 +01:00
Claude 12d7fbb00e Windscreen bugs from the insects met: none below 20 km/h, more the faster
The engine counts the insects the vehicle of the wipers meets (seconds of
driving at 100 km/h: nothing below 20 km/h, then (v - 20) / 80 a second) and
gives the count to the shaders in rain_wind.w, with the count of the moments
the blades were at the ends of their sweep in two new vec4 at the end of the
block of the scene (wiper_bugs_out, wiper_bugs_return, next to the timers).
mat_bugs_windscreen grows the dirt from the insects met since the glass was
clean instead of from the time, so a vehicle standing still gets no bugs and
a fast one gets them sooner (full after an hour at 100 km/h).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BqfRrTiBDaAyQ2gT6ZrnZD
2026-11-29 11:39:08 +01:00
Claude a9d9c74a70 Keep the wiper timers of the windscreen when the camera leaves the cab
The moments the blades were at the ends of their sweep (wiper_timer_out /
wiper_timer_return, the drops on the glass come back from then) were set to
-1000 whenever the camera wasn't in an active cab, so the glass came back
fully wet on the return to the cab, and stayed so until the blades reached
the end of their sweep again.

They now follow the train driven while the camera is outside it (or the
vehicle of the camera, as before, when it's in an active cab) and are kept;
they're forgotten only when another vehicle is followed. Both renderers
(OpenGL 4.6 and Vulkan).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BqfRrTiBDaAyQ2gT6ZrnZD
2026-11-29 11:39:08 +01:00
Hirek 38b1110d1b Merge origin/staging into cleanup/mover
Staging's 7 commits since 62f7a29b. Two of them changed files this branch
split up, so their changes are carried into the new files by hand:
- #445 (the decisions of an uphill start in uphill_start::): the changes to
  TController::control_tractive_force() and control_uphill_start() of
  vehicle/Driver.cpp go into vehicle/ai/force.cpp, with the names of this
  branch (VehicleEnd::front, ->physics)
- #530 (the lowpoly driver figure follows the direction in single desk
  vehicles): the figure in ABuLittleUpdate() goes into
  vehicle/dynamic/visual.cpp; the reading of cab1model:/cab2model: and of
  driverNpos:/driverNsitpos: goes into the helpers of the internaldata:
  section in vehicle/dynamic/mmd.cpp, which pass the cab places along
  (loadInternalDataKeyword, loadInternalDataDeviceKeyword,
  loadInternalDataCabKeyword); read_driver_position() takes the tokens no
  group of keywords knows, as the last else of the chain did
vehicle/Driver.cpp and vehicle/DynObj.cpp stay deleted. The rest merged on
its own. 1185/1185 tests, golden traces exact against staging 62f7a29b.
2026-11-29 04:00:11 +01:00
Hirek d0387753f8 refactor(physics): TMoverParameters becomes physics::Vehicle, the mover is gone
The physics of a vehicle loses the name it had from the Pascal of 2001. Done by
tools/rename/mover_to_physics.py, committed with it:

  physics/mover.h                  physics/vehicle.h
  TMoverParameters                 physics::Vehicle (in namespace physics)
  TDynamicObject::MoverParameters  physics
  mvOccupied, mvControlled         occupied, controlled (TTrain, TController)
  mvSecond, mvThird                secondUnit, thirdUnit
  mvPantographUnit                 pantographUnit
  mover, Mover, movers             physics, Physics, vehicles (locals, params)
  m_mover, othermover, currentMover, from_movers, renderMoverEventSounds
                                   m_physics, otherPhysics, currentPhysics,
                                   from_vehicles, renderPhysicsEventSounds

The code and the comments are renamed, the string literals are not: no text
the game shows, logs or looks up has changed (none had the names). The movers
of the editor, the tracks a slide moves, keep their name.

By hand: two member functions of TDynamicObject (gather_off_track_terrain,
begin_off_track) had a local mover aliasing their own MoverParameters, which
the rename made physics { *physics }; the alias is gone, they use physics->.
No other function has a renamed local meeting a renamed member (checked over
all the functions of the code before the rename).

For the branches made before it: run the script on the branch (python
tools/rename/mover_to_physics.py, from the root of the repository) before
merging it with this one, and the names don't conflict. It can be run again;
the second time it changes nothing.

The class is the same as it was; breaking it into its parts (braking,
electrics, controls, load) and making its data private are the next stages.

No change in behaviour: 1149/1149 tests, golden traces exact against staging
62f7a29b.
2026-11-28 23:56:46 +01:00
jerrrrycho 702b552780 fix(render): particle vertex attribute offsets from offsetof in the GL 4.6 and Vulkan renderers (#511)
* fix(render): particle vertex attribute offsets from offsetof

* fix(render): particle vertex attribute offsets from offsetof in the GL 4.6 and Vulkan renderers

The GL 4.6 particles passed 0, 12 and 28 to setup_attrib, the Vulkan layout of
vertex_kind::particle had the stride 36 and the same offsets as numbers. They
now come from sizeof and offsetof of particle_vertex. The Vulkan particle_vertex
moves from vulkan14frame.cpp to vulkan14context.h so the layout in
vulkan14scene.cpp can use it.

A build with static_asserts that each offsetof equals the old number (and the
size 36) compiled; the asserts were taken out after.
2026-11-27 23:51:25 +01:00
Hirek 19f884cdbb refactor(physics): the vehicle vocabulary in physics/vehicletypes.h; DynObj.h and Driver.h no longer include mover.h
DynObj.h included physics/mover.h, so nearly every file of the simulator
compiled the whole vehicle physics (TMoverParameters and the brakes) though
most of them only name a vehicle end, a coupling or a light.

- physics/vehicletypes.h: the enums, flags and small structures the rest of
  the simulator passes around (end, side, coupling, light, sound, activation,
  train_type, TEngineType, TBrakeSystem..., TLocation, TTrackShape,
  neighbour_data), moved from mover.h as they were. mover.h includes it.
- DynObj.h and Driver.h include vehicletypes.h; TMoverParameters is forward
  declared (utilities/Classes.h). Their inline accessors that read the mover
  (NextConnected(), GetVelocity(), is_emu(), DirectionalVel()...) are defined
  in DynObj.cpp and Driver.cpp.
- the files that use the mover include physics/mover.h themselves.

Now 140 of the 730 objects of the build depend on mover.h and brakes.h,
about 80 of them unit tests.

No change in behaviour: 1142/1142 tests, golden traces exact against staging
62f7a29b.
2026-11-27 18:53:06 +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
Hirek ad71963a4e fix(render): the Vulkan renderer checks its cache files, backs off when memory runs out and keeps its threads alive through any exception 2026-11-25 15:29:31 +01:00
Hirek b0ebd83475 Merge branch 'feat/gl46-migration' of https://github.com/MaSzyna-EU07/maszyna into feat/renderers-cleanup 2026-11-25 15:29:12 +01:00
Hirek 43c46952ab perf(render): the Vulkan renderer resolves MSAA once a pass, keeps the window of the draw blocks and makes the multi draw shaders and ray tracing textures in the background 2026-11-25 10:27:31 +01:00
Hirek e0f07fde71 fix(render): the Vulkan renderer doesn't hang on exit, draw a minimized window with a NaN projection or quit on a lost surface 2026-11-25 09:34:58 +01:00
pol102 4ba8d508ca fix(gl46, vk14): keep the loading screen up while the shaders and pipelines are prepared, instead of a black window (#476)
* fix(gl46): the loading screen stays until the shaders are compiled, no black window at the first start of a new version

At the first start of a new build (the driver keeps the compiled shaders of each executable apart, and every build has a name of
its own) the window went black and didn't answer for about half a minute after the scenery was loaded. Measured on
calkowo_osobowy with a copy of the executable under a new name: 33 of those seconds were the first step of the water on the
windscreens, which compiled its nine programs (water_*.comp) in the first frame of the simulation.

- After the scenery is loaded the loader keeps its screen, with the bar going and the note on preparing the graphics, until the
  renderer says the programs are ready (gfx_renderer::Prewarm_Shaders(), about 50 ms a frame): the programs of the materials
  are drawn with once each into a small target of the formats of the colour pass, as the opaque things and as the translucent
  ones, then the programs of the windscreen water are compiled one a frame (opengl46_windscreen_water::prepare_next()), which
  gpu_init() then keeps. The window answers in between.
- The Vulkan renderer, which has its pipeline cache, says it's all done at once (the default of the interface).

Checked with a copy of the executable under a new name (nothing kept by the driver): the loading screen with the note from the
end of the loading (19 s) to the first frame (58 s), the window answering all the time; the first frame no longer stalls (the
water 12 ms instead of 33 s). With the shaders kept by the driver the preparing takes no time.

No asset changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(gl46): the missing program of the windscreen water found by find_if, which GCC 13 and MSVC 14.4x compile

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(loading): the notice that the graphics are being prepared at the top of the screen

The notice stood at the bottom left, beside where the loading icon goes, over the trivia and the texts some
of the backgrounds carry at the bottom. It is now centred at the top of the screen on a dark plate, so it
reads on any background. The text and its translation are the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(vk14): the loading screen stays until the pipelines of the scene are made, as with OpenGL 4.6

vulkan14_renderer::Prewarm_Shaders() lists the pipelines the loaded scenery draws with most: those of the
programs of its materials for the colour pass of the main view, opaque and blended, and those of the
shadows. With the background threads (gfx.vulkan.asyncresources) they are handed to them, made ahead and
not counted as made late; without them they are made on the main thread for about 50 ms a frame. The
loading screen, with its notice and progress bar, waits for them and for the pipelines of the last
session the background threads make ahead. Before, a pipeline first asked for by a draw either left the
draw out for a few frames or held the frame while it was made.

The images of a viewport are made by make_viewport_targets(), taken out of render_scene() unchanged, so
the main view's formats are known before the first frame. The key and the settings of a pipeline come
from the same helpers bind_scene_pipeline() uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(gl46, vk14): the review of #476: the multi draw variants prewarmed with a model block, the last session's list in the progress

OpenGL 4.6: with gfx.gpucull 1 and the multi draws on, Prewarm_Shaders() also draws the multi draw variants
of the material programs. Their shaders read the model block from the storage buffer at
MODEL_DRAW_SSBO_BINDING, which nothing bound before the first frame, so the draw was undefined. The
prewarm now binds a buffer of one model block there. With the default gfx.gpucull 0 there are no such
variants and nothing changes.

Vulkan: the loading screen waits for the background threads, and so for the list of the last session, up
to 4096 pipelines. With a cold cache the bar stood at n/(n+1) all that time and looked stuck. The
pipelines of that list are now counted in the progress as they are done with, made or not. The wait still
ends when the background threads are idle, as before.

make_viewport_targets() returns false without a context, which Sonar reported as a null pointer
dereference. Its callers checked the context already.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QRgQ1LqB4YXWorLDBBL6hD

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 05:14:33 +01:00
Hirek 51c76da927 fix(render): the free camera blurs with its own movement in the OpenGL 4.6 and Vulkan renderers 2026-11-23 20:55:50 +01:00
Hirek 9071d3f4d3 Improved water shader 2026-11-16 22:55:33 +01:00
Hirek b8815a2455 Optimise raytracing and buffer building 2026-11-16 22:19:17 +01:00
Hirek ff2ff308ed Some optimalisations 2026-11-09 20:58:02 +01:00
Hirek 7078edf138 fix(vulkan): read back the editor cursor depth and correct the depth pass bias 2026-10-30 01:33:41 +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 9904eddd0d Light the cab with cablight/dashboardlight light points of the cab model 2026-10-28 20:55:45 +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 ac0b4e5f15 Add a white balance to the tonemapping 2026-10-27 01:40:19 +01:00
Hirek 719c729929 Improve rain shader 2026-10-26 15:51:56 +01:00
Hirek a6bdeeaa2b Add DLSS Frame Generation (gfx.framegeneration x2/x3/x4) and Reflex (gfx.reflex) to the Vulkan renderer 2026-10-25 20:52:12 +01:00
Hirek 1841e6d7b0 Add NVIDIA DLSS to the Vulkan renderer (gfx.antialiasing dlss/dlaa) and gfx.buffer.percent 2026-10-25 19:35:33 +01:00
Hirek 71a6628a4a Vulkan ray tracing: shade the heightmap terrain from its layers; longer default SSR range 2026-10-25 17:15:58 +01:00
Hirek e201c83825 Vulkan ray tracing: trace only visible reflections, sun shadow from the shadow map, foliage switch and timings 2026-10-25 16:09:19 +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 cdacb4110b Vulkan ray tracing: test the gathered scene around the camera, not the world origin 2026-10-25 14:53:06 +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 c48c58776a Vulkan: parity with GL (P1–P7), shared GPU culling records (N6c), threaded command recording and render thread (M1, M4) 2026-10-25 03:06:01 +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