Class DirectionalLightShadowRendererVR

java.lang.Object
com.jme3.shadow.AbstractShadowRendererVR
com.jme3.shadow.DirectionalLightShadowRendererVR
All Implemented Interfaces:
Savable, SceneProcessor

public class DirectionalLightShadowRendererVR extends AbstractShadowRendererVR
DirectionalLightShadowRenderer renderer use Parallel Split Shadow Mapping technique (pssm)
It splits the view frustum in several parts and compute a shadow map for each one.
splits are distributed so that the closer they are from the camera, the smaller they are to maximize the resolution used of the shadow map.
This results in a better quality shadow than standard shadow mapping.
for more information on this read http://http.developer.nvidia.com/GPUGems3/gpugems3_ch10.html
  • Field Details

    • lambda

      protected float lambda
    • shadowCam

      protected Camera shadowCam
    • splits

      protected ColorRGBA splits
    • splitsArray

      protected float[] splitsArray
    • light

      protected DirectionalLight light
    • points

      protected Vector3f[] points
  • Constructor Details

    • DirectionalLightShadowRendererVR

      public DirectionalLightShadowRendererVR()
      Used for serialization use DirectionalLightShadowRenderer#DirectionalLightShadowRenderer(AssetManager assetManager, int shadowMapSize, int nbSplits)
    • DirectionalLightShadowRendererVR

      public DirectionalLightShadowRendererVR(AssetManager assetManager, int shadowMapSize, int nbSplits)
      Creates a DirectionalLight shadow renderer. More info on the technique at http://http.developer.nvidia.com/GPUGems3/gpugems3_ch10.html
      Parameters:
      assetManager - the application's asset manager
      shadowMapSize - the size of the rendered shadowmaps (512, 1024, 2048, etcetera)
      nbSplits - the number of shadow maps rendered (More shadow maps yield better quality, fewer fps.)
  • Method Details

    • initFrustumCam

      protected void initFrustumCam()
      Description copied from class: AbstractShadowRendererVR
      delegates the initialization of the frustum cam to child renderers
      Specified by:
      initFrustumCam in class AbstractShadowRendererVR
    • getLight

      public DirectionalLight getLight()
      return the light used to cast shadows
      Returns:
      the DirectionalLight
    • setLight

      public void setLight(DirectionalLight light)
      Sets the light to use to cast shadows
      Parameters:
      light - a DirectionalLight
    • updateShadowCams

      protected void updateShadowCams(Camera viewCam)
      Description copied from class: AbstractShadowRendererVR
      Invoked once per frame to update the shadow cams according to the light view.
      Specified by:
      updateShadowCams in class AbstractShadowRendererVR
      Parameters:
      viewCam - the scene cam
    • getOccludersToRender

      protected GeometryList getOccludersToRender(int shadowMapIndex, GeometryList shadowMapOccluders)
      Description copied from class: AbstractShadowRendererVR
      Returns a subclass-specific geometryList containing the occluders to be rendered in the shadow map
      Specified by:
      getOccludersToRender in class AbstractShadowRendererVR
      Parameters:
      shadowMapIndex - the index of the shadow map being rendered
      shadowMapOccluders - the list of occluders
      Returns:
      a list of occluders
    • getReceivers

      protected void getReceivers(GeometryList lightReceivers)
      Specified by:
      getReceivers in class AbstractShadowRendererVR
    • getShadowCam

      protected Camera getShadowCam(int shadowMapIndex)
      Description copied from class: AbstractShadowRendererVR
      return the shadow camera to use for rendering the shadow map according the given index
      Specified by:
      getShadowCam in class AbstractShadowRendererVR
      Parameters:
      shadowMapIndex - the index of the shadow map being rendered
      Returns:
      the shadowCam
    • doDisplayFrustumDebug

      protected void doDisplayFrustumDebug(int shadowMapIndex)
      Description copied from class: AbstractShadowRendererVR
      responsible for displaying the frustum of the shadow cam for debug purpose
      Overrides:
      doDisplayFrustumDebug in class AbstractShadowRendererVR
    • setMaterialParameters

      protected void setMaterialParameters(Material material)
      Description copied from class: AbstractShadowRendererVR
      This method is called once per frame and is responsible for setting any material parameters that subclasses may need to set on the post material.
      Specified by:
      setMaterialParameters in class AbstractShadowRendererVR
      Parameters:
      material - the material to use for the post shadow pass
    • clearMaterialParameters

      protected void clearMaterialParameters(Material material)
      Description copied from class: AbstractShadowRendererVR
      This method is called once per frame and is responsible for clearing any material parameters that subclasses may need to clear on the post material.
      Specified by:
      clearMaterialParameters in class AbstractShadowRendererVR
      Parameters:
      material - the material that was used for the post shadow pass
    • getLambda

      public float getLambda()
      returns the lambda parameter see #setLambda(float lambda)
      Returns:
      lambda
    • setLambda

      public void setLambda(float lambda)
      Adjusts the partition of the shadow extend into shadow maps. Lambda is usually between 0 and 1. A low value gives a more linear partition, resulting in consistent shadow quality over the extend, but near shadows could look very jagged. A high value gives a more logarithmic partition, resulting in high quality for near shadows, but quality decreases rapidly with distance. The default value is 0.65 (the theoretical optimum).
      Parameters:
      lambda - the lambda value.
    • isEnabledStabilization

      public boolean isEnabledStabilization()
      Check if the stabilization is enabled.
      Returns:
      true if stabilization is enabled and false otherwise.
    • setEnabledStabilization

      public void setEnabledStabilization(boolean stabilize)
      Enables the stabilization of the shadow's edges. (default is true) This prevents shadow edges from flickering when the camera moves. However, it can lead to some loss of shadow quality in particular scenes.
      Parameters:
      stabilize - true if stabilization has to be enabled and false otherwise.
    • read

      public void read(JmeImporter im) throws IOException
      Description copied from class: AbstractShadowRendererVR
      De-serialize this instance, for example when loading from a J3O file.
      Specified by:
      read in interface Savable
      Overrides:
      read in class AbstractShadowRendererVR
      Parameters:
      im - importer (not null)
      Throws:
      IOException
    • write

      public void write(JmeExporter ex) throws IOException
      Description copied from class: AbstractShadowRendererVR
      Serialize this instance, for example when saving to a J3O file.
      Specified by:
      write in interface Savable
      Overrides:
      write in class AbstractShadowRendererVR
      Parameters:
      ex - exporter (not null)
      Throws:
      IOException
    • checkCulling

      protected boolean checkCulling(Camera viewCam)
      Directional light is always in the view frustum
      Specified by:
      checkCulling in class AbstractShadowRendererVR
      Parameters:
      viewCam -
      Returns:
      true