MetaDrive: Rendering images into the 3D environment #707
-
Hi, First of all, thanks for this great project! I'm using MetaDrive for robustness testing of DNN-based lane detection algorithms. Is it possible to do this with existing functions in the project? Thanks for any tips! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Ahh, I see. That's interesting. First, You need to modify this function: metadrive/metadrive/engine/core/terrain.py Line 590 in 233a3a1 terrain.frag.glsl . You also new to modify this shader program by
if ((attri.r > 0.01) && (terrain_uv.x>=r_min) && (terrain_uv.y >= r_min) && (terrain_uv.x<=r_max) && (terrain_uv.y<=r_max)){
float value = attri.r; // Assuming it's a red channel texture
if (value < 0.11) {
// yellow
diffuse=texture(yellow_tex, terrain_uv * road_tex_ratio).rgb;
} else if (value < 0.21) {
// road
diffuse = texture(road_tex, terrain_uv * road_tex_ratio).rgb;
} else if (value < 0.31) {
// white
diffuse = texture(white_tex, terrain_uv * road_tex_ratio).rgb;
} else if (value > 0.3999 || value < 0.760001) {
// crosswalk
float theta=(value-0.39999) * 1000/180 * 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);
diffuse = texture(crosswalk_tex, new_terrain_uv * road_tex_ratio).rgb;
} else{
// Semantics for value 4
diffuse = texture(white_tex, terrain_uv * road_tex_ratio).rgb;
}
tex_normal_world = get_normal(diffuse, road_normal, road_rough, road_tex_ratio, tbn);
} |
Beta Was this translation helpful? Give feedback.
-
Hey, I have a follow-up question. I got most of the rendering working, but I still struggle with one thing: the texture appearance in the render for the main+RGB cams: In the best case, the rendered model would be as bright as the original texture image. As a first step, I disabled the SimplePBR Pipeline in the And for placing the patch, I'm using a canvas .egg model with the following code:
I already experimented a little bit with the Any tips would be very appreciated (and a big thanks for the help so far). Update: I used a similar technique as used in the semantic map by creating a "magic number" that I can use in the shader to differentiate my custom texture. I assigned a material with
And can then adjust the color of the texture so it matches the original texture image. I use a similar approach in the tonemap shader. |
Beta Was this translation helpful? Give feedback.
Ahh, I see. That's interesting. First, You need to modify this function:
metadrive/metadrive/engine/core/terrain.py
Line 590 in 233a3a1
terrain.frag.glsl
. You also new to modify this shader program by