use of com.jme3.renderer.RenderManager in project jmonkeyengine by jMonkeyEngine.
the class TestShaderNodes method simpleInitApp.
@Override
public void simpleInitApp() {
flyCam.setMoveSpeed(20);
Logger.getLogger("com.jme3").setLevel(Level.WARNING);
Box boxshape1 = new Box(1f, 1f, 1f);
Geometry cube_tex = new Geometry("A Textured Box", boxshape1);
Texture tex = assetManager.loadTexture("Interface/Logo/Monkey.jpg");
Material mat = new Material(assetManager, "Common/MatDefs/Misc/UnshadedNodes.j3md");
mat.selectTechnique(TechniqueDef.DEFAULT_TECHNIQUE_NAME, renderManager);
Technique t = mat.getActiveTechnique();
// for (Shader.ShaderSource shaderSource : t.getShader().getSources()) {
// System.out.println(shaderSource.getSource());
// }
mat.setColor("Color", ColorRGBA.Yellow);
mat.setTexture("ColorMap", tex);
cube_tex.setMaterial(mat);
rootNode.attachChild(cube_tex);
}
use of com.jme3.renderer.RenderManager in project jmonkeyengine by jMonkeyEngine.
the class TestDepthStencil method simpleRender.
@Override
public void simpleRender(RenderManager rm) {
Renderer r = rm.getRenderer();
//do FBO rendering
r.setFrameBuffer(fb);
// FBO uses current camera
rm.setCamera(cam, false);
r.clearBuffers(true, true, true);
rm.renderScene(fbNode, viewPort);
rm.flushQueue(viewPort);
//go back to default rendering and let
//SimpleApplication render the default scene
r.setFrameBuffer(null);
}
use of com.jme3.renderer.RenderManager in project jmonkeyengine by jMonkeyEngine.
the class VRViewManagerOSVR method setupCamerasAndViews.
private void setupCamerasAndViews() {
if (environment != null) {
if (environment.getApplication() != null) {
// get desired frustrum from original camera
Camera origCam = environment.getCamera();
float fFar = origCam.getFrustumFar();
float fNear = origCam.getFrustumNear();
// if we are using OSVR get the eye info here
if (environment.getVRHardware() instanceof OSVR) {
((OSVR) environment.getVRHardware()).getEyeInfo();
}
// restore frustrum on distortion scene cam, if needed
if (environment.isInstanceRendering()) {
leftCamera = origCam;
} else if (environment.compositorAllowed() == false) {
origCam.setFrustumFar(100f);
origCam.setFrustumNear(1f);
leftCamera = origCam.clone();
prepareCameraSize(origCam, 2f);
} else {
leftCamera = origCam.clone();
}
leftCamera.setFrustumPerspective(environment.getDefaultFOV(), environment.getDefaultAspect(), fNear, fFar);
prepareCameraSize(leftCamera, 1f);
if (environment.getVRHardware() != null)
leftCamera.setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionLeftEye(leftCamera));
if (!environment.isInstanceRendering()) {
leftViewport = setupViewBuffers(leftCamera, LEFT_VIEW_NAME);
rightCamera = leftCamera.clone();
if (environment.getVRHardware() != null) {
rightCamera.setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionRightEye(rightCamera));
}
rightViewport = setupViewBuffers(rightCamera, RIGHT_VIEW_NAME);
} else {
System.err.println("[VRViewManager] THIS CODE NEED CHANGES !!!");
leftViewport = environment.getApplication().getViewPort();
//leftViewport.attachScene(app.getRootNode());
rightCamera = leftCamera.clone();
if (environment.getVRHardware() != null) {
rightCamera.setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionRightEye(rightCamera));
}
org.lwjgl.opengl.GL11.glEnable(org.lwjgl.opengl.GL30.GL_CLIP_DISTANCE0);
//FIXME: [jme-vr] Fix with JMonkey next release
//RenderManager._VRInstancing_RightCamProjection = camRight.getViewProjectionMatrix();
setupFinalFullTexture(environment.getApplication().getViewPort().getCamera());
}
// setup gui
environment.getVRGUIManager().setupGui(leftCamera, rightCamera, leftViewport, rightViewport);
if (environment.getVRHardware() != null) {
// call these to cache the results internally
environment.getVRHardware().getHMDMatrixPoseLeftEye();
environment.getVRHardware().getHMDMatrixPoseRightEye();
}
} 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.RenderManager in project jmonkeyengine by jMonkeyEngine.
the class VRViewManagerOpenVR method setupCamerasAndViews.
private void setupCamerasAndViews() {
if (environment != null) {
// get desired frustrum from original camera
Camera origCam = environment.getCamera();
float fFar = origCam.getFrustumFar();
float fNear = origCam.getFrustumNear();
// restore frustrum on distortion scene cam, if needed
if (environment.isInstanceRendering()) {
leftCamera = origCam;
} else if (environment.compositorAllowed() == false) {
origCam.setFrustumFar(100f);
origCam.setFrustumNear(1f);
leftCamera = origCam.clone();
prepareCameraSize(origCam, 2f);
} else {
leftCamera = origCam.clone();
}
getLeftCamera().setFrustumPerspective(environment.getDefaultFOV(), environment.getDefaultAspect(), fNear, fFar);
prepareCameraSize(getLeftCamera(), 1f);
if (environment.getVRHardware() != null) {
getLeftCamera().setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionLeftEye(getLeftCamera()));
}
if (!environment.isInstanceRendering()) {
leftViewport = setupViewBuffers(getLeftCamera(), LEFT_VIEW_NAME);
rightCamera = getLeftCamera().clone();
if (environment.getVRHardware() != null) {
getRightCamera().setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionRightEye(getRightCamera()));
}
rightViewport = setupViewBuffers(getRightCamera(), RIGHT_VIEW_NAME);
} else {
if (environment.getApplication() != null) {
logger.severe("THIS CODE NEED CHANGES !!!");
leftViewport = environment.getApplication().getViewPort();
//leftViewport.attachScene(app.getRootNode());
rightCamera = getLeftCamera().clone();
if (environment.getVRHardware() != null) {
getRightCamera().setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionRightEye(getRightCamera()));
}
org.lwjgl.opengl.GL11.glEnable(org.lwjgl.opengl.GL30.GL_CLIP_DISTANCE0);
//FIXME: [jme-vr] Fix with JMonkey next release
//RenderManager._VRInstancing_RightCamProjection = camRight.getViewProjectionMatrix();
setupFinalFullTexture(environment.getApplication().getViewPort().getCamera());
} else {
throw new IllegalStateException("This VR environment is not attached to any application.");
}
}
// setup gui
environment.getVRGUIManager().setupGui(getLeftCamera(), getRightCamera(), getLeftViewport(), getRightViewport());
if (environment.getVRHardware() != null) {
// call these to cache the results internally
environment.getVRHardware().getHMDMatrixPoseLeftEye();
environment.getVRHardware().getHMDMatrixPoseRightEye();
}
} else {
throw new IllegalStateException("This VR view manager is not attached to any VR environment.");
}
}
use of com.jme3.renderer.RenderManager in project jmonkeyengine by jMonkeyEngine.
the class CartoonSSAO method initFilter.
@Override
protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
this.renderManager = renderManager;
this.viewPort = vp;
int screenWidth = Math.round(w / downsample);
int screenHeight = Math.round(h / downsample);
normalPass = new Pass();
normalPass.init(renderManager.getRenderer(), screenWidth, screenHeight, Format.RGBA8, Format.Depth);
frustumNearFar = new Vector2f();
float farY = (vp.getCamera().getFrustumTop() / vp.getCamera().getFrustumNear()) * vp.getCamera().getFrustumFar();
float farX = farY * ((float) screenWidth / (float) screenHeight);
frustumCorner = new Vector3f(farX, farY, vp.getCamera().getFrustumFar());
frustumNearFar.x = vp.getCamera().getFrustumNear();
frustumNearFar.y = vp.getCamera().getFrustumFar();
//ssao Pass
material = new Material(manager, "Common/MatDefs/VR/CartoonSSAO.j3md");
material.setTexture("Normals", normalPass.getRenderedTexture());
material.setVector3("FrustumCorner", frustumCorner);
material.setVector2("FrustumNearFar", frustumNearFar);
material.setFloat("Distance", applyDistance);
if (useOutline == false)
material.setBoolean("disableOutline", true);
if (instancedRendering)
material.setBoolean("useInstancing", true);
}
Aggregations