From 10bc250db75b3852676eb65d3358d46b846d3359 Mon Sep 17 00:00:00 2001 From: Alexandr Brui Date: Sun, 23 Jul 2017 18:51:23 +0300 Subject: [PATCH] Fix of the one parameter of shadows render. (#688) * fixed applying the render back faces shadows option during creating a shadow filter. --- .../jme3/shadow/AbstractShadowRenderer.java | 23 ++++++++----------- .../jme3/shadow/AbstractShadowRendererVR.java | 23 +++++++------------ 2 files changed, 18 insertions(+), 28 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/shadow/AbstractShadowRenderer.java b/jme3-core/src/main/java/com/jme3/shadow/AbstractShadowRenderer.java index b390c1340..ff967f584 100644 --- a/jme3-core/src/main/java/com/jme3/shadow/AbstractShadowRenderer.java +++ b/jme3-core/src/main/java/com/jme3/shadow/AbstractShadowRenderer.java @@ -32,11 +32,7 @@ package com.jme3.shadow; import com.jme3.asset.AssetManager; -import com.jme3.export.InputCapsule; -import com.jme3.export.JmeExporter; -import com.jme3.export.JmeImporter; -import com.jme3.export.OutputCapsule; -import com.jme3.export.Savable; +import com.jme3.export.*; import com.jme3.material.Material; import com.jme3.material.RenderState; import com.jme3.math.ColorRGBA; @@ -99,7 +95,7 @@ public abstract class AbstractShadowRenderer implements SceneProcessor, Savable, protected CompareMode shadowCompareMode = CompareMode.Hardware; protected Picture[] dispPic; protected RenderState forcedRenderState = new RenderState(); - protected Boolean renderBackFacesShadows = true; + protected boolean renderBackFacesShadows = true; protected AppProfiler prof; /** @@ -192,6 +188,7 @@ public abstract class AbstractShadowRenderer implements SceneProcessor, Savable, setEdgeFilteringMode(edgeFilteringMode); setShadowIntensity(shadowIntensity); initForcedRenderState(); + setRenderBackFacesShadows(isRenderBackFacesShadows()); } protected void initForcedRenderState() { @@ -558,19 +555,20 @@ public abstract class AbstractShadowRenderer implements SceneProcessor, Savable, for (int j = 0; j < nbShadowMaps; j++) { mat.setMatrix4(lightViewStringCache[j], lightViewProjectionsMatrices[j]); } + for (int j = 0; j < nbShadowMaps; j++) { mat.setTexture(shadowMapStringCache[j], shadowMaps[j]); } + mat.setBoolean("HardwareShadows", shadowCompareMode == CompareMode.Hardware); mat.setInt("FilterMode", edgeFilteringMode.getMaterialParamValue()); mat.setFloat("PCFEdge", edgesThickness); mat.setFloat("ShadowIntensity", shadowIntensity); + mat.setBoolean("BackfaceShadows", renderBackFacesShadows); + if (fadeInfo != null) { mat.setVector2("FadeInfo", fadeInfo); } - if(renderBackFacesShadows != null){ - mat.setBoolean("BackfaceShadows", renderBackFacesShadows); - } setMaterialParameters(mat); } @@ -610,9 +608,7 @@ public abstract class AbstractShadowRenderer implements SceneProcessor, Savable, if (fadeInfo != null) { postshadowMat.setVector2("FadeInfo", fadeInfo); } - if(renderBackFacesShadows != null){ - postshadowMat.setBoolean("BackfaceShadows", renderBackFacesShadows); - } + postshadowMat.setBoolean("BackfaceShadows", renderBackFacesShadows); } /** @@ -788,10 +784,11 @@ public abstract class AbstractShadowRenderer implements SceneProcessor, Savable, /** * if this processor renders back faces shadows + * * @return true if this processor renders back faces shadows */ public boolean isRenderBackFacesShadows() { - return renderBackFacesShadows != null?renderBackFacesShadows:false; + return renderBackFacesShadows; } @Override diff --git a/jme3-vr/src/main/java/com/jme3/shadow/AbstractShadowRendererVR.java b/jme3-vr/src/main/java/com/jme3/shadow/AbstractShadowRendererVR.java index 323a452ec..8c9fae742 100644 --- a/jme3-vr/src/main/java/com/jme3/shadow/AbstractShadowRendererVR.java +++ b/jme3-vr/src/main/java/com/jme3/shadow/AbstractShadowRendererVR.java @@ -33,11 +33,7 @@ package com.jme3.shadow; */ import com.jme3.asset.AssetManager; -import com.jme3.export.InputCapsule; -import com.jme3.export.JmeExporter; -import com.jme3.export.JmeImporter; -import com.jme3.export.OutputCapsule; -import com.jme3.export.Savable; +import com.jme3.export.*; import com.jme3.material.Material; import com.jme3.material.RenderState; import com.jme3.math.ColorRGBA; @@ -57,8 +53,6 @@ import com.jme3.renderer.queue.RenderQueue.ShadowMode; import com.jme3.scene.Geometry; import com.jme3.scene.Spatial; import com.jme3.scene.debug.WireFrustum; -import com.jme3.shadow.CompareMode; -import com.jme3.shadow.EdgeFilteringMode; import com.jme3.texture.FrameBuffer; import com.jme3.texture.Image.Format; import com.jme3.texture.Texture.MagFilter; @@ -99,7 +93,7 @@ public abstract class AbstractShadowRendererVR implements SceneProcessor, Savabl protected CompareMode shadowCompareMode = CompareMode.Hardware; protected Picture[] dispPic; protected RenderState forcedRenderState = new RenderState(); - protected Boolean renderBackFacesShadows; + protected boolean renderBackFacesShadows; protected AppProfiler profiler = null; @@ -193,6 +187,7 @@ public abstract class AbstractShadowRendererVR implements SceneProcessor, Savabl setEdgeFilteringMode(edgeFilteringMode); setShadowIntensity(shadowIntensity); initForcedRenderState(); + setRenderBackFacesShadows(isRenderBackFacesShadows()); } protected void initForcedRenderState() { @@ -572,12 +567,11 @@ public abstract class AbstractShadowRendererVR implements SceneProcessor, Savabl mat.setInt("FilterMode", edgeFilteringMode.getMaterialParamValue()); mat.setFloat("PCFEdge", edgesThickness); mat.setFloat("ShadowIntensity", shadowIntensity); + mat.setBoolean("BackfaceShadows", renderBackFacesShadows); + if (fadeInfo != null) { mat.setVector2("FadeInfo", fadeInfo); } - if(renderBackFacesShadows != null){ - mat.setBoolean("BackfaceShadows", renderBackFacesShadows); - } setMaterialParameters(mat); } @@ -617,9 +611,7 @@ public abstract class AbstractShadowRendererVR implements SceneProcessor, Savabl if (fadeInfo != null) { postshadowMat.setVector2("FadeInfo", fadeInfo); } - if(renderBackFacesShadows != null){ - postshadowMat.setBoolean("BackfaceShadows", renderBackFacesShadows); - } + postshadowMat.setBoolean("BackfaceShadows", renderBackFacesShadows); } /** @@ -800,10 +792,11 @@ public abstract class AbstractShadowRendererVR implements SceneProcessor, Savabl /** * if this processor renders back faces shadows + * * @return true if this processor renders back faces shadows */ public boolean isRenderBackFacesShadows() { - return renderBackFacesShadows != null?renderBackFacesShadows:false; + return renderBackFacesShadows; } /**