Search in sources :

Example 1 with CompareMode

use of com.jme3.shadow.CompareMode in project jmonkeyengine by jMonkeyEngine.

the class PssmShadowRenderer method setMatParams.

private void setMatParams() {
    GeometryList l = lightReceivers;
    //iteration throught all the geometries of the list to gather the materials
    matCache.clear();
    for (int i = 0; i < l.size(); i++) {
        Material mat = l.get(i).getMaterial();
        //checking if the material has the post technique and adding it to the material cache
        if (mat.getMaterialDef().getTechniqueDefs(postTechniqueName) != null) {
            if (!matCache.contains(mat)) {
                matCache.add(mat);
            }
        } else {
            needsfallBackMaterial = true;
        }
    }
    //iterating through the mat cache and setting the parameters
    for (Material mat : matCache) {
        mat.setColor("Splits", splits);
        mat.setFloat("ShadowMapSize", shadowMapSize);
        for (int j = 0; j < nbSplits; j++) {
            mat.setMatrix4("LightViewProjectionMatrix" + j, lightViewProjectionsMatrices[j]);
        }
        for (int j = 0; j < nbSplits; j++) {
            mat.setTexture("ShadowMap" + j, shadowMaps[j]);
        }
        mat.setBoolean("HardwareShadows", compareMode == CompareMode.Hardware);
        mat.setInt("FilterMode", filterMode.ordinal());
        mat.setFloat("PCFEdge", edgesThickness);
        mat.setFloat("ShadowIntensity", shadowIntensity);
        if (fadeInfo != null) {
            mat.setVector2("FadeInfo", fadeInfo);
        }
    }
    applyHWShadows = false;
    applyFilterMode = false;
    applyPCFEdge = false;
    applyShadowIntensity = false;
    applyFadeInfo = false;
    //so we fall back to the forced material solution (transparent shadows won't be supported for these objects)
    if (needsfallBackMaterial) {
        setPostShadowParams();
    }
}
Also used : GeometryList(com.jme3.renderer.queue.GeometryList) Material(com.jme3.material.Material)

Example 2 with CompareMode

use of com.jme3.shadow.CompareMode in project jmonkeyengine by jMonkeyEngine.

the class PssmShadowRenderer method setFilterMode.

/**
     * Sets the filtering mode for shadow edges see {@link FilterMode} for more
     * info
     *
     * @param filterMode
     */
public final void setFilterMode(FilterMode filterMode) {
    if (filterMode == null) {
        throw new NullPointerException();
    }
    if (this.filterMode == filterMode) {
        return;
    }
    this.filterMode = filterMode;
    postshadowMat.setInt("FilterMode", filterMode.ordinal());
    postshadowMat.setFloat("PCFEdge", edgesThickness);
    if (compareMode == CompareMode.Hardware) {
        for (Texture2D shadowMap : shadowMaps) {
            if (filterMode == FilterMode.Bilinear) {
                shadowMap.setMagFilter(MagFilter.Bilinear);
                shadowMap.setMinFilter(MinFilter.BilinearNoMipMaps);
            } else {
                shadowMap.setMagFilter(MagFilter.Nearest);
                shadowMap.setMinFilter(MinFilter.NearestNoMipMaps);
            }
        }
    }
    applyFilterMode = true;
}
Also used : Texture2D(com.jme3.texture.Texture2D)

Example 3 with CompareMode

use of com.jme3.shadow.CompareMode in project jmonkeyengine by jMonkeyEngine.

the class AbstractShadowRenderer method setShadowCompareMode.

/**
     * Sets the shadow compare mode. See {@link CompareMode} for more info.
     *
     * @param compareMode the desired compare mode (not null)
     */
public final void setShadowCompareMode(CompareMode compareMode) {
    if (compareMode == null) {
        throw new IllegalArgumentException("Shadow compare mode cannot be null");
    }
    this.shadowCompareMode = compareMode;
    for (Texture2D shadowMap : shadowMaps) {
        if (compareMode == CompareMode.Hardware) {
            shadowMap.setShadowCompareMode(ShadowCompareMode.LessOrEqual);
            if (edgeFilteringMode == EdgeFilteringMode.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);
}
Also used : Texture2D(com.jme3.texture.Texture2D)

Example 4 with CompareMode

use of com.jme3.shadow.CompareMode 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;
}
Also used : Texture2D(com.jme3.texture.Texture2D)

Example 5 with CompareMode

use of com.jme3.shadow.CompareMode in project jmonkeyengine by jMonkeyEngine.

the class AbstractShadowRendererVR method setShadowCompareMode.

/**
     * Sets the shadow compare mode. See {@link CompareMode} for more info.
     *
     * @param compareMode the desired compare mode (not null)
     */
public final void setShadowCompareMode(CompareMode compareMode) {
    if (compareMode == null) {
        throw new IllegalArgumentException("Shadow compare mode cannot be null");
    }
    this.shadowCompareMode = compareMode;
    for (Texture2D shadowMap : shadowMaps) {
        if (compareMode == CompareMode.Hardware) {
            shadowMap.setShadowCompareMode(ShadowCompareMode.LessOrEqual);
            if (edgeFilteringMode == EdgeFilteringMode.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);
}
Also used : Texture2D(com.jme3.texture.Texture2D)

Aggregations

Texture2D (com.jme3.texture.Texture2D)4 Material (com.jme3.material.Material)1 GeometryList (com.jme3.renderer.queue.GeometryList)1