Breaking changes on PBR branch

Hey monkeys. for the past 3 weeks I’ve been actively working on PBR.

PBR indirect lighting, needs some environment maps to fake global illumination.
In previous implementation you had basically one instance of each env maps, snapshot from the 0,0,0 position with an inifnite range.
This was working ok as long as the model was right in the center of the scene.
However, you may encounter scenes where you need env maps taken from different places of the scene.
For example, you may have a very bright outdoor area with a very bright env map, and l’et’s say a cave in this area where light should be a lot dimmer than on the outside.

So somehow, you need several env maps, and be able to switch them for rendering at some point.

I’ve introduce a LightProbe class that extends Light. It’s not exactly a light but it retains environment lighting information (the necessary env maps needed for indirect lighting). And making it a Light was nicely blending in our lighting system.
A LightProbe has a position in world space, and a color that is not used for now.

To create a LightProbe you have to use the EnvProbeFactory.makeProbe method. this method takes an EnvironmentCamera ( used to take the snapshot of the scene) and the scene where to render the snapshot.
This will assychronously create the necessary env maps for the probe. Note that it uses several threads so the genration is faster, but it’s still a long process (around 2 seconds on my computer) that is more meant ot be done off line.

Later, you’ll have the possibility to save the generated env maps along the envProve in a j3o so that the images are loaded with the scene, and you don’t have to re render them.

I made this process thread safe so you can call it from any thread.

Here is a debug shot to understand what a LightProbe is.

And with its range.

So basically to have PBR to work properly you need to do this :

EnvironmentCamera envCam = new environmentCamera();
LightProbe probe = LightProbeFactory.makeProbe(envCam, rootNode);

Of course you also need a model with a PBR material.

All of this is still a WIP and may change and enhance slightly in the future.
All of this is based on this article from Sebastien Lagarde. Even if I just implemented 10% of it for now :stuck_out_tongue:

I recommend this read.

Please report if you have any issue.


Excellent :slight_smile: I have to work hard on PBR when i back home because this is getting really beatiful.

Do i need to make an envCamera for each LightProbe or can it be shared between them?

One is enough.
The LightProbe doesn’t retain any information about the camera anyway.