Skip to content

Commit

Permalink
merge everything into master (#4)
Browse files Browse the repository at this point in the history
* disable anisotropic setting

* opencv-headless

* mac
  • Loading branch information
maxime-desroches committed Aug 12, 2024
1 parent c921830 commit 0dd67b8
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 28 deletions.
2 changes: 1 addition & 1 deletion metadrive/component/block/base_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __init__(
self.side_texture.setWrapU(Texture.WM_repeat)
self.side_texture.setWrapV(Texture.WM_repeat)
self.side_texture.setMinfilter(SamplerState.FT_linear_mipmap_linear)
self.side_texture.setAnisotropicDegree(8)
self.side_texture.setAnisotropicDegree(1)
self.side_normal = self.loader.loadTexture(AssetLoader.file_path("textures", "sidewalk", "normal.png"))
# self.side_normal.set_format(Texture.F_srgb)
self.side_normal.setWrapU(Texture.WM_repeat)
Expand Down
29 changes: 15 additions & 14 deletions metadrive/engine/core/engine_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 3 additions & 7 deletions metadrive/engine/core/sky_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self, pure_background: bool = False):
skybox_texture.set_magfilter(SamplerState.FT_linear)
skybox_texture.set_wrap_u(SamplerState.WM_repeat)
skybox_texture.set_wrap_v(SamplerState.WM_mirror)
skybox_texture.set_anisotropic_degree(16)
skybox_texture.set_anisotropic_degree(1)
skybox.set_texture(skybox_texture)

gles = ConfigVariableString("load-display").getValue()
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions metadrive/engine/core/terrain.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ def _load_mesh_terrain_textures(self, engine, anisotropic_degree=16, filter_type
tex.set_wrap_v(v_wrap)
tex.setMinfilter(filter_type)
tex.setMagfilter(filter_type)
tex.setAnisotropicDegree(anisotropic_degree)
tex.setAnisotropicDegree(1)

# rock
self.rock_tex = self.loader.loadTexture(
Expand All @@ -464,7 +464,7 @@ def _load_mesh_terrain_textures(self, engine, anisotropic_degree=16, filter_type
tex.set_wrap_v(v_wrap)
tex.setMinfilter(filter_type)
tex.setMagfilter(filter_type)
tex.setAnisotropicDegree(anisotropic_degree)
tex.setAnisotropicDegree(1)

# # sidewalk
# self.side_tex = self.loader.loadTexture(AssetLoader.file_path("textures", "sidewalk", "color.png"))
Expand Down Expand Up @@ -496,7 +496,7 @@ def _load_mesh_terrain_textures(self, engine, anisotropic_degree=16, filter_type
tex.set_wrap_v(v_wrap)
tex.setMinfilter(filter_type)
tex.setMagfilter(filter_type)
tex.setAnisotropicDegree(anisotropic_degree)
tex.setAnisotropicDegree(1)
# self.road_texture_displacement = self.loader.loadTexture(AssetLoader.file_path("textures", "sci", "normal.jpg"))
# self.road_texture.setMinfilter(minfilter)
# self.road_texture.setAnisotropicDegree(anisotropic_degree)
Expand Down
4 changes: 2 additions & 2 deletions metadrive/shaders/terrain.frag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -233,4 +233,4 @@ void main() {
// shading = vec3(0, 1, 1);
// }
color = vec4(shading, 1.0);
}
}
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def is_win():
"panda3d-gltf==0.13", # 0.14 will bring some problems
"pillow",
"pytest",
"opencv-python",
"opencv-python-headless",
"lxml",
"scipy",
"psutil",
Expand Down

0 comments on commit 0dd67b8

Please sign in to comment.