bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
35.25k stars 3.47k forks source link

`depth_bias` is ignored on `StandardMaterial` #14169

Open DiSaber opened 2 months ago

DiSaber commented 2 months ago

Bevy version

0.14.0

Relevant system information

cargo 1.79.0 (ffa9cf99a 2024-06-03)
SystemInfo { os: "Windows 11 Pro", kernel: "22631", cpu: "AMD Ryzen 9 7950X 16-Core Processor", core_count: "16", memory: "31.6 GiB" }
AdapterInfo { name: "AMD Radeon RX 7900 XTX", vendor: 4098, device: 29772, device_type: DiscreteGpu, driver: "AMD proprietary driver", driver_info: "24.5.1 (LLPC)", backend: Vulkan }

What you did

Spawned a small plane mesh with a transparent ring texture and a depth_bias of f32::INFINITY.

(
    PbrBundle {
        mesh: meshes.add(Plane3d::new(Vec3::Y, Vec2::splat(0.3))),
        material: materials.add(StandardMaterial {
            base_color_texture: Some(
                asset_cache.cache(asset_server.load("textures/ring.ktx2")), // NOTE: `asset_cache.cache` simply clones the strong handle into a vector and returns the original handle
            ),
            base_color: Srgba::WHITE.with_alpha(0.12549019).into(), // 32 alpha
            alpha_mode: AlphaMode::Blend,
            unlit: true,
            depth_bias: f32::INFINITY, // Render the ring above all other 3d objects
            ..Default::default()
        }),
        transform: Transform::from_translation(Vec3::new(
            0.0,
            -HALF_PLAYER_HEIGHT - GROUND_OFFSET, // Places the ring exactly on the surface level
            0.0,
        )),
        ..Default::default()
    },
    NotShadowCaster,
)

What went wrong

Z-fighting: image

Additional information

This was previously functional on Bevy 0.13.2. As a "workaround" (probably how I should've done it from the beginning) I made a different camera on a higher render layer to render the ring on top of all other 3d meshes.

jakemoran commented 1 week ago

I have also been experiencing this issue.