mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-19 11:06:03 +01:00
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.
This commit is contained in:
@@ -277,6 +277,8 @@ class opengl33_renderer : public gfx_renderer {
|
||||
void setup_pass(viewport_config &Viewport, renderpass_config &Config, rendermode const Mode, float const Znear = 0.f, float const Zfar = 1.f, bool const Ignoredebug = false);
|
||||
void setup_matrices();
|
||||
void setup_drawing(bool const Alpha = false);
|
||||
// alpha to coverage for the alpha tested materials of the opaque colour pass, when multisampled
|
||||
void setup_alpha_to_coverage(bool const Enable);
|
||||
void setup_shadow_unbind_map();
|
||||
void setup_shadow_bind_map();
|
||||
void setup_shadow_color( glm::vec4 const &Shadowcolor );
|
||||
@@ -560,6 +562,7 @@ class opengl33_renderer : public gfx_renderer {
|
||||
material_handle m_invalid_material;
|
||||
|
||||
bool m_blendingenabled;
|
||||
bool m_alphatocoverageenabled{ false };
|
||||
|
||||
bool m_widelines_supported;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user