Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for gltf::Material::unlit #1341

Merged
merged 7 commits into from
Feb 1, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/bevy_gltf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ bevy_math = { path = "../bevy_math", version = "0.4.0" }
bevy_scene = { path = "../bevy_scene", version = "0.4.0" }

# other
gltf = { version = "0.15.2", default-features = false, features = ["utils", "names"] }
gltf = { version = "0.15.2", default-features = false, features = ["utils", "names", "KHR_materials_unlit"] }
image = { version = "0.23.12", default-features = false }
thiserror = "1.0"
anyhow = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_gltf/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ fn load_material(material: &Material, load_context: &mut LoadContext) -> Handle<
LoadedAsset::new(StandardMaterial {
albedo: Color::rgba(color[0], color[1], color[2], color[3]),
albedo_texture: texture_handle,
..Default::default()
unlit: !material.unlit(),
})
.with_dependencies(dependencies),
)
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_pbr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl Plugin for PbrPlugin {
Handle::<StandardMaterial>::default(),
StandardMaterial {
albedo: Color::PINK,
shaded: false,
unlit: true,
albedo_texture: None,
},
);
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_pbr/src/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ pub struct StandardMaterial {
pub albedo_texture: Option<Handle<Texture>>,
#[render_resources(ignore)]
#[shader_def]
pub shaded: bool,
pub unlit: bool,
}

impl Default for StandardMaterial {
fn default() -> Self {
StandardMaterial {
albedo: Color::rgb(1.0, 1.0, 1.0),
albedo_texture: None,
shaded: true,
unlit: false,
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void main() {
v_Uv);
# endif

# ifdef STANDARDMATERIAL_SHADED
# ifndef STANDARDMATERIAL_UNLIT
vec3 normal = normalize(v_Normal);
// accumulate color
vec3 color = AmbientColor;
Expand Down
6 changes: 3 additions & 3 deletions examples/3d/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@ fn setup(
// this material renders the texture normally
let material_handle = materials.add(StandardMaterial {
albedo_texture: Some(texture_handle.clone()),
shaded: false,
unlit: true,
..Default::default()
});

// this material modulates the texture to make it red (and slightly transparent)
let red_material_handle = materials.add(StandardMaterial {
albedo: Color::rgba(1.0, 0.0, 0.0, 0.5),
albedo_texture: Some(texture_handle.clone()),
shaded: false,
unlit: true,
});

// and lets make this one blue! (and also slightly transparent)
let blue_material_handle = materials.add(StandardMaterial {
albedo: Color::rgba(0.0, 0.0, 1.0, 0.5),
albedo_texture: Some(texture_handle),
shaded: false,
unlit: true,
});

// add entities to the world
Expand Down
6 changes: 3 additions & 3 deletions examples/3d/z_sort_debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn setup(
.spawn(PbrBundle {
mesh: cube_handle.clone(),
material: materials.add(StandardMaterial {
shaded: false,
unlit: true,
..Default::default()
}),
transform: Transform::from_xyz(0.0, 0.0, 1.0),
Expand All @@ -65,7 +65,7 @@ fn setup(
.spawn(PbrBundle {
mesh: cube_handle.clone(),
material: materials.add(StandardMaterial {
shaded: false,
unlit: true,
..Default::default()
}),
transform: Transform::from_xyz(0.0, 3.0, 0.0),
Expand All @@ -74,7 +74,7 @@ fn setup(
.spawn(PbrBundle {
mesh: cube_handle,
material: materials.add(StandardMaterial {
shaded: false,
unlit: true,
..Default::default()
}),
transform: Transform::from_xyz(0.0, -3.0, 0.0),
Expand Down