Class LightProbe

java.lang.Object
com.jme3.light.Light
com.jme3.light.LightProbe
All Implemented Interfaces:
Savable, Cloneable
Direct Known Subclasses:
EnvironmentProbeControl

public class LightProbe extends Light implements Savable
A LightProbe is not exactly a light. It holds environment map information used for Image Based Lighting. This is used for indirect lighting in the Physically Based Rendering pipeline. A light probe has a position in world space. This is the position from where the Environment Map are rendered. There are two environment data structure held by the LightProbe : - The irradiance spherical harmonics factors (used for indirect diffuse lighting in the PBR pipeline). - The prefiltered environment map (used for indirect specular lighting and reflection in the PBE pipeline). Note that when instantiating the LightProbe, both of those structures are null. To compute them see LightProbeFactory.makeProbe(com.jme3.environment.EnvironmentCamera, com.jme3.scene.Spatial) and EnvironmentCamera. The light probe has an area of effect centered on its position. It can have a Spherical area or an Oriented Box area A LightProbe will only be taken into account when it's marked as ready and enabled. A light probe is ready when it has valid environment map data set. Note that you should never call setReady yourself.
See Also:
  • Field Details

    • FALLBACK_MATRIX

      public static final Matrix4f FALLBACK_MATRIX
  • Constructor Details

  • Method Details

    • getPrefilteredEnvMap

      public TextureCubeMap getPrefilteredEnvMap()
      returns the prefiltered environment map texture of this light probe Note that this Texture may not have image data yet if the LightProbe is not ready
      Returns:
      the prefiltered environment map
    • setPrefilteredMap

      public void setPrefilteredMap(TextureCubeMap prefilteredEnvMap)
      Sets the prefiltered environment map
      Parameters:
      prefilteredEnvMap - the prefiltered environment map
    • getUniformMatrix

      public Matrix4f getUniformMatrix()
      Returns the data to send to the shader. This is a column major matrix that is not a classic transform matrix, it's laid out in a particular way // 3x3 rot mat| // 0 1 2 | 3 // 0 | ax bx cx | px | ) // 1 | ay by cy | py | probe position // 2 | az bz cz | pz | ) // --|----------| // 3 | sx sy sz sp | 1/probe radius + nbMipMaps // --scale--

      (ax, ay, az) is the pitch rotation axis (bx, by, bz) is the yaw rotation axis (cx, cy, cz) is the roll rotation axis Like in a standard 3x3 rotation matrix. It's also the valid rotation matrix of the probe in world space. Note that for the Spherical Probe area this part is a 3x3 identity matrix.

      (px, py, pz) is the position of the center of the probe in world space Like in a valid 4x4 transform matrix.

      (sx, sy, sy) is the extent of the probe ( the scale ) In a standard transform matrix, the scale is applied to the rotation matrix part. In the shader, we need the rotation and the scale to be separated. Doing so avoids extracting the scale from a classic transform matrix in the shader.

      (sp) is a special entry, it contains the packed number of mip maps of the probe and the inverse radius for the probe. since the inverse radius in lower than 1, it's packed in the decimal part of the float. The number of mip maps is packed in the integer part of the float. (ie: for 6 mip maps and a radius of 3, sp= 6.3333333)

      The radius is obvious for a SphereProbeArea, but in the case of an OrientedBoxProbeArea it's the max of the extent vector's components.

      Returns:
      the pre-existing matrix
    • write

      public void write(JmeExporter ex) throws IOException
      Specified by:
      write in interface Savable
      Overrides:
      write in class Light
      Throws:
      IOException
    • read

      public void read(JmeImporter im) throws IOException
      Specified by:
      read in interface Savable
      Overrides:
      read in class Light
      Throws:
      IOException
    • getBounds

      @Deprecated public BoundingVolume getBounds()
      Deprecated.
      returns the bounding volume of this LightProbe
      Returns:
      a bounding volume.
    • getArea

      public ProbeArea getArea()
    • setAreaType

      public void setAreaType(LightProbe.AreaType type)
    • getAreaType

      public LightProbe.AreaType getAreaType()
    • isReady

      public boolean isReady()
      return true if the LightProbe is ready, meaning the Environment maps have been loaded or rendered and are ready to be used by a material
      Returns:
      the LightProbe ready state
    • setReady

      public void setReady(boolean ready)
      Don't call this method directly. It's meant to be called by additional systems that will load or render the Environment maps of the LightProbe
      Parameters:
      ready - the ready state of the LightProbe.
    • getShCoeffs

      public Vector3f[] getShCoeffs()
    • setShCoeffs

      public void setShCoeffs(Vector3f[] shCoefficients)
    • getPosition

      public Vector3f getPosition()
      Returns the position of the LightProbe in world space
      Returns:
      the world-space position
    • setPosition

      public void setPosition(Vector3f position)
      Sets the position of the LightProbe in world space
      Parameters:
      position - the world-space position
    • getNbMipMaps

      public int getNbMipMaps()
    • setNbMipMaps

      public void setNbMipMaps(int nbMipMaps)
    • intersectsBox

      public boolean intersectsBox(BoundingBox box, TempVars vars)
      Description copied from class: Light
      Determines if the light intersects with the given bounding box.

      For non-local lights, such as directional lights, ambient lights, or point lights without influence radius, this method should always return true.

      Specified by:
      intersectsBox in class Light
      Parameters:
      box - The box to check intersection against.
      vars - TempVars in case it is needed.
      Returns:
      True if the light intersects the box, false otherwise.
    • intersectsFrustum

      public boolean intersectsFrustum(Camera camera, TempVars vars)
      Description copied from class: Light
      Determines if the light intersects with the given camera frustum. For non-local lights, such as directional lights, ambient lights, or point lights without influence radius, this method should always return true.
      Specified by:
      intersectsFrustum in class Light
      Parameters:
      camera - The camera frustum to check intersection against.
      vars - TempVars in case it is needed.
      Returns:
      True if the light intersects the frustum, false otherwise.
    • intersectsSphere

      public boolean intersectsSphere(BoundingSphere sphere, TempVars vars)
      Description copied from class: Light
      Determines if the light intersects with the given bounding sphere.

      For non-local lights, such as directional lights, ambient lights, or point lights without influence radius, this method should always return true.

      Specified by:
      intersectsSphere in class Light
      Parameters:
      sphere - The sphere to check intersection against.
      vars - TempVars in case it is needed.
      Returns:
      True if the light intersects the sphere, false otherwise.
    • computeLastDistance

      protected void computeLastDistance(Spatial owner)
      Description copied from class: Light
      Used internally to compute the last distance value.
      Specified by:
      computeLastDistance in class Light
      Parameters:
      owner - the Spatial whose distance is to be determined
    • getType

      public Light.Type getType()
      Description copied from class: Light
      Returns the light type
      Specified by:
      getType in class Light
      Returns:
      the light type
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object