Permalink
Browse files

Adds support for light porbe blending and Oriented box light probes w…

…ith corrected parallax
  • Loading branch information...
Nehon committed Apr 17, 2018
1 parent 824e99c commit 83aef82d927da14ea70018c2a78dd9b7126348d1
Showing with 1,153 additions and 486 deletions.
  1. +10 −0 jme3-core/src/main/java/com/jme3/bounding/Intersection.java
  2. +4 −9 jme3-core/src/main/java/com/jme3/environment/EnvironmentCamera.java
  3. +21 −0 jme3-core/src/main/java/com/jme3/environment/LightProbeFactory.java
  4. +22 −8 jme3-core/src/main/java/com/jme3/environment/util/LightsDebugState.java
  5. +7 −3 jme3-core/src/main/java/com/jme3/light/DefaultLightFilter.java
  6. +114 −63 jme3-core/src/main/java/com/jme3/light/LightProbe.java
  7. +0 −214 jme3-core/src/main/java/com/jme3/light/LightProbeBlendingProcessor.java
  8. +249 −0 jme3-core/src/main/java/com/jme3/light/OrientedBoxProbeArea.java
  9. +0 −107 jme3-core/src/main/java/com/jme3/light/PoiLightProbeLightFilter.java
  10. +1 −6 jme3-core/src/main/java/com/jme3/light/PointLight.java
  11. +33 −0 jme3-core/src/main/java/com/jme3/light/ProbeArea.java
  12. +102 −0 jme3-core/src/main/java/com/jme3/light/SphereProbeArea.java
  13. +77 −0 jme3-core/src/main/java/com/jme3/light/WeightedProbeBlendingStrategy.java
  14. +44 −28 jme3-core/src/main/java/com/jme3/material/logic/SinglePassAndImageBasedLightingLogic.java
  15. +26 −16 jme3-core/src/main/java/com/jme3/scene/debug/WireFrustum.java
  16. +133 −26 jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag
  17. +4 −0 jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.j3md
  18. 0 jme3-examples/src/main/java/jme3test/collision/Main.java
  19. 0 jme3-examples/src/main/java/jme3test/light/DlsfError.java
  20. +1 −1 jme3-examples/src/main/java/jme3test/light/TestConeVSFrustum.java
  21. +301 −0 jme3-examples/src/main/java/jme3test/light/TestObbVsBounds.java
  22. +2 −2 jme3-examples/src/main/java/jme3test/light/pbr/RefEnv.java
  23. +2 −3 jme3-examples/src/main/java/jme3test/light/pbr/TestPBRLighting.java
@@ -34,6 +34,7 @@
import com.jme3.math.FastMath;
import com.jme3.math.Plane;
import com.jme3.math.Vector3f;
import com.jme3.renderer.Camera;
import com.jme3.util.TempVars;
import static java.lang.Math.max;
import static java.lang.Math.min;
@@ -107,6 +108,15 @@ private static final void findMinMax(float x0, float x1, float x2, Vector3f minM
}
}
public static boolean intersect(Camera camera, Vector3f center,float radius){
for (int i = 5; i >= 0; i--) {
if (camera.getWorldPlane(i).pseudoDistance(center) <= -radius) {
return false;
}
}
return true;
}
// private boolean axisTest(float a, float b, float fa, float fb, Vector3f v0, Vector3f v1, )
// private boolean axisTestX01(float a, float b, float fa, float fb,
// Vector3f center, Vector3f ext,
@@ -38,14 +38,9 @@
import com.jme3.light.LightProbe;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.Camera;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.renderer.*;
import com.jme3.scene.Spatial;
import com.jme3.texture.FrameBuffer;
import com.jme3.texture.Image;
import com.jme3.texture.Texture2D;
import com.jme3.texture.TextureCubeMap;
import com.jme3.texture.*;
import com.jme3.texture.image.ColorSpace;
import com.jme3.util.BufferUtils;
import com.jme3.util.MipMapGenerator;
@@ -119,7 +114,7 @@
private final List<SnapshotJob> jobs = new ArrayList<SnapshotJob>();
/**
* Creates an EnvironmentCamera with a size of 128
* Creates an EnvironmentCamera with a size of 256
*/
public EnvironmentCamera() {
}
@@ -322,7 +317,7 @@ protected Camera createOffCamera(final int mapSize, final Vector3f worldPos, fin
final Camera offCamera = new Camera(mapSize, mapSize);
offCamera.setLocation(worldPos);
offCamera.setAxes(axisX, axisY, axisZ);
offCamera.setFrustumPerspective(90f, 1f, 1, 1000);
offCamera.setFrustumPerspective(90f, 1f, 0.1f, 1000);
offCamera.setLocation(position);
return offCamera;
}
@@ -32,6 +32,7 @@
package com.jme3.environment;
import com.jme3.app.Application;
import com.jme3.asset.AssetManager;
import com.jme3.environment.generation.*;
import com.jme3.environment.util.EnvMapUtils;
import com.jme3.light.LightProbe;
@@ -204,6 +205,26 @@ private static void generatePbrMaps(TextureCubeMap envMap, final LightProbe prob
}
}
/**
* 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.
*
* @param manager the asset manager
* @return a debug node
*/
public static Node getDebugGui(AssetManager manager, LightProbe probe) {
if (!probe.isReady()) {
throw new UnsupportedOperationException("This EnvProbe is not ready yet, try to test isReady()");
}
Node debugNode = new Node("debug gui probe");
Node debugPfemCm = EnvMapUtils.getCubeMapCrossDebugViewWithMipMaps(probe.getPrefilteredEnvMap(), manager);
debugNode.attachChild(debugPfemCm);
debugPfemCm.setLocalTranslation(520, 0, 0);
return debugNode;
}
/**
* An inner class to keep the state of a generation process
*/
@@ -34,9 +34,8 @@
import com.jme3.app.Application;
import com.jme3.app.state.BaseAppState;
import com.jme3.bounding.BoundingSphere;
import com.jme3.light.*;
import com.jme3.material.Material;
import com.jme3.light.LightProbe;
import com.jme3.light.Light;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
@@ -68,7 +67,7 @@
@Override
protected void initialize(Application app) {
debugNode = new Node("Environment debug Node");
Sphere s = new Sphere(16, 16, 1);
Sphere s = new Sphere(16, 16, 0.15f);
debugGeom = new Geometry("debugEnvProbe", s);
debugMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Misc/reflect.j3md");
debugGeom.setMaterial(debugMaterial);
@@ -80,6 +79,16 @@ protected void initialize(Application app) {
@Override
public void update(float tpf) {
if(!isEnabled()){
return;
}
updateLights(scene);
debugNode.updateLogicalState(tpf);
debugNode.updateGeometricState();
cleanProbes();
}
public void updateLights(Spatial scene) {
for (Light light : scene.getWorldLightList()) {
switch (light.getType()) {
@@ -101,16 +110,18 @@ public void update(float tpf) {
m.setTexture("CubeMap", probe.getPrefilteredEnvMap());
}
n.setLocalTranslation(probe.getPosition());
n.getChild(1).setLocalScale(((BoundingSphere) probe.getBounds()).getRadius());
n.getChild(1).setLocalScale(probe.getArea().getRadius());
break;
default:
break;
}
}
debugNode.updateLogicalState(tpf);
debugNode.updateGeometricState();
cleanProbes();
if( scene instanceof Node){
Node n = (Node)scene;
for (Spatial spatial : n.getChildren()) {
updateLights(spatial);
}
}
}
/**
@@ -138,6 +149,9 @@ private void cleanProbes() {
@Override
public void render(RenderManager rm) {
if(!isEnabled()){
return;
}
rm.renderScene(debugNode, getApplication().getViewPort());
}
@@ -43,10 +43,10 @@
private Camera camera;
private final HashSet<Light> processedLights = new HashSet<Light>();
private final LightProbeBlendingStrategy probeBlendStrat;
private LightProbeBlendingStrategy probeBlendStrat;
public DefaultLightFilter() {
probeBlendStrat = new BasicProbeBlendingStrategy();
probeBlendStrat = new WeightedProbeBlendingStrategy();
}
public DefaultLightFilter(LightProbeBlendingStrategy probeBlendStrat) {
@@ -113,5 +113,9 @@ public void filterLights(Geometry geometry, LightList filteredLightList) {
vars.release();
}
}
public void setLightProbeBlendingStrategy(LightProbeBlendingStrategy strategy){
probeBlendStrat = strategy;
}
}
Oops, something went wrong.

0 comments on commit 83aef82

Please sign in to comment.