From 7d7c7165822d9c97bb048d6b27d1f07fe0897d8c Mon Sep 17 00:00:00 2001 From: Maxime Desroches Date: Mon, 12 Aug 2024 15:58:11 -0700 Subject: [PATCH] mac --- metadrive/engine/core/engine_core.py | 29 ++++++++++++++-------------- metadrive/engine/core/sky_box.py | 8 ++------ metadrive/shaders/terrain.frag.glsl | 4 ++-- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/metadrive/engine/core/engine_core.py b/metadrive/engine/core/engine_core.py index cdd529939..e4978e9c5 100644 --- a/metadrive/engine/core/engine_core.py +++ b/metadrive/engine/core/engine_core.py @@ -83,8 +83,6 @@ class EngineCore(ShowBase.ShowBase): DEBUG = False global_config = None # global config can exist before engine initialization loadPrcFileData("", "window-title {}".format(EDITION)) - loadPrcFileData("", "framebuffer-multisample 1") - loadPrcFileData("", "multisamples 8") loadPrcFileData("", "bullet-filter-algorithm groups-mask") loadPrcFileData("", "audio-library-name null") loadPrcFileData("", "model-cache-compressed-textures 1") @@ -98,14 +96,19 @@ class EngineCore(ShowBase.ShowBase): # loadPrcFileData("", "allow-incomplete-render #t") # loadPrcFileData("", "# even-animation #t") - # loadPrcFileData("", " framebuffer-srgb truein") # loadPrcFileData("", "geom-cache-size 50000") # v-sync, it seems useless # loadPrcFileData("", "sync-video 1") - # for debug use - # loadPrcFileData("", "gl-version 3 2") + if is_mac(): + # latest macOS supported openGL version + loadPrcFileData("", "gl-version 4 1") + loadPrcFileData("", " framebuffer-srgb truein") + else: + # anti-aliasing does not work on macOS + loadPrcFileData("", "framebuffer-multisample 1") + loadPrcFileData("", "multisamples 8") def __init__(self, global_config): # if EngineCore.global_config is not None: @@ -160,9 +163,6 @@ def __init__(self, global_config): # Disable useless camera capturing in none mode self.global_config["show_interface"] = False - if is_mac() and (self.mode == RENDER_MODE_OFFSCREEN): # Mac don't support offscreen rendering - self.mode = RENDER_MODE_ONSCREEN - loadPrcFileData("", "win-size {} {}".format(*self.global_config["window_size"])) if self.use_render_pipeline: @@ -294,12 +294,13 @@ def __init__(self, global_config): if self.global_config["daytime"] is not None: self.render_pipeline.daytime_mgr.time = self.global_config["daytime"] else: - self.pbrpipe = init( - msaa_samples=16, - use_hardware_skinning=True, - # use_normal_maps=True, - use_330=False - ) + if not is_mac(): + self.pbrpipe = init( + msaa_samples=16, + use_hardware_skinning=True, + # use_normal_maps=True, + use_330=False + ) self.sky_box = SkyBox(not self.global_config["show_skybox"]) self.sky_box.attach_to_world(self.render, self.physics_world) diff --git a/metadrive/engine/core/sky_box.py b/metadrive/engine/core/sky_box.py index b611cf388..6cffde35c 100644 --- a/metadrive/engine/core/sky_box.py +++ b/metadrive/engine/core/sky_box.py @@ -40,12 +40,8 @@ def __init__(self, pure_background: bool = False): AssetLoader.file_path("../shaders", "skybox_gles.frag.glsl") ) else: - if is_mac(): - vert_file = "skybox_mac.vert.glsl" - frag_file = "skybox_mac.frag.glsl" - else: - vert_file = "skybox.vert.glsl" - frag_file = "skybox.frag.glsl" + vert_file = "skybox.vert.glsl" + frag_file = "skybox.frag.glsl" skybox_shader = Shader.load( Shader.SL_GLSL, AssetLoader.file_path("../shaders", vert_file), AssetLoader.file_path("../shaders", frag_file) diff --git a/metadrive/shaders/terrain.frag.glsl b/metadrive/shaders/terrain.frag.glsl index c7189705c..4f0d03f4c 100644 --- a/metadrive/shaders/terrain.frag.glsl +++ b/metadrive/shaders/terrain.frag.glsl @@ -201,7 +201,7 @@ void main() { float radius = 0.001; // Sample radius for(int x = -1; x <= 1; x++) { for(int y = -1; y <= 1; y++) { - float depth_sample = texture2D(PSSMShadowAtlas, projected_coord.xy + vec2(x, y) * radius).r; + float depth_sample = texture(PSSMShadowAtlas, projected_coord.xy + vec2(x, y) * radius).r; shadow_factor += step(ref_depth, depth_sample); } } @@ -233,4 +233,4 @@ void main() { // shading = vec3(0, 1, 1); // } color = vec4(shading, 1.0); -} \ No newline at end of file +}