use gltf emission strength parameter correctly

This commit is contained in:
Dmitry
2025-10-25 19:46:49 +03:00
parent 4eeb82e94b
commit 4135f6ac6c
3 changed files with 10 additions and 3 deletions
+1 -1
View File
@@ -47,7 +47,7 @@ base64 = "0.22.1"
uvgen = "0.3.0"
lightmap = "0.3.0"
libloading = "0.8.1"
gltf = { version = "1.4.0", default-features = false, features = ["names", "utils", "extras"] }
gltf = { version = "1.4.0", default-features = false, features = ["names", "utils", "extras", "KHR_materials_emissive_strength"] }
bytemuck = { version = "1.23.2", features = ["derive"] }
approx = "0.5.1"
@@ -24,7 +24,7 @@
),
(
name: "emissionTexture",
kind: Texture(kind: Sampler2D, fallback: Black),
kind: Texture(kind: Sampler2D, fallback: White),
binding: 4
),
(
+8 -1
View File
@@ -18,6 +18,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#![allow(missing_docs)]
use std::{
fmt::Display,
path::{Path, PathBuf},
@@ -241,7 +243,12 @@ async fn import_material(
"diffuseColor",
Vector4::<f32>::from(pbr.base_color_factor()).into(),
);
set_material_vector3(&mut result, "emissionStrength", mat.emissive_factor());
let mut emission_strength = mat.emissive_factor();
let emission_factor = mat.emissive_strength().unwrap_or(1.0);
for c in emission_strength.iter_mut() {
*c *= emission_factor;
}
set_material_vector3(&mut result, "emissionStrength", emission_strength);
set_material_scalar(&mut result, "metallicFactor", pbr.metallic_factor());
set_material_scalar(&mut result, "roughnessFactor", pbr.roughness_factor());
Ok(Resource::new_ok(