use of com.jme3.renderer.ViewPort in project jmonkeyengine by jMonkeyEngine.
the class PreNormalCaching method getPreNormals.
/**
* Get pre-normals from the given rendering.
* @param renderManager the render manager.
* @param normalPass the normal pass.
* @param viewPort the viewport.
*/
public static void getPreNormals(RenderManager renderManager, Pass normalPass, ViewPort viewPort) {
curCount++;
// do we already have a valid cache to set the framebuffer to?
Renderer r = renderManager.getRenderer();
if (cachedPreNormals != null) {
r.copyFrameBuffer(cachedPreNormals, normalPass.getRenderFrameBuffer(), false);
} else {
// lets make the prenormals
r.setFrameBuffer(normalPass.getRenderFrameBuffer());
renderManager.getRenderer().clearBuffers(true, true, true);
if (renderManager.getRenderer().getCaps().contains(Caps.GLSL150)) {
renderManager.setForcedTechnique("PreNormalPass15");
} else {
renderManager.setForcedTechnique("PreNormalPass");
}
renderManager.renderViewPortQueues(viewPort, false);
renderManager.setForcedTechnique(null);
// if we should cache this, do it now
if (lastNormalPassesCount > 1) {
cachedPreNormals = normalPass.getRenderFrameBuffer();
}
}
renderManager.getRenderer().setFrameBuffer(viewPort.getOutputFrameBuffer());
}
use of com.jme3.renderer.ViewPort in project jmonkeyengine by jMonkeyEngine.
the class DirectionalLightShadowRendererVR 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;
}
use of com.jme3.renderer.ViewPort in project jmonkeyengine by jMonkeyEngine.
the class VRViewManagerOpenVR method setupFinalFullTexture.
private void setupFinalFullTexture(Camera cam) {
if (environment != null) {
if (environment.getApplication() != null) {
// create offscreen framebuffer
FrameBuffer out = new FrameBuffer(cam.getWidth(), cam.getHeight(), 1);
//offBuffer.setSrgb(true);
//setup framebuffer's texture
dualEyeTex = new Texture2D(cam.getWidth(), cam.getHeight(), Image.Format.RGBA8);
dualEyeTex.setMinFilter(Texture.MinFilter.BilinearNoMipMaps);
dualEyeTex.setMagFilter(Texture.MagFilter.Bilinear);
logger.config("Dual eye texture " + dualEyeTex.getName() + " (" + dualEyeTex.getImage().getId() + ")");
logger.config(" Type: " + dualEyeTex.getType());
logger.config(" Size: " + dualEyeTex.getImage().getWidth() + "x" + dualEyeTex.getImage().getHeight());
logger.config(" Image depth: " + dualEyeTex.getImage().getDepth());
logger.config(" Image format: " + dualEyeTex.getImage().getFormat());
logger.config(" Image color space: " + dualEyeTex.getImage().getColorSpace());
//setup framebuffer to use texture
out.setDepthBuffer(Image.Format.Depth);
out.setColorTexture(dualEyeTex);
ViewPort viewPort = environment.getApplication().getViewPort();
viewPort.setClearFlags(true, true, true);
viewPort.setBackgroundColor(ColorRGBA.Black);
viewPort.setOutputFrameBuffer(out);
} else {
throw new IllegalStateException("This VR environment is not attached to any application.");
}
} else {
throw new IllegalStateException("This VR view manager is not attached to any VR environment.");
}
}
use of com.jme3.renderer.ViewPort in project jmonkeyengine by jMonkeyEngine.
the class VideoRecorderAppState method initialize.
@Override
public void initialize(AppStateManager stateManager, Application app) {
super.initialize(stateManager, app);
this.app = app;
this.oldTimer = app.getTimer();
app.setTimer(new IsoTimer(framerate));
if (file == null) {
String filename = System.getProperty("user.home") + File.separator + "jMonkey-" + System.currentTimeMillis() / 1000 + ".avi";
file = new File(filename);
}
processor = new VideoProcessor();
List<ViewPort> vps = app.getRenderManager().getPostViews();
for (int i = vps.size() - 1; i >= 0; i--) {
lastViewPort = vps.get(i);
if (lastViewPort.isEnabled()) {
break;
}
}
lastViewPort.addProcessor(processor);
}
Aggregations