use of com.jme3.renderer.RenderManager in project jmonkeyengine by jMonkeyEngine.
the class AbstractShadowRenderer method postFrame.
public void postFrame(FrameBuffer out) {
if (skipPostPass) {
return;
}
if (debug) {
displayShadowMap(renderManager.getRenderer());
}
getReceivers(lightReceivers);
if (lightReceivers.size() != 0) {
//setting params to recieving geometry list
setMatParams(lightReceivers);
Camera cam = viewPort.getCamera();
//some materials in the scene does not have a post shadow technique so we're using the fall back material
if (needsfallBackMaterial) {
renderManager.setForcedMaterial(postshadowMat);
}
//forcing the post shadow technique and render state
renderManager.setForcedTechnique(postTechniqueName);
//rendering the post shadow pass
viewPort.getQueue().renderShadowQueue(lightReceivers, renderManager, cam, false);
//resetting renderManager settings
renderManager.setForcedTechnique(null);
renderManager.setForcedMaterial(null);
renderManager.setCamera(cam, false);
//clearing the params in case there are some other shadow renderers
clearMatParams();
}
}
use of com.jme3.renderer.RenderManager in project jmonkeyengine by jMonkeyEngine.
the class BasicShadowRenderer method postQueue.
public void postQueue(RenderQueue rq) {
for (Spatial scene : viewPort.getScenes()) {
ShadowUtil.getGeometriesInCamFrustum(scene, viewPort.getCamera(), ShadowMode.Receive, lightReceivers);
}
// update frustum points based on current camera
Camera viewCam = viewPort.getCamera();
ShadowUtil.updateFrustumPoints(viewCam, viewCam.getFrustumNear(), viewCam.getFrustumFar(), 1.0f, points);
Vector3f frustaCenter = new Vector3f();
for (Vector3f point : points) {
frustaCenter.addLocal(point);
}
frustaCenter.multLocal(1f / 8f);
// update light direction
shadowCam.setProjectionMatrix(null);
shadowCam.setParallelProjection(true);
// shadowCam.setFrustumPerspective(45, 1, 1, 20);
shadowCam.lookAtDirection(direction, Vector3f.UNIT_Y);
shadowCam.update();
shadowCam.setLocation(frustaCenter);
shadowCam.update();
shadowCam.updateViewProjection();
// render shadow casters to shadow map
ShadowUtil.updateShadowCamera(viewPort, lightReceivers, shadowCam, points, shadowOccluders, shadowMapSize);
if (shadowOccluders.size() == 0) {
noOccluders = true;
return;
} else {
noOccluders = false;
}
Renderer r = renderManager.getRenderer();
renderManager.setCamera(shadowCam, false);
renderManager.setForcedMaterial(preshadowMat);
r.setFrameBuffer(shadowFB);
r.clearBuffers(true, true, true);
viewPort.getQueue().renderShadowQueue(shadowOccluders, renderManager, shadowCam, true);
r.setFrameBuffer(viewPort.getOutputFrameBuffer());
renderManager.setForcedMaterial(null);
renderManager.setCamera(viewCam, false);
}
use of com.jme3.renderer.RenderManager in project jmonkeyengine by jMonkeyEngine.
the class PssmShadowRenderer method postFrame.
public void postFrame(FrameBuffer out) {
if (debug) {
displayShadowMap(renderManager.getRenderer());
}
if (!noOccluders) {
//setting params to recieving geometry list
setMatParams();
Camera cam = viewPort.getCamera();
//some materials in the scene does not have a post shadow technique so we're using the fall back material
if (needsfallBackMaterial) {
renderManager.setForcedMaterial(postshadowMat);
}
//forcing the post shadow technique and render state
renderManager.setForcedTechnique(postTechniqueName);
//rendering the post shadow pass
viewPort.getQueue().renderShadowQueue(lightReceivers, renderManager, cam, true);
//resetting renderManager settings
renderManager.setForcedTechnique(null);
renderManager.setForcedMaterial(null);
renderManager.setCamera(cam, false);
}
}
use of com.jme3.renderer.RenderManager in project jmonkeyengine by jMonkeyEngine.
the class OpaqueComparatorTest method testSortByTechnique.
@Test
public void testSortByTechnique() {
Material lightingMatDefault = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
Material lightingPreShadow = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
Material lightingPostShadow = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
Material lightingMatPreNormalPass = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
Material lightingMatGBuf = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
Material lightingMatGlow = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
lightingMatDefault.setName("TechDefault");
lightingMatDefault.selectTechnique(TechniqueDef.DEFAULT_TECHNIQUE_NAME, renderManager);
lightingPostShadow.setName("TechPostShad");
lightingPostShadow.selectTechnique("PostShadow", renderManager);
lightingPreShadow.setName("TechPreShad");
lightingPreShadow.selectTechnique("PreShadow", renderManager);
lightingMatPreNormalPass.setName("TechNorm");
lightingMatPreNormalPass.selectTechnique("PreNormalPass", renderManager);
lightingMatGlow.setName("TechGlow");
lightingMatGlow.selectTechnique("Glow", renderManager);
testSort(lightingMatGlow, lightingPreShadow, lightingMatPreNormalPass, lightingMatDefault, lightingPostShadow);
}
use of com.jme3.renderer.RenderManager in project jmonkeyengine by jMonkeyEngine.
the class FilterPostProcessor method initFilter.
/**
* init the given filter
* @param filter
* @param vp
*/
private void initFilter(Filter filter, ViewPort vp) {
filter.setProcessor(this);
if (filter.isRequiresDepthTexture()) {
if (!computeDepth && renderFrameBuffer != null) {
depthTexture = new Texture2D(width, height, Format.Depth24);
renderFrameBuffer.setDepthTexture(depthTexture);
}
computeDepth = true;
filter.init(assetManager, renderManager, vp, width, height);
filter.setDepthTexture(depthTexture);
} else {
filter.init(assetManager, renderManager, vp, width, height);
}
}
Aggregations