From eace9c38298f8fef81265c6370ebe617b2673fd7 Mon Sep 17 00:00:00 2001 From: Sebastian Hartte Date: Sat, 27 Sep 2014 01:17:53 +0200 Subject: [PATCH] Added a rendering setting to scale the FBOs to effectively reduce (or increase) the resolution of the game scene without affecting the resolution of the UI. I (arbitrarily) set the range from 25% to 200%. Increasing the size should essentially be like supersampling. Also added a slider to the video settings dialog to control this. --- .../terasology/config/RenderingConfig.java | 9 +++++++ .../videoSettings/VideoSettingsScreen.java | 25 +++++++++++++++++++ .../opengl/DefaultRenderingProcess.java | 8 +++++- .../assets/ui/menu/videoMenuScreen.ui | 8 +++--- 4 files changed, 45 insertions(+), 5 deletions(-) diff --git a/engine/src/main/java/org/terasology/config/RenderingConfig.java b/engine/src/main/java/org/terasology/config/RenderingConfig.java index 2c8ea2f6e45..05dc656c803 100644 --- a/engine/src/main/java/org/terasology/config/RenderingConfig.java +++ b/engine/src/main/java/org/terasology/config/RenderingConfig.java @@ -69,6 +69,7 @@ public class RenderingConfig { private boolean inscattering = true; private boolean localReflections; private boolean vSync; + private int fboScale = 100; private PerspectiveCameraSettings cameraSettings = new PerspectiveCameraSettings(CameraSetting.NORMAL); private RenderingDebugConfig debug = new RenderingDebugConfig(); @@ -411,6 +412,14 @@ public void setFrameLimit(int frameLimit) { this.frameLimit = frameLimit; } + public int getFboScale() { + return fboScale; + } + + public void setFboScale(int fboScale) { + this.fboScale = fboScale; + } + @Override public String toString() { return Config.createGson().toJsonTree(this).toString(); diff --git a/engine/src/main/java/org/terasology/rendering/nui/layers/mainMenu/videoSettings/VideoSettingsScreen.java b/engine/src/main/java/org/terasology/rendering/nui/layers/mainMenu/videoSettings/VideoSettingsScreen.java index 2802ee4e73a..a8a3f16296f 100644 --- a/engine/src/main/java/org/terasology/rendering/nui/layers/mainMenu/videoSettings/VideoSettingsScreen.java +++ b/engine/src/main/java/org/terasology/rendering/nui/layers/mainMenu/videoSettings/VideoSettingsScreen.java @@ -155,6 +155,31 @@ public void set(Float value) { }); } + final UISlider fboScaleSlider = find("fboScale", UISlider.class); + if (fboScaleSlider != null) { + fboScaleSlider.setIncrement(5.0f); + fboScaleSlider.setPrecision(0); + fboScaleSlider.setMinimum(25); + fboScaleSlider.setRange(200); + fboScaleSlider.setLabelFunction(new Function() { + @Override + public String apply(Float input) { + return String.valueOf(input.intValue()) + "%"; + } + }); + fboScaleSlider.bindValue(new Binding() { + @Override + public Float get() { + return (float) config.getRendering().getFboScale(); + } + + @Override + public void set(Float value) { + config.getRendering().setFboScale(value.intValue()); + } + }); + } + UIDropdown cameraSetting = find("camera", UIDropdown.class); if (cameraSetting != null) { cameraSetting.setOptions(Arrays.asList(CameraSetting.values())); diff --git a/engine/src/main/java/org/terasology/rendering/opengl/DefaultRenderingProcess.java b/engine/src/main/java/org/terasology/rendering/opengl/DefaultRenderingProcess.java index 4640106d41a..f6e526696e9 100644 --- a/engine/src/main/java/org/terasology/rendering/opengl/DefaultRenderingProcess.java +++ b/engine/src/main/java/org/terasology/rendering/opengl/DefaultRenderingProcess.java @@ -30,6 +30,7 @@ import org.slf4j.LoggerFactory; import org.terasology.asset.Assets; import org.terasology.config.Config; +import org.terasology.config.RenderingConfig; import org.terasology.editor.EditorRange; import org.terasology.monitoring.PerformanceMonitor; import org.terasology.registry.CoreRegistry; @@ -263,7 +264,12 @@ private void createOrUpdateFullscreenFbos() { rtFullHeight = org.lwjgl.opengl.Display.getHeight(); } - if (CoreRegistry.get(Config.class).getRendering().isOculusVrSupport()) { + RenderingConfig renderingConfig = CoreRegistry.get(Config.class).getRendering(); + + rtFullWidth *= renderingConfig.getFboScale() / 100f; + rtFullHeight *= renderingConfig.getFboScale() / 100f; + + if (renderingConfig.isOculusVrSupport()) { if (overwriteRtWidth == 0) { rtFullWidth *= OculusVrHelper.getScaleFactor(); } diff --git a/engine/src/main/resources/assets/ui/menu/videoMenuScreen.ui b/engine/src/main/resources/assets/ui/menu/videoMenuScreen.ui index 6fdb2d2d860..0707f614875 100644 --- a/engine/src/main/resources/assets/ui/menu/videoMenuScreen.ui +++ b/engine/src/main/resources/assets/ui/menu/videoMenuScreen.ui @@ -213,12 +213,12 @@ "id": "frameLimit" }, { - "type": "UISpace", - "size": [1, 13] + "type": "UILabel", + "text": "Render Quality: " }, { - "type": "UISpace", - "size": [1, 13] + "type": "UISlider", + "id": "fboScale" }, { "type": "UISpace",