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

14 Commits

Author SHA1 Message Date
Hirek 5fab613d77 Merge branch 'feat/gl46-migration' of https://github.com/MaSzyna-EU07/maszyna into feat/renderers-cleanup 2026-11-27 10:18:00 +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 bd597146c3 Merge remote-tracking branch 'origin/staging' into feat/renderers-cleanup 2026-11-27 09:13:29 +01:00
jerrrrycho 57a0a71f48 fix(ci): build and run the shader validator again (#437)
* fix(ci): build and run the shader validator again

- gl/glsl_common.h and gl/shader.cpp include utilities/Globals.h and
  utilities/Logs.h now, so the stand-in headers of the validator move to
  ci_shadervalidator/utilities/.
- gl/ubo.h needs std::span and gl/shader.cpp uses contains(), so the
  script builds with -std=c++20. The stand-in stdafx.h gives <array>,
  <algorithm> and <string_view>, which the precompiled header of the
  simulator gives otherwise.
- build.sh runs from any directory and stops on the first error.
- glslang defines the GL_ARB_gpu_shader5 macro without the #extension
  directive, so light_common.glsl took its textureGather() path without
  the extension enabled and 25 material shaders failed on desktop GL with
  the shadows on. The validator adds the directive which the simulator
  gives on the drivers with the extension.
- The shader goes to the temporary directory of the system instead of a
  fixed /tmp, a shader which can't be preprocessed fails instead of
  ending the run, the shaders go in name order and the failed ones are
  listed at the end.

* fix(ci): write the validated shader to a unique temporary file

The shader validator wrote every preprocessed shader to a file with a
fixed name in the temporary directory (/tmp/shader on Linux) and opened
it with std::ofstream. In a shared /tmp anyone can create that name in
advance, as a file or a link to another file, and the validator would
then write through it (Sonar rule S5443, publicly writable directories).

The shader now goes to a file with a unique name which is created
exclusively: mkstemp() on Linux, and on Windows, which has no mkstemp(),
a random name opened with fopen_s(..., "wx"), which fails when the file
exists. The file is removed after glslangValidator has checked it, and
when it cannot be written completely. glslangValidator gets the stage
with -S, so the file still needs no extension.

* docs(ci): the standalone validator no longer checks the PCF fallback path

The comment of has_gl_extension() said the validator compiles the 16-tap
PCF fallback of light_common.glsl. Since the validator adds the
GL_ARB_gpu_shader5 directive itself, it checks the textureGather() path.
2026-11-25 05:12:15 +01:00
jerrrrycho 04b55c866a fix(render): alpha to coverage only where it is on, full coverage on flat alpha
Review of the alpha to coverage change for alpha tested surfaces:

- An alpha which is flat over the pixel (fwidth 0) and equal to the opacity
  threshold got a coverage of 0.5, so e.g. opacity 1 on an opaque or DXT1
  texture turned half see-through with multisampling. Without an alpha edge
  in the pixel the plain test decides now: step(opacity, alpha).
- The shaders took the coverage path whenever they were built with
  multisampling, also where alpha to coverage is off (the reflections pass)
  or does nothing (the single-sampled model previews), and grew the cut-outs
  there by about half a pixel. model_ubo gets an alpha_to_coverage flag, set
  together with the GL state, and the shaders keep the plain alpha test
  without it. The previews no longer turn alpha to coverage on. The flag
  takes 4 of the 12 padding bytes after shadow_tone, so the std140 layout and
  the size of the block stay the same.
- The shader validator never set iMultisampling, so it never compiled the
  alpha to coverage branches. Its "features on" configuration uses the
  default of 2 now, on desktop GL and GLES.
2026-11-08 20:03:32 +01:00
jerrrrycho aecc73e893 fix(render): antialias alpha tested edges with multisampling (eu07/maszyna#449)
The sides of the trackbed (and grass, fences, foliage) are cut out of their
textures by the alpha test, which keeps or drops whole pixels, so their edges
stayed jagged at any multisampling level; only geometry edges got smoothed.

With multisampling on, the alpha tested materials of the opaque colour pass
now draw with GL_SAMPLE_ALPHA_TO_COVERAGE. Their shaders do the alpha test
with alpha_test_fail() of glsl_common and write as alpha the coverage of the
test edge: the alpha sharpened around the opacity threshold to go from 0 to 1
over about a pixel, so the edge keeps the place it had and gets the samples
it covers. The renderer turns alpha to coverage on per material, only for
shaders which use the helper and only in the opaque pass with a positive
opacity, so translucent, water, terrain and the other shaders are unchanged.
Without multisampling the shaders work as before.
2026-11-08 01:34:35 +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
Hirek bd589f272d feat(vulkan): vulkan 1.4 core with the user interface and the launcher, shaders split into ogl46/vk14 with SPIR-V binaries loaded first 2026-10-24 05:47:11 +02:00
Hirek 494304903f Draw the instances from the GPU with multi draws, the model block of each draw read by its number 2026-10-18 00:47:05 +02:00
Hirek 9186819363 Validate shaders against GLSL 4.60 including compute stage 2026-10-15 02:20:22 +02:00
Hirek 0e10ce4d0b Remove OpenGL ES / ANGLE render path 2026-10-15 00:53:28 +02:00
milek7 56eba08a6f CI shader validation 2021-01-21 15:51:03 +01:00