From 62869dc92f760a8d58f01a0afd2e81b6615cf87e Mon Sep 17 00:00:00 2001 From: abhishek1995 Date: Thu, 6 Mar 2014 20:51:09 +0530 Subject: [PATCH 01/17] Update CMakeLists.txt This commit includes checking whether ../data directory (from build directory) and ../../stk-assets directory (from build directory) exists or not. If they don't exist, then it gives error message for the corresponding directory. I have included the code for this on line 320. --- CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index eb544bd66..d73cb16ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -312,6 +312,18 @@ install(FILES ${PROJECT_BINARY_DIR}/supertuxkart.desktop DESTINATION share/appli install(FILES data/supertuxkart_32.png data/supertuxkart_128.png DESTINATION share/pixmaps) install(FILES data/supertuxkart.appdata DESTINATION share/appdata) +# ==== Checking if data folder exists ==== +if(NOT IS_DIRECTORY data) + message( FATAL_ERROR "${CMAKE_CURRENT_SOURCE_DIR}/data folder doesn't exist" ) +endif() + +# ==== Checking if stk-assets folder exists ==== +if(NOT IS_DIRECTORY ../stk-assets) + set (CUR_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + get_filename_component(PARENT_DIR ${CUR_DIR} PATH) + message( FATAL_ERROR "${PARENT_DIR}/stk-assets folder doesn't exist" ) +endif() + set(PREFIX ${CMAKE_INSTALL_PREFIX}) configure_file(data/supertuxkart_desktop.template supertuxkart.desktop) add_dependencies(supertuxkart supertuxkart.desktop) From 96fe29eb8403b7b59fcc04622f9bbf29eb5f37eb Mon Sep 17 00:00:00 2001 From: abhishek1995 Date: Thu, 6 Mar 2014 21:13:53 +0530 Subject: [PATCH 02/17] Update CMakeLists.txt --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d73cb16ed..83f5827a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -313,12 +313,12 @@ install(FILES data/supertuxkart_32.png data/supertuxkart_128.png DESTINATION sha install(FILES data/supertuxkart.appdata DESTINATION share/appdata) # ==== Checking if data folder exists ==== -if(NOT IS_DIRECTORY data) +if(NOT IS_DIRECTORY ../data) message( FATAL_ERROR "${CMAKE_CURRENT_SOURCE_DIR}/data folder doesn't exist" ) endif() # ==== Checking if stk-assets folder exists ==== -if(NOT IS_DIRECTORY ../stk-assets) +if(NOT IS_DIRECTORY ../../stk-assets) set (CUR_DIR ${CMAKE_CURRENT_SOURCE_DIR}) get_filename_component(PARENT_DIR ${CUR_DIR} PATH) message( FATAL_ERROR "${PARENT_DIR}/stk-assets folder doesn't exist" ) From 84a1e32ade3b25f76a2cdb7e62b85e4a9dfcfed9 Mon Sep 17 00:00:00 2001 From: hiker Date: Thu, 24 Apr 2014 14:22:38 +1000 Subject: [PATCH 03/17] Let cmake test if stk-assets exists in the expected place. If not, cmake is aborted with an error message. The option -DCHECK_ASSETS=off option can be used to disable this test. The latter is also used for travis. --- .travis.yml | 2 +- CMakeLists.txt | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index aa3607483..86a203378 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ script: # Build commands - mkdir build - cd build - - cmake .. -DCMAKE_BUILD_TYPE=Debug + - cmake .. -DCMAKE_BUILD_TYPE=Debug -DCHECK_ASSETS=off - make VERBOSE=1 -j 4 notifications: irc: diff --git a/CMakeLists.txt b/CMakeLists.txt index 685d8ad87..3d94deb40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,8 @@ endif() option(USE_WIIUSE "Support for wiimote input devices" ON) option(USE_FRIBIDI "Support for right-to-left languages" ON) +option(CHECK_ASSETS "Check if assets are installed in ../stk-assets" ON) + if(UNIX) option(USE_CPP2011 "Activate C++ 2011 mode (GCC only)" OFF) endif() @@ -319,10 +321,13 @@ if(NOT IS_DIRECTORY ../data) endif() # ==== Checking if stk-assets folder exists ==== -if(NOT IS_DIRECTORY ../../stk-assets) - set (CUR_DIR ${CMAKE_CURRENT_SOURCE_DIR}) - get_filename_component(PARENT_DIR ${CUR_DIR} PATH) - message( FATAL_ERROR "${PARENT_DIR}/stk-assets folder doesn't exist" ) +if(CHECK_ASSETS) + if(NOT IS_DIRECTORY ../../stk-assets) + set (CUR_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + get_filename_component(PARENT_DIR ${CUR_DIR} PATH) + message( FATAL_ERROR "${PARENT_DIR}/stk-assets folder doesn't exist. " + "Please download the stk-assets, or disable this test with -DCHECK_ASSETS=off." ) + endif() endif() set(PREFIX ${CMAKE_INSTALL_PREFIX}) From ef07b2520291887b6e73760bf82cd8520e6a505b Mon Sep 17 00:00:00 2001 From: vlj Date: Thu, 24 Apr 2014 17:47:17 +0200 Subject: [PATCH 04/17] Make possible to tweak exposure/lwhite in adm --- data/shaders/tonemap.frag | 5 +++-- src/graphics/irr_driver.hpp | 22 +++++++++++++++++++++ src/graphics/post_processing.cpp | 2 +- src/graphics/shaders.cpp | 8 +++++++- src/graphics/shaders.hpp | 4 ++-- src/states_screens/dialogs/debug_slider.cpp | 5 +++++ 6 files changed, 40 insertions(+), 6 deletions(-) diff --git a/data/shaders/tonemap.frag b/data/shaders/tonemap.frag index 9e23b9bc5..186c69460 100644 --- a/data/shaders/tonemap.frag +++ b/data/shaders/tonemap.frag @@ -2,6 +2,8 @@ uniform sampler2D tex; uniform sampler2D logluminancetex; +uniform float exposure = .09; +uniform float Lwhite = 1.; in vec2 uv; out vec4 FragColor; @@ -9,8 +11,7 @@ out vec4 FragColor; vec3 getCIEYxy(vec3 rgbColor); vec3 getRGBFromCIEXxy(vec3 YxyColor); -float exposure = .09; -float Lwhite = 1.; + float delta = .0001; float saturation = 1.; diff --git a/src/graphics/irr_driver.hpp b/src/graphics/irr_driver.hpp index 60bb9839b..3d1d995ce 100644 --- a/src/graphics/irr_driver.hpp +++ b/src/graphics/irr_driver.hpp @@ -99,6 +99,8 @@ private: Shaders *m_shaders; /** Wind. */ Wind *m_wind; + float m_exposure; + float m_lwhite; /** RTTs. */ RTT *m_rtts; /** Shadow importance. */ @@ -160,6 +162,26 @@ public: return 120; } + float getExposure() const + { + return m_exposure; + } + + void setExposure(float v) + { + m_exposure = v; + } + + float getLwhite() const + { + return m_lwhite; + } + + void setLwhite(float v) + { + m_lwhite = v; + } + private: std::vector m_modes; diff --git a/src/graphics/post_processing.cpp b/src/graphics/post_processing.cpp index 70ff32bc7..373929418 100644 --- a/src/graphics/post_processing.cpp +++ b/src/graphics/post_processing.cpp @@ -530,7 +530,7 @@ static void toneMap(GLuint fbo, GLuint rtt) glBindVertexArray(FullScreenShader::ToneMapShader::vao); setTexture(0, rtt, GL_NEAREST, GL_NEAREST); setTexture(1, irr_driver->getRenderTargetTexture(RTT_LOG_LUMINANCE), GL_NEAREST, GL_NEAREST_MIPMAP_NEAREST); - FullScreenShader::ToneMapShader::setUniforms(0, 1); + FullScreenShader::ToneMapShader::setUniforms(irr_driver->getExposure(), irr_driver->getLwhite(), 0, 1); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); } diff --git a/src/graphics/shaders.cpp b/src/graphics/shaders.cpp index 0494c6adb..0c5a8ca3c 100644 --- a/src/graphics/shaders.cpp +++ b/src/graphics/shaders.cpp @@ -2069,6 +2069,8 @@ namespace FullScreenShader GLuint ToneMapShader::Program; GLuint ToneMapShader::uniform_tex; GLuint ToneMapShader::uniform_logluminancetex; + GLuint ToneMapShader::uniform_exposure; + GLuint ToneMapShader::uniform_lwhite; GLuint ToneMapShader::vao; void ToneMapShader::init() @@ -2080,13 +2082,17 @@ namespace FullScreenShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/tonemap.frag").c_str()); uniform_tex = glGetUniformLocation(Program, "tex"); uniform_logluminancetex = glGetUniformLocation(Program, "logluminancetex"); + uniform_exposure = glGetUniformLocation(Program, "exposure"); + uniform_lwhite = glGetUniformLocation(Program, "Lwhite"); vao = createVAO(Program); } - void ToneMapShader::setUniforms(unsigned TU_tex, unsigned TU_loglum) + void ToneMapShader::setUniforms(float exposure, float Lwhite, unsigned TU_tex, unsigned TU_loglum) { glUniform1i(uniform_tex, TU_tex); glUniform1i(uniform_logluminancetex, TU_loglum); + glUniform1f(uniform_exposure, exposure); + glUniform1f(uniform_lwhite, Lwhite); } GLuint DepthOfFieldShader::Program; diff --git a/src/graphics/shaders.hpp b/src/graphics/shaders.hpp index bf5e2af1e..8a6b62ccf 100644 --- a/src/graphics/shaders.hpp +++ b/src/graphics/shaders.hpp @@ -524,11 +524,11 @@ class ToneMapShader { public: static GLuint Program; - static GLuint uniform_tex, uniform_logluminancetex; + static GLuint uniform_tex, uniform_logluminancetex, uniform_exposure, uniform_lwhite; static GLuint vao; static void init(); - static void setUniforms(unsigned TU_tex, unsigned TU_logluminance); + static void setUniforms(float exposure, float Lwhite, unsigned TU_tex, unsigned TU_logluminance); }; class DepthOfFieldShader diff --git a/src/states_screens/dialogs/debug_slider.cpp b/src/states_screens/dialogs/debug_slider.cpp index 4c5b02c57..f3ce2462c 100644 --- a/src/states_screens/dialogs/debug_slider.cpp +++ b/src/states_screens/dialogs/debug_slider.cpp @@ -26,6 +26,7 @@ #include "modes/world.hpp" #include "states_screens/state_manager.hpp" #include "utils/translation.hpp" +#include "graphics/irr_driver.hpp" using namespace GUIEngine; @@ -73,6 +74,10 @@ GUIEngine::EventPropagation DebugSliderDialog::processEvent(const std::string& e { int value = getWidget("value_slider")->getValue(); Log::info("DebugSlider", "Value for <%s> : %i", m_id.c_str(), value); + if (m_id == "lwhite") + irr_driver->setLwhite(value / 10.); + if (m_id == "exposure") + irr_driver->setExposure(value / 100.); return GUIEngine::EVENT_BLOCK; } From 85e720a58faa1e8a7dd6c008d968adcfd3ccdb9c Mon Sep 17 00:00:00 2001 From: vlj Date: Thu, 24 Apr 2014 18:33:05 +0200 Subject: [PATCH 05/17] Shadow: tweak bias to remove acnee --- data/shaders/sunlightshadow.frag | 6 +++--- data/shaders/sunlightshadowdebug.frag | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/data/shaders/sunlightshadow.frag b/data/shaders/sunlightshadow.frag index 64ef8f365..2b316c09a 100644 --- a/data/shaders/sunlightshadow.frag +++ b/data/shaders/sunlightshadow.frag @@ -53,7 +53,7 @@ float getShadowFactor(vec3 pos, float bias, int index) float sum = 0.; for (int i = 0; i < 4; i++) { - sum += texture(shadowtex, vec4(shadowtexcoord + shadowoffset[i] / 2048., float(index), 0.5 * (shadowcoord.z - bias * 0.01) + 0.5)); + sum += texture(shadowtex, vec4(shadowtexcoord + shadowoffset[i] / 2048., float(index), 0.5 * shadowcoord.z + 0.5 + bias)); } return sum / 4.; } @@ -88,8 +88,8 @@ void main() { // } // Shadows - float bias = 0.002 * tan(acos(NdotL)); // According to the slope - bias = clamp(bias, 0.001, 0.014); + float bias = 0.005 * tan(acos(NdotL)); // According to the slope + bias = clamp(bias, 0., 0.01); float factor; if (xpos.z < 5.) factor = getShadowFactor(xpos.xyz, bias, 0); diff --git a/data/shaders/sunlightshadowdebug.frag b/data/shaders/sunlightshadowdebug.frag index 96a4d3cb8..c285c30a3 100644 --- a/data/shaders/sunlightshadowdebug.frag +++ b/data/shaders/sunlightshadowdebug.frag @@ -37,7 +37,7 @@ vec3 getShadowFactor(vec3 pos, float bias) vec2 shadowtexcoord = shadowcoord.xy * 0.5 + 0.5; if (shadowtexcoord.x < 0. || shadowtexcoord.x > 1. || shadowtexcoord.y < 0. || shadowtexcoord.y > 1.) continue; - return cascadeColor[i] * texture(shadowtex, vec4(shadowtexcoord, float(i), 0.5 * (shadowcoord.z + bias * 0.001) + 0.5)); + return cascadeColor[i] * texture(shadowtex, vec4(shadowtexcoord, float(i), 0.5 * shadowcoord.z + 0.5 + bias)); } return vec3(1.); } @@ -61,8 +61,8 @@ void main() { vec3 outcol = NdotL * col; // Shadows - float bias = 0.002 * tan(acos(NdotL)); // According to the slope - bias = clamp(bias, 0.001, 0.014); + float bias = 0.005 * tan(acos(NdotL)); // According to the slope + bias = clamp(bias, 0., 0.01); vec3 factor = getShadowFactor(xpos.xyz, bias); Diff = vec4(factor * NdotL * col, 1.); Spec = vec4(factor * Specular, 1.); From 84ddd7119e00aaac1ddbbad80de6d9d835fa7520 Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Thu, 24 Apr 2014 21:02:24 +0200 Subject: [PATCH 06/17] Use glPolygonOffset to remove shadow acne It's a 2002 trick from M. Kilgard --- data/shaders/sunlightshadow.frag | 2 +- data/shaders/sunlightshadowdebug.frag | 8 +++----- src/graphics/render.cpp | 6 +++--- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/data/shaders/sunlightshadow.frag b/data/shaders/sunlightshadow.frag index 2b316c09a..4dd96f041 100644 --- a/data/shaders/sunlightshadow.frag +++ b/data/shaders/sunlightshadow.frag @@ -53,7 +53,7 @@ float getShadowFactor(vec3 pos, float bias, int index) float sum = 0.; for (int i = 0; i < 4; i++) { - sum += texture(shadowtex, vec4(shadowtexcoord + shadowoffset[i] / 2048., float(index), 0.5 * shadowcoord.z + 0.5 + bias)); + sum += texture(shadowtex, vec4(shadowtexcoord + shadowoffset[i] / 2048., float(index), 0.5 * shadowcoord.z + 0.5)); } return sum / 4.; } diff --git a/data/shaders/sunlightshadowdebug.frag b/data/shaders/sunlightshadowdebug.frag index c285c30a3..b0c39ec8e 100644 --- a/data/shaders/sunlightshadowdebug.frag +++ b/data/shaders/sunlightshadowdebug.frag @@ -22,7 +22,7 @@ out vec4 Spec; vec3 DecodeNormal(vec2 n); vec3 getSpecular(vec3 normal, vec3 eyedir, vec3 lightdir, vec3 color, float roughness); -vec3 getShadowFactor(vec3 pos, float bias) +vec3 getShadowFactor(vec3 pos) { vec3 cascadeColor[] = vec3[]( vec3(1., 0., 0.), @@ -37,7 +37,7 @@ vec3 getShadowFactor(vec3 pos, float bias) vec2 shadowtexcoord = shadowcoord.xy * 0.5 + 0.5; if (shadowtexcoord.x < 0. || shadowtexcoord.x > 1. || shadowtexcoord.y < 0. || shadowtexcoord.y > 1.) continue; - return cascadeColor[i] * texture(shadowtex, vec4(shadowtexcoord, float(i), 0.5 * shadowcoord.z + 0.5 + bias)); + return cascadeColor[i] * texture(shadowtex, vec4(shadowtexcoord, float(i), 0.5 * shadowcoord.z + 0.5)); } return vec3(1.); } @@ -61,9 +61,7 @@ void main() { vec3 outcol = NdotL * col; // Shadows - float bias = 0.005 * tan(acos(NdotL)); // According to the slope - bias = clamp(bias, 0., 0.01); - vec3 factor = getShadowFactor(xpos.xyz, bias); + vec3 factor = getShadowFactor(xpos.xyz); Diff = vec4(factor * NdotL * col, 1.); Spec = vec4(factor * Specular, 1.); return; diff --git a/src/graphics/render.cpp b/src/graphics/render.cpp index 3c78c9d79..4381466a5 100644 --- a/src/graphics/render.cpp +++ b/src/graphics/render.cpp @@ -665,8 +665,8 @@ void IrrDriver::renderShadows(//ShadowImportanceProvider * const sicb, irr_driver->setPhase(SHADOW_PASS); glDisable(GL_BLEND); - glEnable(GL_CULL_FACE); - glCullFace(GL_FRONT); + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(1.5, 0.); glBindFramebuffer(GL_FRAMEBUFFER, m_rtts->getShadowFBO()); glViewport(0, 0, 1024, 1024); glClear(GL_DEPTH_BUFFER_BIT); @@ -674,7 +674,7 @@ void IrrDriver::renderShadows(//ShadowImportanceProvider * const sicb, glBindBufferBase(GL_UNIFORM_BUFFER, 0, SharedObject::ViewProjectionMatrixesUBO); m_scene_manager->drawAll(scene::ESNRP_SOLID); - glCullFace(GL_BACK); + glDisable(GL_POLYGON_OFFSET_FILL); glViewport(0, 0, UserConfigParams::m_width, UserConfigParams::m_height); From 7239154a3a72c168c209979d37375dd8aec99d98 Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Thu, 24 Apr 2014 21:23:32 +0200 Subject: [PATCH 07/17] NormalMap should cast shadows too --- src/graphics/stkmeshscenenode.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/graphics/stkmeshscenenode.cpp b/src/graphics/stkmeshscenenode.cpp index f5fe882ad..04c1209d0 100644 --- a/src/graphics/stkmeshscenenode.cpp +++ b/src/graphics/stkmeshscenenode.cpp @@ -462,10 +462,12 @@ void STKMeshSceneNode::render() glDisable(GL_CULL_FACE); GLMesh* mesh; - if (!GeometricMesh[FPSM_DEFAULT].empty()) + if (!GeometricMesh[FPSM_DEFAULT].empty() || !GeometricMesh[FPSM_NORMAL_MAP].empty()) glUseProgram(MeshShader::ShadowShader::Program); for_in(mesh, GeometricMesh[FPSM_DEFAULT]) drawShadow(*mesh, AbsoluteTransformation); + for_in(mesh, GeometricMesh[FPSM_NORMAL_MAP]) + drawShadow(*mesh, AbsoluteTransformation); if (!GeometricMesh[FPSM_ALPHA_REF_TEXTURE].empty()) glUseProgram(MeshShader::RefShadowShader::Program); From 5b8b1a8b57bb22178daa2c4b6906632266b9dbd5 Mon Sep 17 00:00:00 2001 From: vlj Date: Fri, 25 Apr 2014 00:29:33 +0200 Subject: [PATCH 08/17] Temporary comment out exposure/lwhite settings --- src/graphics/shaders.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/graphics/shaders.cpp b/src/graphics/shaders.cpp index 0c5a8ca3c..58b06894a 100644 --- a/src/graphics/shaders.cpp +++ b/src/graphics/shaders.cpp @@ -2091,8 +2091,8 @@ namespace FullScreenShader { glUniform1i(uniform_tex, TU_tex); glUniform1i(uniform_logluminancetex, TU_loglum); - glUniform1f(uniform_exposure, exposure); - glUniform1f(uniform_lwhite, Lwhite); +// glUniform1f(uniform_exposure, exposure); +// glUniform1f(uniform_lwhite, Lwhite); } GLuint DepthOfFieldShader::Program; From c5fbd5ff847ed36f12bd7459e00d6fdcdf099ef4 Mon Sep 17 00:00:00 2001 From: vlj Date: Fri, 25 Apr 2014 00:59:02 +0200 Subject: [PATCH 09/17] Reenable ability to change exposure/lwhite. --- src/graphics/shaders.cpp | 4 ++-- src/states_screens/dialogs/debug_slider.cpp | 8 ++++++++ src/tracks/track.cpp | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/graphics/shaders.cpp b/src/graphics/shaders.cpp index 58b06894a..0c5a8ca3c 100644 --- a/src/graphics/shaders.cpp +++ b/src/graphics/shaders.cpp @@ -2091,8 +2091,8 @@ namespace FullScreenShader { glUniform1i(uniform_tex, TU_tex); glUniform1i(uniform_logluminancetex, TU_loglum); -// glUniform1f(uniform_exposure, exposure); -// glUniform1f(uniform_lwhite, Lwhite); + glUniform1f(uniform_exposure, exposure); + glUniform1f(uniform_lwhite, Lwhite); } GLuint DepthOfFieldShader::Program; diff --git a/src/states_screens/dialogs/debug_slider.cpp b/src/states_screens/dialogs/debug_slider.cpp index f3ce2462c..d8b7b9536 100644 --- a/src/states_screens/dialogs/debug_slider.cpp +++ b/src/states_screens/dialogs/debug_slider.cpp @@ -48,6 +48,14 @@ DebugSliderDialog::DebugSliderDialog(std::string id, irr::core::stringw msg) : LabelWidget* message = getWidget("title"); message->setText( msg.c_str(), false ); + + float val; + if (m_id == "lwhite") + val = irr_driver->getLwhite() * 10.; + if (m_id == "exposure") + val = irr_driver->getExposure() * 100.; + + getWidget("value_slider")->setValue(val); } // ------------------------------------------------------------------------------------------------------ diff --git a/src/tracks/track.cpp b/src/tracks/track.cpp index 9e7f1e0a4..cf6068168 100644 --- a/src/tracks/track.cpp +++ b/src/tracks/track.cpp @@ -356,6 +356,8 @@ void Track::cleanup() //----------------------------------------------------------------------------- void Track::loadTrackInfo() { + irr_driver->setLwhite(1.); + irr_driver->setExposure(0.09); // Default values m_use_fog = false; m_fog_max = 1.0f; From 97b6db3fdc1c6ccc2ca0159ea7ab8861088c2332 Mon Sep 17 00:00:00 2001 From: Marianne Gagnon Date: Thu, 24 Apr 2014 19:24:23 -0400 Subject: [PATCH 10/17] Honor the per-track flag to disable god rays --- src/graphics/post_processing.cpp | 3 ++- src/graphics/render.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/graphics/post_processing.cpp b/src/graphics/post_processing.cpp index 373929418..96cc955d0 100644 --- a/src/graphics/post_processing.cpp +++ b/src/graphics/post_processing.cpp @@ -655,7 +655,8 @@ void PostProcessing::render() std::swap(in_fbo, out_fbo); PROFILER_PUSH_CPU_MARKER("- Godrays", 0xFF, 0x00, 0x00); - if (UserConfigParams::m_light_shaft && m_sunpixels > 30)//World::getWorld()->getTrack()->hasGodRays() && ) // god rays + const bool hasgodrays = World::getWorld()->getTrack()->hasGodRays(); + if (UserConfigParams::m_light_shaft && m_sunpixels > 30 && hasgodrays) { glEnable(GL_DEPTH_TEST); // Grab the sky diff --git a/src/graphics/render.cpp b/src/graphics/render.cpp index 4381466a5..38737c29e 100644 --- a/src/graphics/render.cpp +++ b/src/graphics/render.cpp @@ -236,7 +236,7 @@ void IrrDriver::renderGLSL(float dt) // Is the lens flare enabled & visible? Check last frame's query. const bool hasflare = World::getWorld()->getTrack()->hasLensFlare(); const bool hasgodrays = World::getWorld()->getTrack()->hasGodRays(); - if (UserConfigParams::m_light_shaft)//hasflare || hasgodrays) + if (UserConfigParams::m_light_shaft && hasgodrays)//hasflare || hasgodrays) { irr::video::COpenGLDriver* gl_driver = (irr::video::COpenGLDriver*)m_device->getVideoDriver(); From 3e4254b3a76a367df54a9a4adbae3657fed82e10 Mon Sep 17 00:00:00 2001 From: vlj Date: Fri, 25 Apr 2014 17:57:10 +0200 Subject: [PATCH 11/17] Tonemap: Use J. Hable filmic operator It gives better result on stk enterprise, slightly saturating blacks. --- data/shaders/tonemap.frag | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/data/shaders/tonemap.frag b/data/shaders/tonemap.frag index 186c69460..4e414578c 100644 --- a/data/shaders/tonemap.frag +++ b/data/shaders/tonemap.frag @@ -23,9 +23,13 @@ void main() vec3 Cw = getCIEYxy(col.xyz); float Lw = Cw.y; - float L = Lw * exposure / avgLw; + +/* float L = Lw * exposure / avgLw; float Ld = L * (1. + L / (Lwhite * Lwhite)); - Ld /= (1. + L); + Ld /= (1. + L);*/ + + float Ld = (Lw * (6.2 * Lw + .5)) / (Lw * (6.2 * Lw + 1.7) + 0.06); + Ld = pow(Ld, 2.2); FragColor = vec4(Ld * pow(col.xyz / Lw, vec3(saturation)), 1.); From 2ca11c316602960a50fdb68471b33e82efffe0db Mon Sep 17 00:00:00 2001 From: vlj Date: Sat, 26 Apr 2014 02:00:50 +0200 Subject: [PATCH 12/17] Auria provided tonemap coefficients --- data/shaders/tonemap.frag | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/data/shaders/tonemap.frag b/data/shaders/tonemap.frag index 4e414578c..b3c7d6905 100644 --- a/data/shaders/tonemap.frag +++ b/data/shaders/tonemap.frag @@ -24,13 +24,15 @@ void main() vec3 Cw = getCIEYxy(col.xyz); float Lw = Cw.y; -/* float L = Lw * exposure / avgLw; - float Ld = L * (1. + L / (Lwhite * Lwhite)); - Ld /= (1. + L);*/ + /* Reinhard, for reference */ +// float L = Lw * exposure / avgLw; +// float Ld = L * (1. + L / (Lwhite * Lwhite)); +// Ld /= (1. + L); +// FragColor = vec4(Ld * pow(col.xyz / Lw, vec3(saturation)), 1.); - float Ld = (Lw * (6.2 * Lw + .5)) / (Lw * (6.2 * Lw + 1.7) + 0.06); - Ld = pow(Ld, 2.2); - - FragColor = vec4(Ld * pow(col.xyz / Lw, vec3(saturation)), 1.); + // Uncharted2 tonemap with Auria's custom coefficients + vec4 perChannel = (col * (6.9 * col + .5)) / (col * (5.5 * col + 1.7) + 0.06); + perChannel = pow(perChannel, vec4(2.2)); + FragColor = vec4(perChannel.xyz, 1.); } From 924e09b3e9e2e95cc7e78483cef0782aaf44953e Mon Sep 17 00:00:00 2001 From: Marianne Gagnon Date: Fri, 25 Apr 2014 20:02:16 -0400 Subject: [PATCH 13/17] Very slight tweak --- data/shaders/tonemap.frag | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/shaders/tonemap.frag b/data/shaders/tonemap.frag index b3c7d6905..4b8077317 100644 --- a/data/shaders/tonemap.frag +++ b/data/shaders/tonemap.frag @@ -31,7 +31,7 @@ void main() // FragColor = vec4(Ld * pow(col.xyz / Lw, vec3(saturation)), 1.); // Uncharted2 tonemap with Auria's custom coefficients - vec4 perChannel = (col * (6.9 * col + .5)) / (col * (5.5 * col + 1.7) + 0.06); + vec4 perChannel = (col * (6.9 * col + .5)) / (col * (5.2 * col + 1.7) + 0.06); perChannel = pow(perChannel, vec4(2.2)); FragColor = vec4(perChannel.xyz, 1.); From a2e202a695b4764c25ff2ac5fd0318edb8d1a882 Mon Sep 17 00:00:00 2001 From: vlj Date: Sat, 26 Apr 2014 02:22:33 +0200 Subject: [PATCH 14/17] Missing "track->hasShadows" check --- src/graphics/render.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graphics/render.cpp b/src/graphics/render.cpp index 38737c29e..6edd492b5 100644 --- a/src/graphics/render.cpp +++ b/src/graphics/render.cpp @@ -901,7 +901,7 @@ void IrrDriver::renderLights(const core::aabbox3df& cambox, if (!m_lights[i]->isPointLight()) { m_lights[i]->render(); - if (UserConfigParams::m_shadows) + if (UserConfigParams::m_shadows && World::getWorld()->getTrack()->hasShadows()) m_post_processing->renderShadowedSunlight(sun_ortho_matrix, m_rtts->getShadowDepthTex()); else m_post_processing->renderSunlight(); From 2ee7f7a2e8619ba0b7d169750b5e0125d172e3fa Mon Sep 17 00:00:00 2001 From: Marianne Gagnon Date: Sat, 26 Apr 2014 20:04:16 -0400 Subject: [PATCH 15/17] Bugfix : use ambient light from the sun when SH maps are not used --- src/graphics/render.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/graphics/render.cpp b/src/graphics/render.cpp index 6edd492b5..d19277dec 100644 --- a/src/graphics/render.cpp +++ b/src/graphics/render.cpp @@ -1391,14 +1391,20 @@ void IrrDriver::generateSkyboxCubemap() int sh_w = 16; int sh_h = 16; + const video::SColorf& ambientf = irr_driver->getSceneManager()->getAmbientLight(); + video::SColor ambient = ambientf.toSColor(); + char *sh_rgba[6]; for (unsigned i = 0; i < 6; i++) { sh_rgba[i] = new char[sh_w * sh_h * 4]; - for (int j = 0; j < sh_w * sh_h * 4; j++) + for (int j = 0; j < sh_w * sh_h * 4; j+=4) { - sh_rgba[i][j] = 150; + sh_rgba[i][j] = ambient.getBlue(); + sh_rgba[i][j + 1] = ambient.getGreen(); + sh_rgba[i][j + 2] = ambient.getRed(); + sh_rgba[i][j + 3] = 255; } } From 9ac57c3919fa6f5c87cbec288e03f81c160c0e1c Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Sun, 27 Apr 2014 18:04:39 +0200 Subject: [PATCH 16/17] Tigher fit of light extent --- data/shaders/pointlight.vert | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/shaders/pointlight.vert b/data/shaders/pointlight.vert index 1831d4559..dc854fd38 100644 --- a/data/shaders/pointlight.vert +++ b/data/shaders/pointlight.vert @@ -16,7 +16,7 @@ const float zNear = 1.; void main(void) { // Beyond that value, light is too attenuated - float r = 500 * Energy; + float r = 100 * Energy; center = Position; energy = Energy; vec4 Center = ViewMatrix * vec4(Position, 1.); From 18aa119890c640d81b8efac328c1c799682e6ecb Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Sun, 27 Apr 2014 18:31:00 +0200 Subject: [PATCH 17/17] Tweak light attenuation. Doesnt really change the look of the light but reduce their extent. --- data/shaders/pointlight.frag | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/data/shaders/pointlight.frag b/data/shaders/pointlight.frag index 6369a7850..398506752 100644 --- a/data/shaders/pointlight.frag +++ b/data/shaders/pointlight.frag @@ -32,8 +32,7 @@ void main() vec3 light_pos = pseudocenter.xyz; vec3 light_col = col.xyz; float d = distance(light_pos, xpos.xyz); - float att = energy * 200. / (1 + d + 4. * 3.14 * d * d); - float spec_att = energy * 200. / (1 + d + 4. * 3.14 * d * d); + float att = energy * 200. / (1. + 33. * d + 33. * d * d); // Light Direction vec3 L = -normalize(xpos.xyz - light_pos); @@ -41,5 +40,5 @@ void main() float NdotL = max(0., dot(norm, L)); Diffuse = vec4(NdotL * light_col * att, 1.); - Specular = vec4(getSpecular(norm, eyedir, L, light_col, roughness) * NdotL * spec_att, 1.); + Specular = vec4(getSpecular(norm, eyedir, L, light_col, roughness) * NdotL * att, 1.); }