Sfoglia il codice sorgente

PBR: Applied band factor to sh coefficient.
Regenrerated the default probe in test data
better gloss / spec pipeline

Nehon 8 anni fa
parent
commit
37e4d4d564

+ 9 - 9
jme3-core/src/main/java/com/jme3/environment/util/EnvMapUtils.java

@@ -509,15 +509,15 @@ public class EnvMapUtils {
         float coef7 = coef5;
         float coef8 = sqrt15Pi / 4f;
 
-        shCoefs[0].multLocal(coef0);
-        shCoefs[1].multLocal(coef1);
-        shCoefs[2].multLocal(coef2);
-        shCoefs[3].multLocal(coef3);
-        shCoefs[4].multLocal(coef4);
-        shCoefs[5].multLocal(coef5);
-        shCoefs[6].multLocal(coef6);
-        shCoefs[7].multLocal(coef7);
-        shCoefs[8].multLocal(coef8);
+        shCoefs[0].multLocal(coef0).multLocal(shBandFactor[0]);
+        shCoefs[1].multLocal(coef1).multLocal(shBandFactor[1]);
+        shCoefs[2].multLocal(coef2).multLocal(shBandFactor[2]);
+        shCoefs[3].multLocal(coef3).multLocal(shBandFactor[3]);
+        shCoefs[4].multLocal(coef4).multLocal(shBandFactor[4]);
+        shCoefs[5].multLocal(coef5).multLocal(shBandFactor[5]);
+        shCoefs[6].multLocal(coef6).multLocal(shBandFactor[6]);
+        shCoefs[7].multLocal(coef7).multLocal(shBandFactor[7]);
+        shCoefs[8].multLocal(coef8).multLocal(shBandFactor[8]);
     }
 
 

+ 14 - 2
jme3-core/src/main/java/com/jme3/light/LightProbe.java

@@ -120,20 +120,32 @@ public class LightProbe extends Light implements Savable {
         oc.write(position, "position", null);
         oc.write(bounds, "bounds", new BoundingSphere(1.0f, Vector3f.ZERO));
         oc.write(ready, "ready", false);
+        oc.write(nbMipMaps, "nbMipMaps", 0);
     }
 
     @Override
     public void read(JmeImporter im) throws IOException {
         super.read(im);
         InputCapsule ic = im.getCapsule(this);
-        shCoeffs = (Vector3f[]) ic.readSavableArray("shCoeffs", null);
+
+
         prefilteredEnvMap = (TextureCubeMap) ic.readSavable("prefilteredEnvMap", null);
         position = (Vector3f) ic.readSavable("position", this);
         bounds = (BoundingVolume) ic.readSavable("bounds", new BoundingSphere(1.0f, Vector3f.ZERO));
+        nbMipMaps = ic.readInt("nbMipMaps", 0);
         ready = ic.readBoolean("ready", false);
-        if (shCoeffs == null) {
+
+
+        Savable[] coeffs = ic.readSavableArray("shCoeffs", null);
+        if (coeffs == null) {
             ready = false;
             logger.log(Level.WARNING, "LightProbe is missing parameters, it should be recomputed. Please use lightProbeFactory.updateProbe()");
+        } else {
+            shCoeffs = new Vector3f[coeffs.length];
+            for (int i = 0; i < coeffs.length; i++) {
+                shCoeffs[i] = (Vector3f) coeffs[i];
+            }
+
         }
     }
 

+ 4 - 4
jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag

@@ -128,13 +128,13 @@ void main(){
 
     #ifdef USE_PACKED_MR
         vec2 rm = texture2D(m_MetallicRoughnessMap, newTexCoord).gb;
-        float Roughness = rm.x * max(m_Roughness, 1e-8);
+        float Roughness = rm.x * max(m_Roughness, 1e-4);
         float Metallic = rm.y * max(m_Metallic, 0.0);
     #else
         #ifdef ROUGHNESSMAP
-            float Roughness = texture2D(m_RoughnessMap, newTexCoord).r * max(m_Roughness, 1e-8);
+            float Roughness = texture2D(m_RoughnessMap, newTexCoord).r * max(m_Roughness, 1e-4);
         #else
-            float Roughness =  max(m_Roughness, 1e-8);
+            float Roughness =  max(m_Roughness, 1e-4);
         #endif
         #ifdef METALLICMAP
             float Metallic = texture2D(m_MetallicMap, newTexCoord).r * max(m_Metallic, 0.0);
@@ -187,7 +187,7 @@ void main(){
             #endif
             specularColor *= m_Specular;
         #endif
-        vec4 diffuseColor = albedo * (1.0 - max(max(specularColor.r, specularColor.g), specularColor.b));
+        vec4 diffuseColor = albedo;// * (1.0 - max(max(specularColor.r, specularColor.g), specularColor.b));
         Roughness = 1.0 - glossiness;
     #else      
         float nonMetalSpec = 0.08 * specular;

+ 0 - 3
jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.j3md

@@ -288,9 +288,6 @@ MaterialDef PBR Lighting {
 
         Defines {
             NEED_TEXCOORD1
-            HAS_GLOWMAP : GlowMap
-            HAS_GLOWCOLOR : GlowColor
-
             NUM_BONES : NumberOfBones
             INSTANCING : UseInstancing
         }

BIN
jme3-testdata/src/main/resources/Scenes/defaultProbe.j3o