use of org.terasology.rendering.opengl.FBO in project Terasology by MovingBlocks.
the class DisplayResolutionDependentFBOs method request.
@Override
public FBO request(FBOConfig fboConfig) {
FBO fbo;
SimpleUri fboName = fboConfig.getName();
if (fboConfigs.containsKey(fboName)) {
if (!fboConfig.equals(fboConfigs.get(fboName))) {
throw new IllegalArgumentException("Requested FBO is already available with different configuration");
}
fbo = fboLookup.get(fboConfig.getName());
} else {
fbo = generateWithDimensions(fboConfig, fullScale.multiplyBy(fboConfig.getScale()));
}
retain(fboName);
return fbo;
}
use of org.terasology.rendering.opengl.FBO in project Terasology by MovingBlocks.
the class ShadowMapResolutionDependentFBOs method propertyChange.
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (renderingConfig.isDynamicShadows()) {
int shadowMapResFromSettings = (int) evt.getNewValue();
shadowMapResolution = new FBO.Dimensions(shadowMapResFromSettings, shadowMapResFromSettings);
for (Map.Entry<SimpleUri, FBOConfig> entry : fboConfigs.entrySet()) {
SimpleUri fboName = entry.getKey();
FBOConfig fboConfig = entry.getValue();
if (fboLookup.containsKey(fboName)) {
FBO fbo = fboLookup.get(fboName);
if (fbo != null) {
// TODO: validate if necessary
fbo.dispose();
}
}
FBO shadowMapResDependentFBO = generateWithDimensions(fboConfig, shadowMapResolution);
if (shadowMapResDependentFBO.getStatus() == FBO.Status.DISPOSED) {
logger.warn("Failed to generate ShadowMap FBO. Turning off shadows.");
renderingConfig.setDynamicShadows(false);
break;
}
fboLookup.put(fboName, shadowMapResDependentFBO);
}
}
}
use of org.terasology.rendering.opengl.FBO in project Terasology by MovingBlocks.
the class WorldRendererImpl method render.
/**
* TODO: update javadocs
* This method triggers the execution of the rendering pipeline and, eventually, sends the output to the display
* or to a file, when grabbing a screenshot.
* <p>
* In this particular implementation this method can be called once per frame, when rendering to a standard display,
* or twice, each time with a different rendering stage, when rendering to the head mounted display.
* <p>
* PerformanceMonitor.startActivity/endActivity statements are used in this method and in those it executes,
* to provide statistics regarding the ongoing rendering and its individual steps (i.e. rendering shadows,
* reflections, 2D filters...).
*
* @param renderingStage "MONO" for standard rendering and "LEFT_EYE" or "RIGHT_EYE" for stereoscopic displays.
*/
@Override
public void render(RenderingStage renderingStage) {
preRenderUpdate(renderingStage);
// TODO: Add a method here to check wireframe configuration and regenerate "renderPipelineTask" accordingly.
// The following line re-establish OpenGL defaults, so that the nodes/tasks can rely on them.
// A place where Terasology overrides the defaults is LwjglGraphics.initOpenGLParams(), but
// there could be potentially other places, i.e. in the UI code. In the rendering engine we'd like
// to eventually rely on a default OpenGL state.
glDisable(GL_CULL_FACE);
FBO lastUpdatedGBuffer = displayResolutionDependentFBOs.getGBufferPair().getLastUpdatedFbo();
glViewport(0, 0, lastUpdatedGBuffer.width(), lastUpdatedGBuffer.height());
// glDisable(GL_DEPTH_TEST);
// glDisable(GL_NORMALIZE); // currently keeping these as they are, until we find where they are used.
// glDepthFunc(GL_LESS);
renderPipelineTaskList.forEach(RenderPipelineTask::process);
// this line re-establish Terasology defaults, so that the rest of the application can rely on them.
LwjglGraphics.initOpenGLParams();
playerCamera.updatePrevViewProjectionMatrix();
}
use of org.terasology.rendering.opengl.FBO in project Terasology by MovingBlocks.
the class WorldRendererImpl method addFinalPostProcessingNodes.
private void addFinalPostProcessingNodes(RenderGraph renderGraph) {
Node initialPostProcessingNode = renderGraph.findNode("engine:initialPostProcessingNode");
Node updateExposureNode = renderGraph.findNode("engine:updateExposureNode");
Node toneMappingNode = new ToneMappingNode(context);
renderGraph.addNode(toneMappingNode, "toneMappingNode");
renderGraph.connect(updateExposureNode, toneMappingNode);
renderGraph.connect(initialPostProcessingNode, toneMappingNode);
// Late Blur nodes: assisting Motion Blur and Depth-of-Field effects
FBOConfig firstLateBlurConfig = new FBOConfig(FIRST_LATE_BLUR_FBO_URI, HALF_SCALE, FBO.Type.DEFAULT);
FBO firstLateBlurFbo = displayResolutionDependentFBOs.request(firstLateBlurConfig);
LateBlurNode firstLateBlurNode = new LateBlurNode(context, displayResolutionDependentFBOs.get(ToneMappingNode.TONE_MAPPING_FBO_URI), firstLateBlurFbo);
renderGraph.addNode(firstLateBlurNode, "firstLateBlurNode");
FBOConfig secondLateBlurConfig = new FBOConfig(SECOND_LATE_BLUR_FBO_URI, HALF_SCALE, FBO.Type.DEFAULT);
FBO secondLateBlurFbo = displayResolutionDependentFBOs.request(secondLateBlurConfig);
LateBlurNode secondLateBlurNode = new LateBlurNode(context, firstLateBlurFbo, secondLateBlurFbo);
renderGraph.addNode(secondLateBlurNode, "secondLateBlurNode");
Node finalPostProcessingNode = new FinalPostProcessingNode(context);
renderGraph.addNode(finalPostProcessingNode, "finalPostProcessingNode");
renderGraph.connect(toneMappingNode, firstLateBlurNode, secondLateBlurNode, finalPostProcessingNode);
}
use of org.terasology.rendering.opengl.FBO in project Terasology by MovingBlocks.
the class OutputToScreenNode method handleCommand.
@Override
public void handleCommand(String command, String... arguments) {
switch(command) {
case "setFbo":
if (arguments.length != 1) {
throw new RuntimeException("Invalid number of arguments; expected 1, received " + arguments.length + "!");
}
FBO fbo;
switch(arguments[0]) {
case "engine:fbo.gBuffer":
case "engine:fbo.lastUpdatedGBuffer":
fbo = lastUpdatedGBuffer;
break;
case "engine:fbo.staleGBuffer":
fbo = staleGBuffer;
break;
default:
fbo = displayResolutionDependentFBOs.get(new SimpleUri(arguments[0]));
if (fbo == null) {
throw new RuntimeException(("No FBO is associated with URI '" + arguments[0] + "'"));
}
break;
}
setFbo(fbo);
break;
default:
throw new RuntimeException("Unrecognized command: '" + command + "'");
}
}
Aggregations