#Depth Bias Not Working?

10 messages · Page 1 of 1 (latest)

plucky oxide
#

Depth bias does not seem to work (unless I misunderstand what it is?). In the image attached, you can see that I have a 'select border' when I select my units. The entire select border should be visible, but as you can see, half of it extends through the floor.

My ground has a depth bias of NEG_INFINITY:

Mesh3d(meshes.add(Plane3d::default().mesh().size(MAP_WIDTH, MAP_DEPTH))),
MeshMaterial3d(materials.add(StandardMaterial {
    base_color: Color::srgb(0.3, 0.5, 0.3),
    depth_bias: NEG_INFINITY,
    ..Default::default()
})),

My select border has a depth bias of INFINITY

Mesh3d(meshes.add(Rectangle::new(17.0, 17.0))), // TODO: the size needs to be dynamic for various units
MeshMaterial3d(materials.add(StandardMaterial {
    base_color_texture: Some(my_assets.select_border.clone()),
    depth_bias: INFINITY, // TODO: Not working?
    alpha_mode: AlphaMode::Blend,
    unlit: true,
    ..default()
})),

I also tried the other way around to no avail.

austere tapir
#

how about using RenderLayers to show your hints ?

plucky oxide
#

@austere tapir I haven't tried, although that sounds like it would work. I'll see what I can do after work. Still curious why this doesn't work though or even why 'depth_bias' exists. Thanks!

austere tapir
#

I didn't look at the program carefully at first and thought you were drawing the borders in 2D.

plucky oxide
#

@austere tapir I couldnt get render layers to work, nor am I sure that if that would be the right approach here. I ended up spawning the border select boxes as UI elements and then basically converted the tanks position from world space to screen space, and then assigned the border that converted translation. There was a few hiccups in the process, but that is the TLDR version. I appreciate the help!

austere tapir
#

I remember that each Layer needs to have its own camera, and the Layer needs to be specified when creating an entity.

plucky oxide
austere tapir
#

You can use 2D Camera to display 2D UI, and 3D Camera to display the 3D world.