From eac44ded78c9d2ce32d336de5c9eadaeb92da870 Mon Sep 17 00:00:00 2001 From: Schmarni Date: Tue, 2 Sep 2025 06:12:16 +0200 Subject: [PATCH] fix(lines): fix the lines material shader Signed-off-by: Schmarni --- src/nodes/drawable/line.wgsl | 9 +-------- src/nodes/drawable/lines.rs | 25 +------------------------ 2 files changed, 2 insertions(+), 32 deletions(-) diff --git a/src/nodes/drawable/line.wgsl b/src/nodes/drawable/line.wgsl index 440a47b..e227143 100644 --- a/src/nodes/drawable/line.wgsl +++ b/src/nodes/drawable/line.wgsl @@ -27,19 +27,12 @@ fn fragment( in: VertexOutput, @builtin(front_facing) is_front: bool, ) -> FragmentOutput { -#ifdef VERTEX_COLORS - var out: FragmentOutput; - // apply lighting - out.color = in.color; - return out; -#endif - // generate a PbrInput struct from the StandardMaterial bindings var pbr_input = pbr_input_from_standard_material(in, is_front); #ifdef VERTEX_COLORS // Multiply emissive color by vertex color - pbr_input.material.emissive.rgb *= in.color.rgb; + pbr_input.material.emissive *= vec4(in.color.rgb, 1.0); #endif // alpha discard diff --git a/src/nodes/drawable/lines.rs b/src/nodes/drawable/lines.rs index 4282b05..d587df9 100644 --- a/src/nodes/drawable/lines.rs +++ b/src/nodes/drawable/lines.rs @@ -56,7 +56,6 @@ impl MaterialExtension for LineExtension { pub struct LinesNodePlugin; impl Plugin for LinesNodePlugin { fn build(&self, app: &mut App) { - app.add_systems(Startup, test_cube); app.add_systems(Update, build_line_mesh); app.world_mut().resource_mut::>().insert( LINE_SHADER_HANDLE.id(), @@ -73,28 +72,6 @@ impl Plugin for LinesNodePlugin { } } -fn test_cube( - mut cmds: Commands, - mut meshes: ResMut>, - mut materials: ResMut>, -) { - cmds.spawn(( - Transform::from_xyz(0.0, 0.5, 0.0), - Mesh3d(meshes.add(Cuboid::default())), - MeshMaterial3d(materials.add(ExtendedMaterial { - base: BevyMaterial { - base_color: Color::WHITE, - perceptual_roughness: 1.0, - // TODO: this should be Blend - alpha_mode: AlphaMode::Opaque, - // emissive: Color::srgba_u8(128, 128, 128, 255).into(), - ..default() - }, - extension: LineExtension { unused: 0 }, - })), - )); -} - fn build_line_mesh( mut cmds: Commands, mut meshes: ResMut>, @@ -259,7 +236,7 @@ fn build_line_mesh( perceptual_roughness: 1.0, // TODO: this should be Blend alpha_mode: AlphaMode::Opaque, - // emissive: Color::srgba_u8(128, 128, 128, 255).into(), + emissive: Color::srgba_u8(128/4, 128/4, 128/4, 255).into(), ..default() }, extension: LineExtension { unused: 0 },