Permalink
Browse files

Adds various rendering related additions, fixes and tweaks. Also adds…

… TeraEd to be a part of the Terasology distribution by default.

- Tweaks sky shader and adds inscattering (colored haze/fog) effect to the terrain
- Adds first version of light shafts (currently disabled)
- Increases water vertex animation complexity a bit
- Replaces water normal map
- Adds various new properties to be used in combination with TeraEd
- Cleans up various other things
  • Loading branch information...
begla committed Feb 6, 2013
1 parent 8dfe079 commit 67a1a0a0c2ceb09987e39711fa311e027c24aba4
Showing with 592 additions and 216 deletions.
  1. +13 −1 build.gradle
  2. +28 −0 launchScripts/LauncherTeraEd.xml
  3. BIN launchScripts/TeraEd.exe
  4. +15 −2 src/{editor → main}/java/org/terasology/editor/TeraEd.java
  5. +1 −1 src/main/java/org/terasology/{ → editor}/properties/IPropertyProvider.java
  6. +1 −1 src/main/java/org/terasology/{ → editor}/properties/Property.java
  7. +6 −1 src/{editor/java/org/terasology → main/java/org/terasology/editor}/properties/SceneProperties.java
  8. +2 −15 src/{editor/java/org/terasology → main/java/org/terasology/editor}/ui/MainWindow.java
  9. +3 −4 src/{editor/java/org/terasology → main/java/org/terasology/editor}/ui/PropertyPanel.java
  10. +2 −2 src/{editor/java/org/terasology → main/java/org/terasology/editor}/ui/PropertySlider.java
  11. +1 −6 src/{editor/java/org/terasology → main/java/org/terasology/editor}/ui/ViewPort.java
  12. +8 −0 src/main/java/org/terasology/logic/manager/Config.java
  13. +56 −23 src/main/java/org/terasology/logic/manager/PostProcessingRenderer.java
  14. +1 −0 src/main/java/org/terasology/logic/manager/ShaderManager.java
  15. +65 −8 src/main/java/org/terasology/protobuf/Configuration.java
  16. +2 −0 src/main/java/org/terasology/rendering/assets/Shader.java
  17. +4 −0 src/main/java/org/terasology/rendering/cameras/Camera.java
  18. +3 −0 src/main/java/org/terasology/rendering/gui/windows/UIMenuConfigVideo.java
  19. +2 −2 src/main/java/org/terasology/rendering/shader/ShaderParametersBase.java
  20. +30 −2 src/main/java/org/terasology/rendering/shader/ShaderParametersChunk.java
  21. +1 −3 src/main/java/org/terasology/rendering/shader/ShaderParametersHdr.java
  22. +85 −0 src/main/java/org/terasology/rendering/shader/ShaderParametersLightShaft.java
  23. +18 −21 src/main/java/org/terasology/rendering/shader/ShaderParametersPost.java
  24. +1 −1 src/main/java/org/terasology/rendering/shader/ShaderParametersPrePost.java
  25. +1 −3 src/main/java/org/terasology/rendering/shader/ShaderParametersSSAO.java
  26. +41 −8 src/main/java/org/terasology/rendering/shader/ShaderParametersSky.java
  27. +17 −47 src/main/java/org/terasology/rendering/world/Skysphere.java
  28. +1 −0 src/main/protobuf/Config2.proto
  29. +18 −3 src/main/resources/assets/shaders/chunk_frag.glsl
  30. +12 −2 src/main/resources/assets/shaders/chunk_vert.glsl
  31. +54 −0 src/main/resources/assets/shaders/lightshaft_frag.glsl
  32. +29 −0 src/main/resources/assets/shaders/lightshaft_vert.glsl
  33. +11 −3 src/main/resources/assets/shaders/post_frag.glsl
  34. +18 −39 src/main/resources/assets/shaders/sky_frag.glsl
  35. +18 −17 src/main/resources/assets/shaders/sky_vert.glsl
  36. BIN src/main/resources/assets/textures/water_normal.png
  37. +24 −1 src/main/resources/org/terasology/include/globalFunctionsFragIncl.glsl
View
@@ -30,6 +30,7 @@ ext {
destDirApplication = 'distributions/application'
destDirMainOutput = 'mainOutput'
destDirMods = "distributions/$subDirMods"
+ mainClassNameEditor = 'org.terasology.editor.TeraEd'
mainClassName = 'org.terasology.game.Terasology'
jarFileName = 'Terasology.jar'
env = System.getenv() // read environment variables, including variables passed by jenking continuous integration server
@@ -242,7 +243,17 @@ task run(type:JavaExec) {
main = mainClassName
classpath "$buildDir/$destDirMainOutput"
classpath configurations.runtime
- // TODO jvmArgs needed?
+}
+
+task runTeraEd(type:JavaExec) {
+ description = "Run 'TeraEd'"
+
+ dependsOn extractNatives
+ dependsOn assembleMainOutput
+ dependsOn modClasses
+ main = mainClassNameEditor
+ classpath "$buildDir/$destDirMainOutput"
+ classpath configurations.runtime
}
task deleteSavedWorldsSubfolders(type: Delete) {
@@ -331,6 +342,7 @@ task distApplication(type:Sync) {
from jar
from('launchScripts') {
exclude('Launcher.xml')
+ exclude('LauncherTeraEd.xml')
}
into(subDirLibs) {
from configurations.runtime
@@ -0,0 +1,28 @@
+<launch4jConfig>
+ <dontWrapJar>true</dontWrapJar>
+ <headerType>gui</headerType>
+ <jar>.\Terasology.jar</jar>
+ <outfile>C:\Users\bg\Desktop\TeraEd.exe</outfile>
+ <errTitle></errTitle>
+ <cmdLine></cmdLine>
+ <chdir></chdir>
+ <priority>normal</priority>
+ <downloadUrl>http://java.com/download</downloadUrl>
+ <supportUrl></supportUrl>
+ <customProcName>false</customProcName>
+ <stayAlive>false</stayAlive>
+ <manifest></manifest>
+ <icon></icon>
+ <classPath>
+ <mainClass>org.terasology.editor.TeraEd</mainClass>
+ <cp>Terasology.jar</cp>
+ </classPath>
+ <jre>
+ <path></path>
+ <minVersion>1.6.0</minVersion>
+ <maxVersion></maxVersion>
+ <jdkPreference>preferJre</jdkPreference>
+ <initialHeapSize>128</initialHeapSize>
+ <maxHeapSize>1024</maxHeapSize>
+ </jre>
+</launch4jConfig>
View
Binary file not shown.
@@ -21,8 +21,8 @@
import org.terasology.game.TerasologyEngine;
import org.terasology.game.modes.StateMainMenu;
import org.terasology.logic.manager.PathManager;
-import org.terasology.properties.SceneProperties;
-import org.terasology.ui.MainWindow;
+import org.terasology.editor.properties.SceneProperties;
+import org.terasology.editor.ui.MainWindow;
import javax.swing.*;
@@ -41,6 +41,19 @@
private static final SceneProperties sceneProperties = new SceneProperties();
public static void main(String[] args) {
+ JPopupMenu.setDefaultLightWeightPopupEnabled(false);
+
+ try {
+ for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
+ if ("Nimbus".equals(info.getName())) {
+ UIManager.setLookAndFeel(info.getClassName());
+ break;
+ }
+ }
+ } catch (Exception e) {
+ // If Nimbus is not available, you can set the GUI to another look and feel.
+ }
+
engine = new TerasologyEngine();
mainWindow = new MainWindow();
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.terasology.properties;
+package org.terasology.editor.properties;
import java.util.List;
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.terasology.properties;
+package org.terasology.editor.properties;
import java.text.DecimalFormat;
@@ -13,9 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.terasology.properties;
+package org.terasology.editor.properties;
import org.terasology.game.CoreRegistry;
+import org.terasology.logic.manager.PostProcessingRenderer;
import org.terasology.rendering.world.Skysphere;
import org.terasology.rendering.world.WorldRenderer;
@@ -32,5 +33,9 @@ public void addPropertiesToList(List<Property> properties) {
if (skysphere != null) {
skysphere.addPropertiesToList(properties);
}
+ PostProcessingRenderer postRenderer = PostProcessingRenderer.getInstance();
+ if (postRenderer != null) {
+ postRenderer.addPropertiesToList(properties);
+ }
}
}
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.terasology.ui;
+package org.terasology.editor.ui;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -69,19 +69,6 @@ public ViewPort getViewPort() {
}
public MainWindow() {
- JPopupMenu.setDefaultLightWeightPopupEnabled(false);
-
- try {
- for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
- if ("Nimbus".equals(info.getName())) {
- UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- } catch (Exception e) {
- // If Nimbus is not available, you can set the GUI to another look and feel.
- }
-
this.addWindowListener(this);
viewPort = new ViewPort();
@@ -106,7 +93,7 @@ public MainWindow() {
getContentPane().add(verticalSplitPane, BorderLayout.CENTER);
setTitle("TeraEd - Terasology" + " | " + "Pre Alpha");
- setSize(new Dimension(1280, 720));
+ setSize(new Dimension(1280+350, 720));
mainMenuBar = new JMenuBar();
setJMenuBar(mainMenuBar);
@@ -13,11 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.terasology.ui;
+package org.terasology.editor.ui;
-import org.terasology.editor.TeraEd;
-import org.terasology.properties.IPropertyProvider;
-import org.terasology.properties.Property;
+import org.terasology.editor.properties.IPropertyProvider;
+import org.terasology.editor.properties.Property;
import javax.swing.*;
import javax.swing.border.TitledBorder;
@@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.terasology.ui;
+package org.terasology.editor.ui;
-import org.terasology.properties.Property;
+import org.terasology.editor.properties.Property;
import javax.swing.*;
import javax.swing.border.TitledBorder;
@@ -13,17 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.terasology.ui;
+package org.terasology.editor.ui;
-import org.lwjgl.input.Mouse;
-import org.lwjgl.util.Display;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.swing.*;
import java.awt.*;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
/**
* TeraEd main class.
@@ -446,6 +446,14 @@ public boolean isSSAO() {
return _setting.getSystemBuilder().getSsao();
}
+ public void setLightShafts(boolean lightShafts) {
+ _setting.getSystemBuilder().setLightShafts(lightShafts);
+ }
+
+ public boolean isLightShafts() {
+ return _setting.getSystemBuilder().getLightShafts();
+ }
+
public void setOutline(boolean outline) {
_setting.getSystemBuilder().setOutline(outline);
}
@@ -18,18 +18,19 @@
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.util.HashMap;
+import java.util.List;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.terasology.game.CoreRegistry;
import org.terasology.math.TeraMath;
+import org.terasology.editor.properties.IPropertyProvider;
+import org.terasology.editor.properties.Property;
import org.terasology.rendering.shader.ShaderProgram;
import org.terasology.rendering.world.WorldRenderer;
-import javax.swing.*;
-
import static org.lwjgl.opengl.GL11.*;
/**
@@ -38,14 +39,14 @@
*
* @author Benjamin Glatzel <benjamin.glatzel@me.com>
*/
-public class PostProcessingRenderer {
+public class PostProcessingRenderer implements IPropertyProvider {
- public static final float DEFAULT_EXPOSURE = 2.5f;
- public static final float MAX_EXPOSURE = 6.0f;
- public static final float MAX_EXPOSURE_NIGHT = 1.0f;
- public static final float MIN_EXPOSURE = 0.5f;
- public static final float TARGET_LUMINANCE = 1.0f;
- public static final float ADJUSTMENT_SPEED = 0.025f;
+ private Property hdrExposureDefault = new Property("hdrExposureDefault", 2.5f, 0.0f, 10.0f);
+ private Property hdrMaxExposure = new Property("hdrMaxExposure", 4.0f, 0.0f, 10.0f);
+ private Property hdrMaxExposureNight = new Property("hdrMaxExposureNight", 1.0f, 0.0f, 10.0f);
+ private Property hdrMinExposure = new Property("hdrMinExposure", 0.5f, 0.0f, 10.0f);
+ private Property hdrTargetLuminance = new Property("hdrTargetLuminance", 1.0f, 0.0f, 4.0f);
+ private Property hdrExposureAdjustmentSpeed = new Property("hdrExposureAdjustmentSpeed", 0.025f, 0.0f, 0.1f);
private static final Logger logger = LoggerFactory.getLogger(PostProcessingRenderer.class);
@@ -151,14 +152,16 @@ private void createOrUpdateFullscreenFbos() {
createFBO("ssaoBlurred0", halfWidth, halfHeight, false, false, false);
createFBO("ssaoBlurred1", halfWidth, halfHeight, false, false, false);
+ createFBO("lightShafts", halfWidth, halfHeight, false, false, false);
+
createFBO("sceneReflected", halfWidth, halfHeight, true, true, false);
- createFBO("sceneHighPass", halfHalfQuarterWidth, halfHalfQuarterHeight, false, false, false);
- createFBO("sceneBloom0", halfHalfQuarterWidth, halfHalfQuarterHeight, false, false, false);
- createFBO("sceneBloom1", halfHalfQuarterWidth, halfHalfQuarterHeight, false, false, false);
+ createFBO("sceneHighPass", halfQuarterWidth, halfQuarterHeight, false, false, false);
+ createFBO("sceneBloom0", halfQuarterWidth, halfQuarterHeight, false, false, false);
+ createFBO("sceneBloom1", halfQuarterWidth, halfQuarterHeight, false, false, false);
- createFBO("sceneBlur0", quarterWidth, quarterHeight, false, false, false);
- createFBO("sceneBlur1", quarterWidth, quarterHeight, false, false, false);
+ createFBO("sceneBlur0", halfWidth, halfHeight, false, false, false);
+ createFBO("sceneBlur1", halfWidth, halfHeight, false, false, false);
}
public void deleteFBO(String title) {
@@ -299,31 +302,31 @@ private void updateExposure() {
_sceneLuminance = 0.2126f * pixels.get(2) / 255.f + 0.7152f * pixels.get(1) / 255.f + 0.0722f * pixels.get(0) / 255.f;
- float targetExposure = MAX_EXPOSURE;
+ float targetExposure = (Float) hdrMaxExposure.getValue();
if (_sceneLuminance > 0) {
- targetExposure = TARGET_LUMINANCE / _sceneLuminance;
+ targetExposure = (Float) hdrTargetLuminance.getValue() / _sceneLuminance;
}
- float maxExposure = MAX_EXPOSURE;
+ float maxExposure = (Float) hdrMaxExposure.getValue();
if (CoreRegistry.get(WorldRenderer.class).getSkysphere().getDaylight() == 0.0) {
- maxExposure = MAX_EXPOSURE_NIGHT;
+ maxExposure = (Float) hdrMaxExposureNight.getValue();
}
if (targetExposure > maxExposure) {
targetExposure = maxExposure;
- } else if (targetExposure < MIN_EXPOSURE) {
- targetExposure = MIN_EXPOSURE;
+ } else if (targetExposure < (Float) hdrMinExposure.getValue()) {
+ targetExposure = (Float) hdrMinExposure.getValue();
}
- _exposure = (float) TeraMath.lerp(_exposure, targetExposure, ADJUSTMENT_SPEED);
+ _exposure = (float) TeraMath.lerp(_exposure, targetExposure, (Float) hdrExposureAdjustmentSpeed.getValue());
} else {
if (CoreRegistry.get(WorldRenderer.class).getSkysphere().getDaylight() == 0.0) {
- _exposure = MAX_EXPOSURE_NIGHT;
+ _exposure = (Float) hdrMaxExposureNight.getValue();
} else {
- _exposure = DEFAULT_EXPOSURE;
+ _exposure = (Float) hdrExposureDefault.getValue();
}
}
}
@@ -382,6 +385,10 @@ public void renderScene() {
generateTonemappedScene();
generateHighPass();
+ if (Config.getInstance().isLightShafts()) {
+ generateLightShafts();
+ }
+
for (int i = 0; i < 2; i++) {
if (Config.getInstance().isBloom()) {
generateBloom(i);
@@ -412,6 +419,21 @@ private void generateTonemappedScene() {
PostProcessingRenderer.getInstance().getFBO("sceneTonemapped").unbind();
}
+ private void generateLightShafts() {
+ ShaderManager.getInstance().enableShader("lightshaft");
+
+ FBO lightshaft = PostProcessingRenderer.getInstance().getFBO("lightShafts");
+ lightshaft.bind();
+
+ glViewport(0, 0, lightshaft._width, lightshaft._height);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ renderFullQuad();
+
+ PostProcessingRenderer.getInstance().getFBO("lightShafts").unbind();
+ glViewport(0, 0, Display.getWidth(), Display.getHeight());
+ }
+
private void generateSSAO() {
ShaderManager.getInstance().enableShader("ssao");
@@ -640,4 +662,15 @@ public float getExposure() {
public FBO getFBO(String title) {
return _FBOs.get(title);
}
+
+
+ @Override
+ public void addPropertiesToList(List<Property> properties) {
+ properties.add(hdrMaxExposure);
+ properties.add(hdrExposureAdjustmentSpeed);
+ properties.add(hdrExposureDefault);
+ properties.add(hdrMaxExposureNight);
+ properties.add(hdrMinExposure);
+ properties.add(hdrTargetLuminance);
+ }
}
@@ -72,6 +72,7 @@ private void initShaders() {
createAndStoreShaderProgram("post", new ShaderParametersPost());
createAndStoreShaderProgram("ssao", new ShaderParametersSSAO());
+ createAndStoreShaderProgram("lightshaft", new ShaderParametersLightShaft());
createAndStoreShaderProgram("sobel", new ShaderParametersSobel());
createAndStoreShaderProgram("prePost", new ShaderParametersPrePost());
createAndStoreShaderProgram("highp", new ShaderParametersDefault());
Oops, something went wrong.

0 comments on commit 67a1a0a

Please sign in to comment.