use of com.jme3.shadow.PssmShadowRenderer.FilterMode in project jmonkeyengine by jMonkeyEngine.
the class PssmShadowRenderer method setCompareMode.
/**
* sets the shadow compare mode see {@link CompareMode} for more info
*
* @param compareMode
*/
public final void setCompareMode(CompareMode compareMode) {
if (compareMode == null) {
throw new NullPointerException();
}
if (this.compareMode == compareMode) {
return;
}
this.compareMode = compareMode;
for (Texture2D shadowMap : shadowMaps) {
if (compareMode == CompareMode.Hardware) {
shadowMap.setShadowCompareMode(ShadowCompareMode.LessOrEqual);
if (filterMode == FilterMode.Bilinear) {
shadowMap.setMagFilter(MagFilter.Bilinear);
shadowMap.setMinFilter(MinFilter.BilinearNoMipMaps);
} else {
shadowMap.setMagFilter(MagFilter.Nearest);
shadowMap.setMinFilter(MinFilter.NearestNoMipMaps);
}
} else {
shadowMap.setShadowCompareMode(ShadowCompareMode.Off);
shadowMap.setMagFilter(MagFilter.Nearest);
shadowMap.setMinFilter(MinFilter.NearestNoMipMaps);
}
}
postshadowMat.setBoolean("HardwareShadows", compareMode == CompareMode.Hardware);
applyHWShadows = true;
}
use of com.jme3.shadow.PssmShadowRenderer.FilterMode in project jmonkeyengine by jMonkeyEngine.
the class AbstractShadowRendererVR method setMatParams.
private void setMatParams(GeometryList l) {
//iteration throught all the geometries of the list to gather the materials
buildMatCache(l);
//iterating through the mat cache and setting the parameters
for (Material mat : matCache) {
mat.setFloat("ShadowMapSize", shadowMapSize);
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);
if (fadeInfo != null) {
mat.setVector2("FadeInfo", fadeInfo);
}
if (renderBackFacesShadows != null) {
mat.setBoolean("BackfaceShadows", renderBackFacesShadows);
}
setMaterialParameters(mat);
}
//so we fall back to the forced material solution (transparent shadows won't be supported for these objects)
if (needsfallBackMaterial) {
setPostShadowParams();
}
}
use of com.jme3.shadow.PssmShadowRenderer.FilterMode in project jmonkeyengine by jMonkeyEngine.
the class AbstractShadowRendererVR method setEdgeFilteringMode.
/**
* Sets the filtering mode for shadow edges. See {@link EdgeFilteringMode}
* for more info.
*
* @param filterMode the desired filter mode (not null)
*/
public final void setEdgeFilteringMode(EdgeFilteringMode filterMode) {
if (filterMode == null) {
throw new NullPointerException();
}
this.edgeFilteringMode = filterMode;
postshadowMat.setInt("FilterMode", filterMode.getMaterialParamValue());
postshadowMat.setFloat("PCFEdge", edgesThickness);
if (shadowCompareMode == CompareMode.Hardware) {
for (Texture2D shadowMap : shadowMaps) {
if (filterMode == EdgeFilteringMode.Bilinear) {
shadowMap.setMagFilter(MagFilter.Bilinear);
shadowMap.setMinFilter(MinFilter.BilinearNoMipMaps);
} else {
shadowMap.setMagFilter(MagFilter.Nearest);
shadowMap.setMinFilter(MinFilter.NearestNoMipMaps);
}
}
}
}
Aggregations