fix(lines): fix the lines material shader

Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
Schmarni
2025-09-02 06:12:16 +02:00
parent 2357cba5f9
commit eac44ded78
2 changed files with 2 additions and 32 deletions

View File

@@ -27,19 +27,12 @@ fn fragment(
in: VertexOutput, in: VertexOutput,
@builtin(front_facing) is_front: bool, @builtin(front_facing) is_front: bool,
) -> FragmentOutput { ) -> FragmentOutput {
#ifdef VERTEX_COLORS
var out: FragmentOutput;
// apply lighting
out.color = in.color;
return out;
#endif
// generate a PbrInput struct from the StandardMaterial bindings // generate a PbrInput struct from the StandardMaterial bindings
var pbr_input = pbr_input_from_standard_material(in, is_front); var pbr_input = pbr_input_from_standard_material(in, is_front);
#ifdef VERTEX_COLORS #ifdef VERTEX_COLORS
// Multiply emissive color by vertex color // 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 #endif
// alpha discard // alpha discard

View File

@@ -56,7 +56,6 @@ impl MaterialExtension for LineExtension {
pub struct LinesNodePlugin; pub struct LinesNodePlugin;
impl Plugin for LinesNodePlugin { impl Plugin for LinesNodePlugin {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
app.add_systems(Startup, test_cube);
app.add_systems(Update, build_line_mesh); app.add_systems(Update, build_line_mesh);
app.world_mut().resource_mut::<Assets<Shader>>().insert( app.world_mut().resource_mut::<Assets<Shader>>().insert(
LINE_SHADER_HANDLE.id(), LINE_SHADER_HANDLE.id(),
@@ -73,28 +72,6 @@ impl Plugin for LinesNodePlugin {
} }
} }
fn test_cube(
mut cmds: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<LineMaterial>>,
) {
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( fn build_line_mesh(
mut cmds: Commands, mut cmds: Commands,
mut meshes: ResMut<Assets<Mesh>>, mut meshes: ResMut<Assets<Mesh>>,
@@ -259,7 +236,7 @@ fn build_line_mesh(
perceptual_roughness: 1.0, perceptual_roughness: 1.0,
// TODO: this should be Blend // TODO: this should be Blend
alpha_mode: AlphaMode::Opaque, 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() ..default()
}, },
extension: LineExtension { unused: 0 }, extension: LineExtension { unused: 0 },