Browse Source

Fixes Gltf Emissive Intensity Default (#2163)

* fixed emissive intensity gltf default

* updated copyright dates

* reverted copyright date
codex 1 năm trước cách đây
mục cha
commit
358f756d12

+ 8 - 0
jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/MaterialAdapter.java

@@ -62,6 +62,13 @@ public abstract class MaterialAdapter {
     protected abstract String getMaterialDefPath();
 
     protected abstract MatParam adaptMatParam(MatParam param);
+    
+    /**
+     * Initializes material parameters to their default settings.
+     * 
+     * @param material 
+     */
+    protected abstract void initDefaultMatParams(Material material);
 
     protected void init(AssetManager assetManager) {
         this.assetManager = assetManager;
@@ -75,6 +82,7 @@ public abstract class MaterialAdapter {
     protected Material getMaterial() {
         if (mat == null) {
             mat = new Material(assetManager, getMaterialDefPath());
+            initDefaultMatParams(mat);
         }
         return mat;
     }

+ 5 - 0
jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/PBRMaterialAdapter.java

@@ -61,6 +61,11 @@ public abstract class PBRMaterialAdapter extends MaterialAdapter {
     protected String getMaterialDefPath() {
         return "Common/MatDefs/Light/PBRLighting.j3md";
     }
+    
+    @Override
+    protected void initDefaultMatParams(Material material) {
+        material.setFloat("EmissiveIntensity", 1);
+    }
 
     @Override
     protected MatParam adaptMatParam(MatParam param) {

+ 7 - 2
jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/UnlitMaterialAdapter.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2020 jMonkeyEngine
+ * Copyright (c) 2023 jMonkeyEngine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -32,6 +32,7 @@
 package com.jme3.scene.plugins.gltf;
 
 import com.jme3.material.MatParam;
+import com.jme3.material.Material;
 import com.jme3.material.RenderState;
 
 /**
@@ -77,5 +78,9 @@ public class UnlitMaterialAdapter extends MaterialAdapter {
             return null;
         }
         return param;
-    }
+    }    
+    
+    @Override
+    protected void initDefaultMatParams(Material material) {}
+    
 }