PBR: Applied band factor to sh coefficient.

Regenrerated the default probe in test data
better gloss / spec pipeline
empirephoenix-patch-1
Nehon 7 years ago
parent 66137d53b8
commit 37e4d4d564
  1. 18
      jme3-core/src/main/java/com/jme3/environment/util/EnvMapUtils.java
  2. 16
      jme3-core/src/main/java/com/jme3/light/LightProbe.java
  3. 8
      jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag
  4. 3
      jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.j3md
  5. BIN
      jme3-testdata/src/main/resources/Scenes/defaultProbe.j3o

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

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

@ -128,13 +128,13 @@ void main(){
#ifdef USE_PACKED_MR #ifdef USE_PACKED_MR
vec2 rm = texture2D(m_MetallicRoughnessMap, newTexCoord).gb; 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); float Metallic = rm.y * max(m_Metallic, 0.0);
#else #else
#ifdef ROUGHNESSMAP #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 #else
float Roughness = max(m_Roughness, 1e-8); float Roughness = max(m_Roughness, 1e-4);
#endif #endif
#ifdef METALLICMAP #ifdef METALLICMAP
float Metallic = texture2D(m_MetallicMap, newTexCoord).r * max(m_Metallic, 0.0); float Metallic = texture2D(m_MetallicMap, newTexCoord).r * max(m_Metallic, 0.0);
@ -187,7 +187,7 @@ void main(){
#endif #endif
specularColor *= m_Specular; specularColor *= m_Specular;
#endif #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; Roughness = 1.0 - glossiness;
#else #else
float nonMetalSpec = 0.08 * specular; float nonMetalSpec = 0.08 * specular;

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

Loading…
Cancel
Save