mirror of
https://github.com/bevyengine/bevy
synced 2024-09-20 14:32:06 +00:00
Add support for gltf::Material::unlit (#1341)
* Add support for gltf::Material::unlit
This commit is contained in:
parent
06dbfffe2e
commit
e6e23fdfa9
7 changed files with 12 additions and 12 deletions
|
@ -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"
|
||||
|
|
|
@ -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),
|
||||
)
|
||||
|
|
|
@ -46,7 +46,7 @@ impl Plugin for PbrPlugin {
|
|||
Handle::<StandardMaterial>::default(),
|
||||
StandardMaterial {
|
||||
albedo: Color::PINK,
|
||||
shaded: false,
|
||||
unlit: true,
|
||||
albedo_texture: None,
|
||||
},
|
||||
);
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Reference in a new issue