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

* Add support for gltf::Material::unlit
This commit is contained in:
Will Crichton 2021-01-31 20:13:16 -05:00 committed by GitHub
parent 06dbfffe2e
commit e6e23fdfa9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 12 additions and 12 deletions

View file

@ -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"

View file

@ -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),
)

View file

@ -46,7 +46,7 @@ impl Plugin for PbrPlugin {
Handle::<StandardMaterial>::default(),
StandardMaterial {
albedo: Color::PINK,
shaded: false,
unlit: true,
albedo_texture: None,
},
);

View file

@ -11,7 +11,7 @@ pub struct StandardMaterial {
pub albedo_texture: Option<Handle<Texture>>,
#[render_resources(ignore)]
#[shader_def]
pub shaded: bool,
pub unlit: bool,
}
impl Default for StandardMaterial {
@ -19,7 +19,7 @@ impl Default for StandardMaterial {
StandardMaterial {
albedo: Color::rgb(1.0, 1.0, 1.0),
albedo_texture: None,
shaded: true,
unlit: false,
}
}
}

View file

@ -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;

View file

@ -29,7 +29,7 @@ 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()
});
@ -37,14 +37,14 @@ fn setup(
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

View file

@ -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),
@ -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),
@ -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),