Search in sources :

Example 6 with FBO

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;
}
Also used : SwappableFBO(org.terasology.rendering.opengl.SwappableFBO) FBO(org.terasology.rendering.opengl.FBO) SimpleUri(org.terasology.engine.SimpleUri)

Example 7 with 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);
        }
    }
}
Also used : FBOConfig(org.terasology.rendering.opengl.FBOConfig) FBO(org.terasology.rendering.opengl.FBO) SimpleUri(org.terasology.engine.SimpleUri) Map(java.util.Map)

Example 8 with FBO

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();
}
Also used : SwappableFBO(org.terasology.rendering.opengl.SwappableFBO) FBO(org.terasology.rendering.opengl.FBO) RenderPipelineTask(org.terasology.rendering.dag.RenderPipelineTask)

Example 9 with FBO

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);
}
Also used : FBOConfig(org.terasology.rendering.opengl.FBOConfig) SwappableFBO(org.terasology.rendering.opengl.SwappableFBO) FBO(org.terasology.rendering.opengl.FBO) LateBlurNode(org.terasology.rendering.dag.nodes.LateBlurNode) FinalPostProcessingNode(org.terasology.rendering.dag.nodes.FinalPostProcessingNode) DeferredMainLightNode(org.terasology.rendering.dag.nodes.DeferredMainLightNode) PrePostCompositeNode(org.terasology.rendering.dag.nodes.PrePostCompositeNode) ShadowMapNode(org.terasology.rendering.dag.nodes.ShadowMapNode) OutlineNode(org.terasology.rendering.dag.nodes.OutlineNode) InitialPostProcessingNode(org.terasology.rendering.dag.nodes.InitialPostProcessingNode) BlurredAmbientOcclusionNode(org.terasology.rendering.dag.nodes.BlurredAmbientOcclusionNode) OpaqueBlocksNode(org.terasology.rendering.dag.nodes.OpaqueBlocksNode) AmbientOcclusionNode(org.terasology.rendering.dag.nodes.AmbientOcclusionNode) FinalPostProcessingNode(org.terasology.rendering.dag.nodes.FinalPostProcessingNode) UpdateExposureNode(org.terasology.rendering.dag.nodes.UpdateExposureNode) LightShaftsNode(org.terasology.rendering.dag.nodes.LightShaftsNode) AlphaRejectBlocksNode(org.terasology.rendering.dag.nodes.AlphaRejectBlocksNode) Node(org.terasology.rendering.dag.Node) DeferredPointLightsNode(org.terasology.rendering.dag.nodes.DeferredPointLightsNode) WorldReflectionNode(org.terasology.rendering.dag.nodes.WorldReflectionNode) ToneMappingNode(org.terasology.rendering.dag.nodes.ToneMappingNode) BufferClearingNode(org.terasology.rendering.dag.nodes.BufferClearingNode) HighPassNode(org.terasology.rendering.dag.nodes.HighPassNode) BloomBlurNode(org.terasology.rendering.dag.nodes.BloomBlurNode) OpaqueObjectsNode(org.terasology.rendering.dag.nodes.OpaqueObjectsNode) OutputToHMDNode(org.terasology.rendering.dag.nodes.OutputToHMDNode) LateBlurNode(org.terasology.rendering.dag.nodes.LateBlurNode) ApplyDeferredLightingNode(org.terasology.rendering.dag.nodes.ApplyDeferredLightingNode) BackdropReflectionNode(org.terasology.rendering.dag.nodes.BackdropReflectionNode) DownSamplerForExposureNode(org.terasology.rendering.dag.nodes.DownSamplerForExposureNode) HazeNode(org.terasology.rendering.dag.nodes.HazeNode) RefractiveReflectiveBlocksNode(org.terasology.rendering.dag.nodes.RefractiveReflectiveBlocksNode) SimpleBlendMaterialsNode(org.terasology.rendering.dag.nodes.SimpleBlendMaterialsNode) OutputToScreenNode(org.terasology.rendering.dag.nodes.OutputToScreenNode) BackdropNode(org.terasology.rendering.dag.nodes.BackdropNode) OverlaysNode(org.terasology.rendering.dag.nodes.OverlaysNode) ToneMappingNode(org.terasology.rendering.dag.nodes.ToneMappingNode)

Example 10 with FBO

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 + "'");
    }
}
Also used : SwappableFBO(org.terasology.rendering.opengl.SwappableFBO) FBO(org.terasology.rendering.opengl.FBO) SimpleUri(org.terasology.engine.SimpleUri)

Aggregations

FBO (org.terasology.rendering.opengl.FBO)10 SwappableFBO (org.terasology.rendering.opengl.SwappableFBO)7 SimpleUri (org.terasology.engine.SimpleUri)6 FBOConfig (org.terasology.rendering.opengl.FBOConfig)5 Node (org.terasology.rendering.dag.Node)3 AlphaRejectBlocksNode (org.terasology.rendering.dag.nodes.AlphaRejectBlocksNode)3 AmbientOcclusionNode (org.terasology.rendering.dag.nodes.AmbientOcclusionNode)3 ApplyDeferredLightingNode (org.terasology.rendering.dag.nodes.ApplyDeferredLightingNode)3 BackdropNode (org.terasology.rendering.dag.nodes.BackdropNode)3 BackdropReflectionNode (org.terasology.rendering.dag.nodes.BackdropReflectionNode)3 BloomBlurNode (org.terasology.rendering.dag.nodes.BloomBlurNode)3 BlurredAmbientOcclusionNode (org.terasology.rendering.dag.nodes.BlurredAmbientOcclusionNode)3 BufferClearingNode (org.terasology.rendering.dag.nodes.BufferClearingNode)3 DeferredMainLightNode (org.terasology.rendering.dag.nodes.DeferredMainLightNode)3 DeferredPointLightsNode (org.terasology.rendering.dag.nodes.DeferredPointLightsNode)3 DownSamplerForExposureNode (org.terasology.rendering.dag.nodes.DownSamplerForExposureNode)3 FinalPostProcessingNode (org.terasology.rendering.dag.nodes.FinalPostProcessingNode)3 HazeNode (org.terasology.rendering.dag.nodes.HazeNode)3 HighPassNode (org.terasology.rendering.dag.nodes.HighPassNode)3 InitialPostProcessingNode (org.terasology.rendering.dag.nodes.InitialPostProcessingNode)3