Skip to content

Commit

Permalink
Add support for KHR_materials_emissive_strength (#9553)
Browse files Browse the repository at this point in the history
# Objective

- Fix blender gltf imports with emissive materials
- Progress towards #5178

## Solution

- Upgrade to gltf-rs 1.3 supporiting
[KHR_materials_emissive_strength](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_emissive_strength/README.md)

---

## Changelog

- GLTF files using `emissiveStrength` (such as those exported by
blender) are now supported

## Migration Guide

- The GLTF asset loader will now factor in `emissiveStrength` when
converting to Bevy's `StandardMaterial::emissive`. Blender will export
emissive materials using this field. Remove the field from your GLTF
files or manually modify your materials post-asset-load to match how
Bevy would load these files in previous versions.
  • Loading branch information
JMS55 authored Aug 24, 2023
1 parent f813831 commit 228e7aa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion crates/bevy_gltf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ bevy_tasks = { path = "../bevy_tasks", version = "0.12.0-dev" }
bevy_utils = { path = "../bevy_utils", version = "0.12.0-dev" }

# other
gltf = { version = "1.0.0", default-features = false, features = [
gltf = { version = "1.3.0", default-features = false, features = [
"KHR_lights_punctual",
"KHR_materials_unlit",
"KHR_materials_emissive_strength",
"extras",
"names",
"utils",
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_gltf/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,8 @@ fn load_material(material: &Material, load_context: &mut LoadContext) -> Handle<
Some(Face::Back)
},
occlusion_texture,
emissive: Color::rgb_linear(emissive[0], emissive[1], emissive[2]),
emissive: Color::rgb_linear(emissive[0], emissive[1], emissive[2])
* material.emissive_strength().unwrap_or(1.0),
emissive_texture,
unlit: material.unlit(),
alpha_mode: alpha_mode(material),
Expand Down

0 comments on commit 228e7aa

Please sign in to comment.