|
@@ -1,5 +1,5 @@
|
|
/*
|
|
/*
|
|
- * Copyright (c) 2009-2019 jMonkeyEngine
|
|
|
|
|
|
+ * Copyright (c) 2009-2023 jMonkeyEngine
|
|
* All rights reserved.
|
|
* All rights reserved.
|
|
*
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* Redistribution and use in source and binary forms, with or without
|
|
@@ -33,7 +33,6 @@ package com.jme3.environment;
|
|
|
|
|
|
import com.jme3.asset.AssetManager;
|
|
import com.jme3.asset.AssetManager;
|
|
import com.jme3.environment.baker.IBLGLEnvBakerLight;
|
|
import com.jme3.environment.baker.IBLGLEnvBakerLight;
|
|
-import com.jme3.environment.baker.IBLHybridEnvBakerLight;
|
|
|
|
import com.jme3.environment.util.EnvMapUtils;
|
|
import com.jme3.environment.util.EnvMapUtils;
|
|
import com.jme3.light.LightProbe;
|
|
import com.jme3.light.LightProbe;
|
|
import com.jme3.math.Vector3f;
|
|
import com.jme3.math.Vector3f;
|
|
@@ -43,40 +42,53 @@ import com.jme3.scene.Spatial;
|
|
import com.jme3.texture.Image.Format;
|
|
import com.jme3.texture.Image.Format;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * A faster version of LightProbeFactory that uses accelerated Baking.
|
|
|
|
|
|
+ * A faster LightProbeFactory that uses GPU accelerated algorithms.
|
|
|
|
+ * This is the GPU version of @{link LightProbeFactory} and should be generally preferred.
|
|
|
|
+ *
|
|
|
|
+ * For common use cases where the probe is baking the scene or part of the scene around it, it
|
|
|
|
+ * is advised to use the @{link EnvironmentProbeControl} instead since it does automatically most of the
|
|
|
|
+ * boilerplate work.
|
|
|
|
+ *
|
|
|
|
+ *
|
|
* @author Riccardo Balbo
|
|
* @author Riccardo Balbo
|
|
*/
|
|
*/
|
|
-public class LightProbeFactory2 {
|
|
|
|
|
|
+public class FastLightProbeFactory {
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
- * Creates a LightProbe with the giver EnvironmentCamera in the given scene.
|
|
|
|
- * @param rm The RenderManager
|
|
|
|
- * @param am The AssetManager
|
|
|
|
- * @param size The size of the probe
|
|
|
|
- * @param pos The position of the probe
|
|
|
|
- * @param frustumNear The near frustum of the probe
|
|
|
|
- * @param frustumFar The far frustum of the probe
|
|
|
|
- * @param scene The scene to bake
|
|
|
|
|
|
+ * Creates a LightProbe with the given EnvironmentCamera in the given scene.
|
|
|
|
+ *
|
|
|
|
+ * @param rm
|
|
|
|
+ * The RenderManager
|
|
|
|
+ * @param am
|
|
|
|
+ * The AssetManager
|
|
|
|
+ * @param size
|
|
|
|
+ * The size of the probe
|
|
|
|
+ * @param pos
|
|
|
|
+ * The position of the probe
|
|
|
|
+ * @param frustumNear
|
|
|
|
+ * The near frustum of the probe
|
|
|
|
+ * @param frustumFar
|
|
|
|
+ * The far frustum of the probe
|
|
|
|
+ * @param scene
|
|
|
|
+ * The scene to bake
|
|
* @return The baked LightProbe
|
|
* @return The baked LightProbe
|
|
*/
|
|
*/
|
|
- public static LightProbe makeProbe(RenderManager rm,
|
|
|
|
- AssetManager am, int size,Vector3f pos, float frustumNear,float frustumFar,Spatial scene) {
|
|
|
|
- IBLHybridEnvBakerLight baker=new IBLGLEnvBakerLight(rm, am, Format.RGB16F, Format.Depth, size, size);
|
|
|
|
|
|
+ public static LightProbe makeProbe(RenderManager rm, AssetManager am, int size, Vector3f pos, float frustumNear, float frustumFar, Spatial scene) {
|
|
|
|
+ IBLGLEnvBakerLight baker = new IBLGLEnvBakerLight(rm, am, Format.RGB16F, Format.Depth, size, size);
|
|
|
|
|
|
baker.setTexturePulling(true);
|
|
baker.setTexturePulling(true);
|
|
- baker.bakeEnvironment(scene,pos, frustumNear,frustumFar,null);
|
|
|
|
|
|
+ baker.bakeEnvironment(scene, pos, frustumNear, frustumFar, null);
|
|
baker.bakeSpecularIBL();
|
|
baker.bakeSpecularIBL();
|
|
baker.bakeSphericalHarmonicsCoefficients();
|
|
baker.bakeSphericalHarmonicsCoefficients();
|
|
-
|
|
|
|
|
|
+
|
|
LightProbe probe = new LightProbe();
|
|
LightProbe probe = new LightProbe();
|
|
-
|
|
|
|
|
|
+
|
|
probe.setPosition(pos);
|
|
probe.setPosition(pos);
|
|
probe.setPrefilteredMap(baker.getSpecularIBL());
|
|
probe.setPrefilteredMap(baker.getSpecularIBL());
|
|
-
|
|
|
|
|
|
+
|
|
int[] mipSizes = probe.getPrefilteredEnvMap().getImage().getMipMapSizes();
|
|
int[] mipSizes = probe.getPrefilteredEnvMap().getImage().getMipMapSizes();
|
|
probe.setNbMipMaps(mipSizes != null ? mipSizes.length : 1);
|
|
probe.setNbMipMaps(mipSizes != null ? mipSizes.length : 1);
|
|
-
|
|
|
|
|
|
+
|
|
probe.setShCoeffs(baker.getSphericalHarmonicsCoefficients());
|
|
probe.setShCoeffs(baker.getSphericalHarmonicsCoefficients());
|
|
probe.setReady(true);
|
|
probe.setReady(true);
|
|
|
|
|
|
@@ -86,14 +98,12 @@ public class LightProbeFactory2 {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
- * For debuging porpose only
|
|
|
|
- * Will return a Node meant to be added to a GUI presenting the 2 cube maps in a cross pattern with all the mip maps.
|
|
|
|
|
|
+ * For debuging purposes only Will return a Node meant to be added to a GUI
|
|
|
|
+ * presenting the 2 cube maps in a cross pattern with all the mip maps.
|
|
*
|
|
*
|
|
- * @param manager the asset manager
|
|
|
|
|
|
+ * @param manager
|
|
|
|
+ * the asset manager
|
|
* @return a debug node
|
|
* @return a debug node
|
|
*/
|
|
*/
|
|
public static Node getDebugGui(AssetManager manager, LightProbe probe) {
|
|
public static Node getDebugGui(AssetManager manager, LightProbe probe) {
|
|
@@ -109,6 +119,4 @@ public class LightProbeFactory2 {
|
|
return debugNode;
|
|
return debugNode;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|