use of com.jme3.shadow.EdgeFilteringMode in project jmonkeyengine by jMonkeyEngine.
the class AbstractShadowRenderer 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);
}
}
}
}
use of com.jme3.shadow.EdgeFilteringMode in project jmonkeyengine by jMonkeyEngine.
the class AbstractShadowRenderer method write.
/**
* Serialize this instance, for example when saving to a J3O file.
*
* @param ex exporter (not null)
*/
public void write(JmeExporter ex) throws IOException {
OutputCapsule oc = ex.getCapsule(this);
oc.write(nbShadowMaps, "nbShadowMaps", 1);
oc.write(shadowMapSize, "shadowMapSize", 0);
oc.write(shadowIntensity, "shadowIntensity", 0.7f);
oc.write(edgeFilteringMode, "edgeFilteringMode", EdgeFilteringMode.Bilinear);
oc.write(shadowCompareMode, "shadowCompareMode", CompareMode.Hardware);
oc.write(edgesThickness, "edgesThickness", 1.0f);
}
use of com.jme3.shadow.EdgeFilteringMode in project jmonkeyengine by jMonkeyEngine.
the class ShadowTestUIManager method onAction.
public void onAction(String name, boolean keyPressed, float tpf) {
if (name.equals("toggle") && keyPressed) {
renderModeIndex += 1;
renderModeIndex %= 3;
switch(renderModeIndex) {
case 0:
viewPort.addProcessor(plsr);
shadowTypeText.setText(TYPE_TEXT + "Processor");
break;
case 1:
viewPort.removeProcessor(plsr);
plsf.setEnabled(true);
shadowTypeText.setText(TYPE_TEXT + "Filter");
break;
case 2:
plsf.setEnabled(false);
shadowTypeText.setText(TYPE_TEXT + "None");
break;
}
} else if (name.equals("toggleHW") && keyPressed) {
hardwareShadows = !hardwareShadows;
plsr.setShadowCompareMode(hardwareShadows ? CompareMode.Hardware : CompareMode.Software);
plsf.setShadowCompareMode(hardwareShadows ? CompareMode.Hardware : CompareMode.Software);
shadowCompareText.setText(COMPARE_TEXT + (hardwareShadows ? "Hardware" : "Software"));
}
if (name.equals("changeFiltering") && keyPressed) {
filteringIndex = plsr.getEdgeFilteringMode().ordinal();
filteringIndex = (filteringIndex + 1) % EdgeFilteringMode.values().length;
EdgeFilteringMode m = EdgeFilteringMode.values()[filteringIndex];
plsr.setEdgeFilteringMode(m);
plsf.setEdgeFilteringMode(m);
shadowFilterText.setText(FILTERING_TEXT + m.toString());
}
if (name.equals("ShadowUp") && keyPressed) {
plsr.setShadowIntensity(plsr.getShadowIntensity() + 0.1f);
plsf.setShadowIntensity(plsf.getShadowIntensity() + 0.1f);
shadowIntensityText.setText(INTENSITY_TEXT + plsr.getShadowIntensity());
}
if (name.equals("ShadowDown") && keyPressed) {
plsr.setShadowIntensity(plsr.getShadowIntensity() - 0.1f);
plsf.setShadowIntensity(plsf.getShadowIntensity() - 0.1f);
shadowIntensityText.setText(INTENSITY_TEXT + plsr.getShadowIntensity());
}
if (name.equals("ThicknessUp") && keyPressed) {
plsr.setEdgesThickness(plsr.getEdgesThickness() + 1);
plsf.setEdgesThickness(plsf.getEdgesThickness() + 1);
System.out.println("Shadow thickness : " + plsr.getEdgesThickness());
}
if (name.equals("ThicknessDown") && keyPressed) {
plsr.setEdgesThickness(plsr.getEdgesThickness() - 1);
plsf.setEdgesThickness(plsf.getEdgesThickness() - 1);
System.out.println("Shadow thickness : " + plsr.getEdgesThickness());
}
}
use of com.jme3.shadow.EdgeFilteringMode 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);
}
}
}
}
use of com.jme3.shadow.EdgeFilteringMode in project jmonkeyengine by jMonkeyEngine.
the class AbstractShadowRendererVR method init.
private void init(AssetManager assetManager, int nbShadowMaps, int shadowMapSize) {
this.postshadowMat = new Material(assetManager, "Common/MatDefs/Shadow/PostShadow.j3md");
shadowFB = new FrameBuffer[nbShadowMaps];
shadowMaps = new Texture2D[nbShadowMaps];
dispPic = new Picture[nbShadowMaps];
lightViewProjectionsMatrices = new Matrix4f[nbShadowMaps];
shadowMapStringCache = new String[nbShadowMaps];
lightViewStringCache = new String[nbShadowMaps];
//DO NOT COMMENT THIS (it prevent the OSX incomplete read buffer crash)
dummyTex = new Texture2D(shadowMapSize, shadowMapSize, Format.RGBA8);
preshadowMat = new Material(assetManager, "Common/MatDefs/Shadow/PreShadow.j3md");
postshadowMat.setFloat("ShadowMapSize", shadowMapSize);
for (int i = 0; i < nbShadowMaps; i++) {
lightViewProjectionsMatrices[i] = new Matrix4f();
shadowFB[i] = new FrameBuffer(shadowMapSize, shadowMapSize, 1);
shadowMaps[i] = new Texture2D(shadowMapSize, shadowMapSize, Format.Depth);
shadowFB[i].setDepthTexture(shadowMaps[i]);
//DO NOT COMMENT THIS (it prevent the OSX incomplete read buffer crash)
shadowFB[i].setColorTexture(dummyTex);
shadowMapStringCache[i] = "ShadowMap" + i;
lightViewStringCache[i] = "LightViewProjectionMatrix" + i;
postshadowMat.setTexture(shadowMapStringCache[i], shadowMaps[i]);
//quads for debuging purpose
dispPic[i] = new Picture("Picture" + i);
dispPic[i].setTexture(assetManager, shadowMaps[i], false);
}
setShadowCompareMode(shadowCompareMode);
setEdgeFilteringMode(edgeFilteringMode);
setShadowIntensity(shadowIntensity);
initForcedRenderState();
}
Aggregations