Search in sources :

Example 6 with GeometryList

use of com.jme3.renderer.queue.GeometryList in project jmonkeyengine by jMonkeyEngine.

the class DirectionalLightShadowRenderer method getOccludersToRender.

@Override
protected GeometryList getOccludersToRender(int shadowMapIndex, GeometryList shadowMapOccluders) {
    // update frustum points based on current camera and split
    ShadowUtil.updateFrustumPoints(viewPort.getCamera(), splitsArray[shadowMapIndex], splitsArray[shadowMapIndex + 1], 1.0f, points);
    //Updating shadow cam with curent split frustra
    if (lightReceivers.size() == 0) {
        for (Spatial scene : viewPort.getScenes()) {
            ShadowUtil.getGeometriesInCamFrustum(scene, viewPort.getCamera(), RenderQueue.ShadowMode.Receive, lightReceivers);
        }
    }
    ShadowUtil.updateShadowCamera(viewPort, lightReceivers, shadowCam, points, shadowMapOccluders, stabilize ? shadowMapSize : 0);
    return shadowMapOccluders;
}
Also used : Spatial(com.jme3.scene.Spatial)

Example 7 with GeometryList

use of com.jme3.renderer.queue.GeometryList in project jmonkeyengine by jMonkeyEngine.

the class SpotLightShadowRenderer method getReceivers.

@Override
protected void getReceivers(GeometryList lightReceivers) {
    lightReceivers.clear();
    Camera[] cameras = new Camera[1];
    cameras[0] = shadowCam;
    for (Spatial scene : viewPort.getScenes()) {
        ShadowUtil.getLitGeometriesInViewPort(scene, viewPort.getCamera(), cameras, RenderQueue.ShadowMode.Receive, lightReceivers);
    }
}
Also used : Spatial(com.jme3.scene.Spatial) Camera(com.jme3.renderer.Camera)

Example 8 with GeometryList

use of com.jme3.renderer.queue.GeometryList in project jmonkeyengine by jMonkeyEngine.

the class RenderQueue method renderGeometryList.

private void renderGeometryList(GeometryList list, RenderManager rm, Camera cam, boolean clear) {
    // select camera for sorting
    list.setCamera(cam);
    list.sort();
    for (int i = 0; i < list.size(); i++) {
        Geometry obj = list.get(i);
        assert obj != null;
        rm.renderGeometry(obj);
        obj.queueDistance = Float.NEGATIVE_INFINITY;
    }
    if (clear) {
        list.clear();
    }
}
Also used : Geometry(com.jme3.scene.Geometry)

Example 9 with GeometryList

use of com.jme3.renderer.queue.GeometryList in project jmonkeyengine by jMonkeyEngine.

the class AbstractShadowRenderer 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();
    }
}
Also used : Material(com.jme3.material.Material)

Example 10 with GeometryList

use of com.jme3.renderer.queue.GeometryList in project jmonkeyengine by jMonkeyEngine.

the class PssmShadowUtil method computeZFar.

/**
     * Compute the Zfar in the model vieuw to adjust the Zfar distance for the splits calculation
     */
public static float computeZFar(GeometryList occ, GeometryList recv, Camera cam) {
    Matrix4f mat = cam.getViewMatrix();
    BoundingBox bbOcc = ShadowUtil.computeUnionBound(occ, mat);
    BoundingBox bbRecv = ShadowUtil.computeUnionBound(recv, mat);
    return min(max(bbOcc.getZExtent() - bbOcc.getCenter().z, bbRecv.getZExtent() - bbRecv.getCenter().z), cam.getFrustumFar());
}
Also used : Matrix4f(com.jme3.math.Matrix4f) BoundingBox(com.jme3.bounding.BoundingBox)

Aggregations

Geometry (com.jme3.scene.Geometry)6 Spatial (com.jme3.scene.Spatial)5 BoundingBox (com.jme3.bounding.BoundingBox)4 Material (com.jme3.material.Material)4 BoundingVolume (com.jme3.bounding.BoundingVolume)3 Camera (com.jme3.renderer.Camera)3 TempVars (com.jme3.util.TempVars)3 Matrix4f (com.jme3.math.Matrix4f)2 GeometryList (com.jme3.renderer.queue.GeometryList)2 Vector3f (com.jme3.math.Vector3f)1 Node (com.jme3.scene.Node)1 HashSet (java.util.HashSet)1