Skip to content

Commit

Permalink
Fix artifact (#802)
Browse files Browse the repository at this point in the history
* adjust shader for lane line rendering

* add multi sample

* use 1024 for scenarioEnv
  • Loading branch information
QuanyiLi authored Jan 19, 2025
1 parent e84da02 commit 2afd69f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions metadrive/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,8 @@ class MapTerrainSemanticColor:
Do not modify this as it is for terrain generation. If you want your own palette, just add a new one or modify
class lMapSemanticColor
"""
YELLOW = 10
WHITE = 30
YELLOW = 30
WHITE = 10

@staticmethod
def get_color(type):
Expand Down
1 change: 1 addition & 0 deletions metadrive/engine/core/engine_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ def __init__(self, global_config):
self.world_light.attach_to_world(self.render, self.physics_world)
self.render.setLight(self.world_light.direction_np)
self.render.setLight(self.world_light.ambient_np)
self.render.setAntialias(AntialiasAttrib.MAuto)

# setup pssm shadow
# init shadow if required
Expand Down
2 changes: 1 addition & 1 deletion metadrive/engine/core/terrain.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __init__(self, show_terrain, engine):

# visualization mesh feature
self._terrain_size = TerrainProperty.map_region_size # [m]
self._height_scale = engine.global_config["height_scale"] # [m]
self._height_scale = engine.global_config["height_scale"] * self._terrain_size / 2048 # [m]
self._drivable_area_extension = engine.global_config["drivable_area_extension"] # [m] road marin
# it should include the whole map. Otherwise, road will have no texture!
self._heightmap_size = self._semantic_map_size = TerrainProperty.map_region_size # [m]
Expand Down
2 changes: 1 addition & 1 deletion metadrive/envs/scenario_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
store_data=True,
need_lane_localization=True,
no_map=False,
map_region_size=2048,
map_region_size=1024,
cull_lanes_outside_map=True,

# ===== Scenario =====
Expand Down
20 changes: 10 additions & 10 deletions metadrive/shaders/terrain.frag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,18 @@ void main() {
vec3 diffuse = vec3(0.0, 0.0, 0.0);
vec3 tex_normal_world;
// float roughnessValue;
if (attri.r > 0.01){
float value = attri.r * 255; // Assuming it's a red channel texture
if (value < 14) {
// yellow
diffuse=vec3(1.0, 0.78, 0.0);
} else if (value < 23) {
// road
diffuse = texture(road_tex, terrain_uv * road_tex_ratio).rgb;
} else if (value < 31) {
float value = attri.r * 255; // Assuming it's a red channel texture
if (value > 5){
if (value < 16) {
// white
diffuse = vec3(1.0, 1.0, 1.0);
} else if (value > 39 || value < 221) {
} else if (value < 26) {
// road
diffuse = texture(road_tex, terrain_uv * road_tex_ratio).rgb;
} else if (value < 34) {
// yellow
diffuse=vec3(1.0, 0.78, 0.0);
} else if (value > 39 || value < 222) {
// crosswalk
float theta=(value-40) * 2/180.0*3.1415926535;
vec2 new_terrain_uv = vec2(cos(theta)*terrain_uv.x - sin(theta)*terrain_uv.y, sin(theta)*terrain_uv.x+cos(theta)*terrain_uv.y);
Expand Down

0 comments on commit 2afd69f

Please sign in to comment.