From ab252a306de99b206356bc25367da83f9d55cea9 Mon Sep 17 00:00:00 2001 From: hiker Date: Sat, 4 Oct 2014 00:39:32 +1000 Subject: [PATCH 01/30] Try to avoid graphical kart chassis being partially in ground (still not perfect). --- src/karts/kart.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index ee2ab1ac6..aee0d8b7c 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -2546,8 +2546,9 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz, float lean_height = tan(fabsf(m_current_lean)) * getKartWidth()*0.5f; float heading = m_skidding->getVisualSkidRotation(); + float xx = fabsf(m_speed)* getKartProperties()->getDownwardImpulseFactor()*0.0006f; Vec3 center_shift = Vec3(0, m_skidding->getGraphicalJumpOffset() - + lean_height +m_graphical_y_offset, 0); + + lean_height +m_graphical_y_offset+xx, 0); center_shift = getTrans().getBasis() * center_shift; Moveable::updateGraphics(dt, center_shift, From 8033c5a8395b81bcf50dccda9ca6ef377a306c98 Mon Sep 17 00:00:00 2001 From: Marianne Gagnon Date: Fri, 3 Oct 2014 18:39:07 -0400 Subject: [PATCH 02/30] Don't set animation strength on speed weighted objects, it's probably unnecessary and produces weird artifacts --- src/karts/kart_model.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/karts/kart_model.cpp b/src/karts/kart_model.cpp index 464acb111..b3bc16b4a 100644 --- a/src/karts/kart_model.cpp +++ b/src/karts/kart_model.cpp @@ -441,7 +441,6 @@ scene::ISceneNode* KartModel::attachModel(bool animated_models, bool always_anim obj.m_node = irr_driver->addAnimatedMesh(obj.m_model, node); obj.m_node->grab(); - obj.m_node->setAnimationStrength(0.0f); obj.m_node->setFrameLoop(m_animation_frame[AF_SPEED_WEIGHTED_START], m_animation_frame[AF_SPEED_WEIGHTED_END]); #ifdef DEBUG @@ -826,7 +825,6 @@ void KartModel::update(float dt, float rotation_dt, float steer, float speed) strength = speed * strength_factor; btClamp(strength, 0.0f, 1.0f); } - obj.m_node->setAnimationStrength(strength); // Animation speed const float speed_factor = GET_VALUE(obj, m_speed_factor); From 3a1b2442e8a53ee9aa8bbafa598347def80b412b Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Sat, 4 Oct 2014 00:59:37 +0200 Subject: [PATCH 03/30] Revert "Try to cull object whose aera is below 1 px" This reverts commit 83053e0ee42b1b84a9934ff34a6353c81d3fe6b4. --- src/graphics/stkscenemanager.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/graphics/stkscenemanager.cpp b/src/graphics/stkscenemanager.cpp index a5326473f..2ff2e33b6 100644 --- a/src/graphics/stkscenemanager.cpp +++ b/src/graphics/stkscenemanager.cpp @@ -167,7 +167,7 @@ bool isBoxInFrontOfPlane(const core::plane3df &plane, const core::vector3df edge } static -bool isCulledPrecise(const scene::ICameraSceneNode *cam, const scene::ISceneNode *node, bool aera_check) +bool isCulledPrecise(const scene::ICameraSceneNode *cam, const scene::ISceneNode *node) { if (!node->getAutomaticCulling()) return false; @@ -183,10 +183,6 @@ bool isCulledPrecise(const scene::ICameraSceneNode *cam, const scene::ISceneNode for (s32 i = 0; i < scene::SViewFrustum::VF_PLANE_COUNT; ++i) if (isBoxInFrontOfPlane(frust.planes[i], edges)) return true; - - float ratio = cam->getProjectionMatrix().pointer()[0] * cam->getProjectionMatrix().pointer()[5]; - if (aera_check && node->getBoundingBox().getArea() * ratio < 1.) - return true; return false; } @@ -439,14 +435,14 @@ parseSceneManager(core::list List, std::vector(*I)) { - if (!isCulledPrecise(cam, *I, false)) + if (!isCulledPrecise(cam, *I)) ParticlesList::getInstance()->push_back(node); continue; } if (STKBillboard *node = dynamic_cast(*I)) { - if (!isCulledPrecise(cam, *I, false)) + if (!isCulledPrecise(cam, *I)) BillBoardList::getInstance()->push_back(node); continue; } @@ -506,12 +502,12 @@ void IrrDriver::PrepareDrawCalls(scene::ICameraSceneNode *camnode) for (int i = 0; i < (int)DeferredUpdate.size(); i++) { scene::ISceneNode *node = dynamic_cast(DeferredUpdate[i]); - DeferredUpdate[i]->setCulledForPlayerCam(isCulledPrecise(camnode, node, false)); - DeferredUpdate[i]->setCulledForRSMCam(isCulledPrecise(m_suncam, node, true)); - DeferredUpdate[i]->setCulledForShadowCam(0, isCulledPrecise(m_shadow_camnodes[0], node, true)); - DeferredUpdate[i]->setCulledForShadowCam(1, isCulledPrecise(m_shadow_camnodes[1], node, true)); - DeferredUpdate[i]->setCulledForShadowCam(2, isCulledPrecise(m_shadow_camnodes[2], node, true)); - DeferredUpdate[i]->setCulledForShadowCam(3, isCulledPrecise(m_shadow_camnodes[3], node, true)); + DeferredUpdate[i]->setCulledForPlayerCam(isCulledPrecise(camnode, node)); + DeferredUpdate[i]->setCulledForRSMCam(isCulledPrecise(m_suncam, node)); + DeferredUpdate[i]->setCulledForShadowCam(0, isCulledPrecise(m_shadow_camnodes[0], node)); + DeferredUpdate[i]->setCulledForShadowCam(1, isCulledPrecise(m_shadow_camnodes[1], node)); + DeferredUpdate[i]->setCulledForShadowCam(2, isCulledPrecise(m_shadow_camnodes[2], node)); + DeferredUpdate[i]->setCulledForShadowCam(3, isCulledPrecise(m_shadow_camnodes[3], node)); } // Add a 1 s timeout From b56901bacdcce084b84dc63934cccd4f1ab10ad7 Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Sat, 4 Oct 2014 01:42:25 +0200 Subject: [PATCH 04/30] Fix minimap halo second time it is rendered. --- src/modes/world.cpp | 2 +- src/modes/world.hpp | 3 +++ src/tracks/quad_graph.cpp | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/modes/world.cpp b/src/modes/world.cpp index 65fc1a2d0..5637925f4 100644 --- a/src/modes/world.cpp +++ b/src/modes/world.cpp @@ -1229,7 +1229,7 @@ void World::escapePressed() bool World::isFogEnabled() const { - return m_track != NULL && m_track->isFogEnabled(); + return !m_force_disable_fog && (m_track != NULL && m_track->isFogEnabled()); } /* EOF */ diff --git a/src/modes/world.hpp b/src/modes/world.hpp index 4d34dbfa6..765f833e3 100644 --- a/src/modes/world.hpp +++ b/src/modes/world.hpp @@ -92,6 +92,7 @@ protected: RandomGenerator m_random; Physics* m_physics; + bool m_force_disable_fog; AbstractKart* m_fastest_kart; /** Number of eliminated karts. */ int m_eliminated_karts; @@ -332,6 +333,8 @@ public: { m_clear_color = color; } + /** Override track fog value to force disabled */ + void forceFogDisabled(bool v) { m_force_disable_fog = v; } // ------------------------------------------------------------------------ /** Override if you want to know when a kart presses fire */ virtual void onFirePressed(Controller* who) {} diff --git a/src/tracks/quad_graph.cpp b/src/tracks/quad_graph.cpp index 0ce062ea0..a8198cdd1 100644 --- a/src/tracks/quad_graph.cpp +++ b/src/tracks/quad_graph.cpp @@ -983,6 +983,7 @@ void QuadGraph::makeMiniMap(const core::dimension2du &dimension, { const SColor oldClearColor = World::getWorld()->getClearColor(); World::getWorld()->setClearbackBufferColor(SColor(0, 255, 255, 255)); + World::getWorld()->forceFogDisabled(true); *oldRttMinimap = NULL; *newRttMinimap = NULL; @@ -1102,6 +1103,7 @@ void QuadGraph::makeMiniMap(const core::dimension2du &dimension, *oldRttMinimap = texture; *newRttMinimap = frame_buffer; World::getWorld()->setClearbackBufferColor(oldClearColor); + World::getWorld()->forceFogDisabled(false); } // makeMiniMap //----------------------------------------------------------------------------- From f63e7d93b861989b79ce5bfd3192ad9d7ca97ca3 Mon Sep 17 00:00:00 2001 From: hiker Date: Sat, 4 Oct 2014 23:32:54 +1000 Subject: [PATCH 05/30] Fixed #1598 (error message about font texture not found). --- data/fonts/materials.xml | 22 ++++++++++++++++++++++ src/main.cpp | 10 +++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 data/fonts/materials.xml diff --git a/data/fonts/materials.xml b/data/fonts/materials.xml new file mode 100644 index 000000000..105ab3111 --- /dev/null +++ b/data/fonts/materials.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main.cpp b/src/main.cpp index 50e80db02..546757998 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1206,7 +1206,15 @@ int main(int argc, char *argv[] ) // Get into menu mode initially. input_manager->setMode(InputManager::MENU); main_loop = new MainLoop(); - material_manager -> loadMaterial (); + material_manager->loadMaterial(); + + // Load the font textures + file_manager->pushTextureSearchPath( + file_manager->getAsset(FileManager::FONT,"")); + material_manager->addSharedMaterial( + file_manager->getAsset(FileManager::FONT,"materials.xml")); + file_manager->popTextureSearchPath(); + GUIEngine::addLoadingIcon( irr_driver->getTexture(FileManager::GUI, "options_video.png")); kart_properties_manager -> loadAllKarts (); From 78b21eb8402eb900208ab3a287eb22e67dfebef7 Mon Sep 17 00:00:00 2001 From: Deve Date: Sat, 4 Oct 2014 21:50:11 +0200 Subject: [PATCH 06/30] Fixed visibility parameter for icon button widget. It was set for widget but not for irrlicht gui element. --- src/guiengine/widgets/icon_button_widget.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/guiengine/widgets/icon_button_widget.cpp b/src/guiengine/widgets/icon_button_widget.cpp index 4255895a0..66342ebfc 100644 --- a/src/guiengine/widgets/icon_button_widget.cpp +++ b/src/guiengine/widgets/icon_button_widget.cpp @@ -189,6 +189,9 @@ void IconButtonWidget::add() m_id = m_element->getID(); if (m_tab_stop) m_element->setTabOrder(m_id); m_element->setTabGroup(false); + + if (!m_is_visible) + m_element->setVisible(false); } // ----------------------------------------------------------------------------- From 5a07fd0fa46f6c6c23286ce835ec4ac806067376 Mon Sep 17 00:00:00 2001 From: Marianne Gagnon Date: Sat, 4 Oct 2014 19:05:27 -0400 Subject: [PATCH 07/30] FIx crash in LOD --- src/graphics/lod_node.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/graphics/lod_node.cpp b/src/graphics/lod_node.cpp index 1fea813a6..31ab6d731 100644 --- a/src/graphics/lod_node.cpp +++ b/src/graphics/lod_node.cpp @@ -80,7 +80,11 @@ int LODNode::getLevel() if (camera == NULL) return (int)m_detail.size() - 1; AbstractKart* kart = camera->getKart(); - const Vec3 &pos = kart->getFrontXYZ(); + // use kart position and not camera position when a kart is available, + // because for some effects the camera will be moved to various locations + // (for instance shadows), so using camera position for LOD may result + // in objects being culled when they shouldn't + const Vec3 &pos = (kart != NULL ? kart->getFrontXYZ() : camera->getCameraSceneNode()->getAbsolutePosition()); const int dist = (int)((m_nodes[0]->getAbsolutePosition()).getDistanceFromSQ(pos.toIrrVector() )); From c1d6c054c8af02c17705f1eb49314c0980685846 Mon Sep 17 00:00:00 2001 From: Marianne Gagnon Date: Sat, 4 Oct 2014 19:38:44 -0400 Subject: [PATCH 08/30] Route a few more controls rendering through the skin, to make them use OpenGL 3 --- lib/irrlicht/source/Irrlicht/CGUIButton.cpp | 2 +- lib/irrlicht/source/Irrlicht/CGUIImage.cpp | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/irrlicht/source/Irrlicht/CGUIButton.cpp b/lib/irrlicht/source/Irrlicht/CGUIButton.cpp index d4e6d9a91..74c335a35 100644 --- a/lib/irrlicht/source/Irrlicht/CGUIButton.cpp +++ b/lib/irrlicht/source/Irrlicht/CGUIButton.cpp @@ -277,7 +277,7 @@ void CGUIButton::draw() pos.X += skin->getSize(EGDS_BUTTON_PRESSED_IMAGE_OFFSET_X); pos.Y += skin->getSize(EGDS_BUTTON_PRESSED_IMAGE_OFFSET_Y); } - driver->draw2DImage(PressedImage, + skin->draw2DImage(PressedImage, ScaleImage? AbsoluteRect : core::recti(pos, PressedImageRect.getSize()), PressedImageRect, &AbsoluteClippingRect, diff --git a/lib/irrlicht/source/Irrlicht/CGUIImage.cpp b/lib/irrlicht/source/Irrlicht/CGUIImage.cpp index 17d30e0ec..184a6e5cc 100644 --- a/lib/irrlicht/source/Irrlicht/CGUIImage.cpp +++ b/lib/irrlicht/source/Irrlicht/CGUIImage.cpp @@ -78,20 +78,20 @@ void CGUIImage::draw() if (Texture) { - if (ScaleImage) - { + //if (ScaleImage) + //{ const video::SColor Colors[] = {Color,Color,Color,Color}; - driver->draw2DImage(Texture, AbsoluteRect, + skin->draw2DImage(Texture, AbsoluteRect, core::rect(core::position2d(0,0), core::dimension2di(Texture->getOriginalSize())), &AbsoluteClippingRect, Colors, UseAlphaChannel); - } - else - { - driver->draw2DImage(Texture, AbsoluteRect.UpperLeftCorner, - core::rect(core::position2d(0,0), core::dimension2di(Texture->getOriginalSize())), - &AbsoluteClippingRect, Color, UseAlphaChannel); - } + //} + //else + //{ + // driver->draw2DImage(Texture, AbsoluteRect.UpperLeftCorner, + // core::rect(core::position2d(0,0), core::dimension2di(Texture->getOriginalSize())), + // &AbsoluteClippingRect, Color, UseAlphaChannel); + //} } else { From 83b25768cc8910d6378443f29c75317f08952cd0 Mon Sep 17 00:00:00 2001 From: Marianne Gagnon Date: Sat, 4 Oct 2014 19:44:04 -0400 Subject: [PATCH 09/30] tweak players screen, checkbox placement was weird --- data/gui/user_screen.stkgui | 10 ++++++---- data/gui/user_screen_tab.stkgui | 12 +++++++----- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/data/gui/user_screen.stkgui b/data/gui/user_screen.stkgui index acb65467f..0a7d83e31 100644 --- a/data/gui/user_screen.stkgui +++ b/data/gui/user_screen.stkgui @@ -13,15 +13,17 @@ square_items="true" child_width="128" child_height="128" /> -
+
-
-
- - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/src/graphics/material.cpp b/src/graphics/material.cpp index d633a8a3c..b9244c1a6 100644 --- a/src/graphics/material.cpp +++ b/src/graphics/material.cpp @@ -57,8 +57,7 @@ Material::Material(const XMLNode *node, bool deprecated) m_shader_type = SHADERTYPE_SOLID; m_deprecated = deprecated; - node->get("name", &m_texname); - + node->get("name", &m_texname); if (m_texname=="") { throw std::runtime_error("[Material] No texture name specified " @@ -66,6 +65,7 @@ Material::Material(const XMLNode *node, bool deprecated) } init(); + node->get("lazy-load", &m_lazy_load); bool b = false; node->get("clampu", &b); if (b) m_clamp_tex |= UCLAMP; //blender 2.4 style @@ -412,10 +412,10 @@ Material::Material(const std::string& fname, bool is_full_path, */ void Material::init() { + m_lazy_load = false; + m_texture = NULL; m_clamp_tex = 0; m_shader_type = SHADERTYPE_SOLID; - //m_lightmap = false; - //m_adjust_image = ADJ_NONE; m_backface_culling = true; m_high_tire_adhesion = false; m_below_surface = false; @@ -455,6 +455,9 @@ void Material::init() //----------------------------------------------------------------------------- void Material::install(bool is_full_path, bool complain_if_not_found) { + // Don't load a texture that is lazily loaded. + if(m_lazy_load) return; + const std::string &full_path = is_full_path ? m_texname : file_manager->searchTexture(m_texname); diff --git a/src/graphics/material.hpp b/src/graphics/material.hpp index 4e95e648b..934c3c433 100644 --- a/src/graphics/material.hpp +++ b/src/graphics/material.hpp @@ -22,13 +22,11 @@ #include "utils/no_copy.hpp" +#include #include #include #include -#include - - namespace irr { namespace video { class ITexture; class SMaterial; } @@ -81,9 +79,18 @@ public: private: + /** Pointer to the texture. */ video::ITexture *m_texture; - //unsigned int m_index; + + /** Name of the texture. */ std::string m_texname; + + /** If true, the texture will not automatically be loaded and bound + * at load time, it must be loaded elsewhere. This is used to store + * material settings for font textures, without loading fonts for + * languages that might not be needed at all. */ + bool m_lazy_load; + /** Name of a special sfx to play when a kart is on this terrain, or * "" if no special sfx exists. */ std::string m_sfx_name; @@ -114,7 +121,7 @@ private: /** If a kart is rescued when driving on this surface. */ bool m_drive_reset; - /** True if this is a texture that will start the jump animatoin when + /** True if this is a texture that will start the jump animation when * leaving it and being in the air. */ bool m_is_jump_texture; @@ -244,27 +251,45 @@ public: void setSFXSpeed(SFXBase *sfx, float speed, bool should_be_paused) const; void setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* mb); - void adjustForFog(scene::ISceneNode* parent, video::SMaterial *m, bool use_fog) const; + void adjustForFog(scene::ISceneNode* parent, video::SMaterial *m, + bool use_fog) const; + void onMadeVisible(scene::IMeshBuffer* who); + void onHidden(scene::IMeshBuffer* who); + void isInitiallyHidden(scene::IMeshBuffer* who); /** Returns the ITexture associated with this material. */ - video::ITexture *getTexture() const { return m_texture; } + video::ITexture *getTexture() const + { + // Note that atm lazy load means that the textures are not loaded + // via the material. So getTexture should only get called for non + // lazily loaded textures (used atm for font textures. + assert(!m_lazy_load); + return m_texture; + } // getTexture + // ------------------------------------------------------------------------ bool isIgnore () const { return m_ignore; } + // ------------------------------------------------------------------------ /** Returns true if this material is a zipper. */ bool isZipper () const { return m_zipper; } + // ------------------------------------------------------------------------ /** Returns if this material should trigger a rescue if a kart * is driving on it. */ bool isDriveReset () const { return m_drive_reset; } + // ------------------------------------------------------------------------ /** Returns if this material should trigger a rescue if a kart * crashes against it. */ CollisionReaction getCollisionReaction() const { return m_collision_reaction; } + // ------------------------------------------------------------------------ std::string getCrashResetParticles() const { return m_collision_particles; } + // ------------------------------------------------------------------------ bool highTireAdhesion () const { return m_high_tire_adhesion; } + // ------------------------------------------------------------------------ const std::string& getTexFname () const { return m_texname; } - //int getIndex () const { return m_index; } + // ------------------------------------------------------------------------ bool isTransparent () const { return m_shader_type == SHADERTYPE_ADDITIVE || @@ -272,12 +297,6 @@ public: m_shader_type == SHADERTYPE_ALPHA_TEST; } - // ------------------------------------------------------------------------ - /** Returns true if this materials need pre-multiply of alpha. */ - //bool isPreMul() const {return m_adjust_image==ADJ_PREMUL; } - // ------------------------------------------------------------------------ - /** Returns true if this materials need pre-division of alpha. */ - //bool isPreDiv() const {return m_adjust_image==ADJ_DIV; } // ------------------------------------------------------------------------ /** Returns the fraction of maximum speed on this material. */ float getMaxSpeedFraction() const { return m_max_speed_fraction; } @@ -300,17 +319,20 @@ public: // ------------------------------------------------------------------------ /** Returns the name of a special sfx to play while a kart is on this * terrain. The string will be "" if no special sfx exists. */ - const std::string & - getSFXName () const { return m_sfx_name; } + const std::string &getSFXName() const { return m_sfx_name; } + // ------------------------------------------------------------------------ + /** Returns if fog is enabled. */ bool isFogEnabled() const { return m_fog; } - /** - * \brief Get the kind of particles that are to be used on this material, in the given conditions - * \return The particles to use, or NULL if none - */ - const ParticleKind* getParticlesWhen(ParticleConditions cond) const { return m_particles_effects[cond]; } - + // ------------------------------------------------------------------------ + /** \brief Get the kind of particles that are to be used on this material, + * in the given conditions. + * \return The particles to use, or NULL if none. */ + const ParticleKind* getParticlesWhen(ParticleConditions cond) const + { + return m_particles_effects[cond]; + } // getParticlesWhen // ------------------------------------------------------------------------ /** Returns true if a kart falling over this kind of material triggers * the special falling camera. */ @@ -346,9 +368,6 @@ public: // ------------------------------------------------------------------------ ShaderType getShaderType() const { return m_shader_type; } // ------------------------------------------------------------------------ - void onMadeVisible(scene::IMeshBuffer* who); - void onHidden(scene::IMeshBuffer* who); - void isInitiallyHidden(scene::IMeshBuffer* who); } ; diff --git a/src/main.cpp b/src/main.cpp index 546757998..54bd8b79e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1208,12 +1208,11 @@ int main(int argc, char *argv[] ) main_loop = new MainLoop(); material_manager->loadMaterial(); - // Load the font textures - file_manager->pushTextureSearchPath( - file_manager->getAsset(FileManager::FONT,"")); + // Load the font textures - they are all lazily loaded + // so no need to push a texture search path. They will actually + // be loaded from ScalableFont. material_manager->addSharedMaterial( file_manager->getAsset(FileManager::FONT,"materials.xml")); - file_manager->popTextureSearchPath(); GUIEngine::addLoadingIcon( irr_driver->getTexture(FileManager::GUI, "options_video.png")); From f95eeb7f56764f4e126d397e07d54523e492efe0 Mon Sep 17 00:00:00 2001 From: Flakebi Date: Sun, 5 Oct 2014 15:11:45 +0200 Subject: [PATCH 14/30] Fix #1602 --- src/states_screens/user_screen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/states_screens/user_screen.cpp b/src/states_screens/user_screen.cpp index 5029a90ad..787d6726a 100644 --- a/src/states_screens/user_screen.cpp +++ b/src/states_screens/user_screen.cpp @@ -282,7 +282,7 @@ void BaseUserScreen::eventCallback(Widget* widget, else if (button == "cancel") { StateManager::get()->popMenu(); - onEscapePressed(); + StateManager::get()->escapePressed(); } else if (button == "recover") { From 9f2b66d195bfcdb827a8306f1f9c0ddf7bfd79d5 Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Sun, 5 Oct 2014 20:37:49 +0200 Subject: [PATCH 15/30] Use specmap on others mats --- .../instanced_detailledobject_pass2.frag | 6 +++++- data/shaders/instanced_grass_pass2.frag | 6 +++++- src/graphics/render_geometry.cpp | 18 +++++++++--------- src/graphics/shaders.cpp | 8 ++++---- src/graphics/shaders.hpp | 8 ++++---- 5 files changed, 27 insertions(+), 19 deletions(-) diff --git a/data/shaders/instanced_detailledobject_pass2.frag b/data/shaders/instanced_detailledobject_pass2.frag index 44790f61c..927a6a845 100644 --- a/data/shaders/instanced_detailledobject_pass2.frag +++ b/data/shaders/instanced_detailledobject_pass2.frag @@ -1,10 +1,12 @@ #ifndef GL_ARB_bindless_texture uniform sampler2D Albedo; uniform sampler2D Detail; +uniform sampler2D SpecMap; #endif #ifdef GL_ARB_bindless_texture flat in sampler2D handle; +flat in sampler2D secondhandle; flat in sampler2D thirdhandle; #endif in vec2 uv; @@ -17,6 +19,7 @@ void main(void) { #ifdef GL_ARB_bindless_texture vec4 color = texture(handle, uv); + float specmap = texture(secondhandle, uv).g; #ifdef SRGBBindlessFix color.xyz = pow(color.xyz, vec3(2.2)); #endif @@ -24,7 +27,8 @@ void main(void) #else vec4 color = texture(Albedo, uv); vec4 detail = texture(Detail, uv_bis); + float specmap = texture(SpecMap, uv).g; #endif color *= detail; - FragColor = vec4(getLightFactor(color.xyz, vec3(1.), 1.), 1.); + FragColor = vec4(getLightFactor(color.xyz, vec3(1.), specmap), 1.); } diff --git a/data/shaders/instanced_grass_pass2.frag b/data/shaders/instanced_grass_pass2.frag index fd48f1012..0bd7f0dbe 100644 --- a/data/shaders/instanced_grass_pass2.frag +++ b/data/shaders/instanced_grass_pass2.frag @@ -2,6 +2,7 @@ layout(bindless_sampler) uniform sampler2D dtex; #else uniform sampler2D Albedo; +uniform sampler2D SpecMap; uniform sampler2D dtex; #endif @@ -9,6 +10,7 @@ uniform vec3 SunDir; #ifdef GL_ARB_bindless_texture flat in sampler2D handle; +flat in sampler2D secondhandle; #endif in vec3 nor; in vec2 uv; @@ -20,11 +22,13 @@ void main(void) { #ifdef GL_ARB_bindless_texture vec4 color = texture(handle, uv); + float specmap = texture(secondhandle, uv).g; #ifdef SRGBBindlessFix color.xyz = pow(color.xyz, vec3(2.2)); #endif #else vec4 color = texture(Albedo, uv); + float specmap = texture(SpecMap, uv).g; #endif if (color.a < 0.5) discard; @@ -44,6 +48,6 @@ void main(void) float scattering = mix(fPowEdotL, fLdotNBack, .5); - vec3 LightFactor = color.xyz * (scattering * 0.3) + getLightFactor(color.xyz, vec3(1.), 1.); + vec3 LightFactor = color.xyz * (scattering * 0.3) + getLightFactor(color.xyz, vec3(1.), specmap); FragColor = vec4(LightFactor, 1.); } diff --git a/src/graphics/render_geometry.cpp b/src/graphics/render_geometry.cpp index b0421af7c..2bc9426ce 100644 --- a/src/graphics/render_geometry.cpp +++ b/src/graphics/render_geometry.cpp @@ -75,7 +75,7 @@ struct DefaultMaterial }; const std::vector DefaultMaterial::FirstPassTextures = { 1 }; -const std::vector DefaultMaterial::SecondPassTextures = { 0 }; +const std::vector DefaultMaterial::SecondPassTextures = { 0, 1 }; struct AlphaRef { @@ -93,7 +93,7 @@ struct AlphaRef }; const std::vector AlphaRef::FirstPassTextures = { 0, 1 }; -const std::vector AlphaRef::SecondPassTextures = { 0 }; +const std::vector AlphaRef::SecondPassTextures = { 0, 1 }; struct SphereMap { @@ -165,7 +165,7 @@ struct NormalMat }; const std::vector NormalMat::FirstPassTextures = { 2, 1 }; -const std::vector NormalMat::SecondPassTextures = { 0 }; +const std::vector NormalMat::SecondPassTextures = { 0, 1 }; struct DetailMat { @@ -183,7 +183,7 @@ struct DetailMat }; const std::vector DetailMat::FirstPassTextures = { 1 }; -const std::vector DetailMat::SecondPassTextures = { 0, 2 }; +const std::vector DetailMat::SecondPassTextures = { 0, 2, 1 }; struct SplattingMat { @@ -531,15 +531,15 @@ void IrrDriver::renderSolidSecondPass() if (UserConfigParams::m_azdo) { - multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, 0)); - multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, 0)); + multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0)); + multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0)); multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, 0)); multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, 0)); SunLightProvider * const cb = (SunLightProvider *)irr_driver->getCallback(ES_SUNLIGHT); - multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, DepthHandle, 0), windDir, cb->getPosition()); + multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, DepthHandle, 0, 0), windDir, cb->getPosition()); - multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, 0)); - multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0)); + multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0)); + multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0, 0)); } else if (irr_driver->hasARB_draw_indirect()) { diff --git a/src/graphics/shaders.cpp b/src/graphics/shaders.cpp index d18c1900a..61148e2ac 100644 --- a/src/graphics/shaders.cpp +++ b/src/graphics/shaders.cpp @@ -865,7 +865,7 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/instanced_object_pass2.frag").c_str()); AssignUniforms(); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo"); + AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "SpecMap"); } InstancedObjectRefPass2Shader::InstancedObjectRefPass2Shader() @@ -876,7 +876,7 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/instanced_objectref_pass2.frag").c_str()); AssignUniforms(); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo"); + AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "SpecMap"); } DetailledObjectPass2Shader::DetailledObjectPass2Shader() @@ -897,7 +897,7 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/instanced_detailledobject_pass2.frag").c_str()); AssignUniforms(); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "Detail"); + AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "Detail", 5, "SpecMap"); } ObjectUnlitShader::ObjectUnlitShader() @@ -947,7 +947,7 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/instanced_grass_pass2.frag").c_str()); AssignUniforms("windDir", "SunDir"); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "dtex", 4, "Albedo"); + AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "dtex", 4, "Albedo", 4, "SpecMap"); } SphereMapShader::SphereMapShader() diff --git a/src/graphics/shaders.hpp b/src/graphics/shaders.hpp index 9a0214731..719bf63b0 100644 --- a/src/graphics/shaders.hpp +++ b/src/graphics/shaders.hpp @@ -107,13 +107,13 @@ public: ObjectPass2Shader(); }; -class InstancedObjectPass2Shader : public ShaderHelperSingleton, public TextureRead +class InstancedObjectPass2Shader : public ShaderHelperSingleton, public TextureRead { public: InstancedObjectPass2Shader(); }; -class InstancedObjectRefPass2Shader : public ShaderHelperSingleton, public TextureRead +class InstancedObjectRefPass2Shader : public ShaderHelperSingleton, public TextureRead { public: InstancedObjectRefPass2Shader(); @@ -125,7 +125,7 @@ public: DetailledObjectPass2Shader(); }; -class InstancedDetailledObjectPass2Shader : public ShaderHelperSingleton, public TextureRead +class InstancedDetailledObjectPass2Shader : public ShaderHelperSingleton, public TextureRead { public: InstancedDetailledObjectPass2Shader(); @@ -155,7 +155,7 @@ public: GrassPass2Shader(); }; -class InstancedGrassPass2Shader : public ShaderHelperSingleton, public TextureRead +class InstancedGrassPass2Shader : public ShaderHelperSingleton, public TextureRead { public: InstancedGrassPass2Shader(); From a8161288a9e5d4b856afce3297df386cbbe56bab Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Sun, 5 Oct 2014 20:47:13 +0200 Subject: [PATCH 16/30] Convert remaining shaders --- data/shaders/detailledobject_pass2.frag | 5 ++++- data/shaders/grass_pass2.frag | 5 ++++- data/shaders/object_pass2.frag | 5 ++++- data/shaders/objectref_pass2.frag | 5 ++++- src/graphics/shaders.cpp | 10 +++++----- src/graphics/shaders.hpp | 8 ++++---- 6 files changed, 25 insertions(+), 13 deletions(-) diff --git a/data/shaders/detailledobject_pass2.frag b/data/shaders/detailledobject_pass2.frag index 832a68f70..5b19966cc 100644 --- a/data/shaders/detailledobject_pass2.frag +++ b/data/shaders/detailledobject_pass2.frag @@ -1,9 +1,11 @@ #ifdef GL_ARB_bindless_texture layout(bindless_sampler) uniform sampler2D Albedo; layout(bindless_sampler) uniform sampler2D Detail; +layout(bindless_sampler) uniform sampler2D SpecMap; #else uniform sampler2D Albedo; uniform sampler2D Detail; +uniform sampler2D SpecMap; #endif #if __VERSION__ >= 130 @@ -28,5 +30,6 @@ void main(void) #endif vec4 detail = texture(Detail, uv_bis); color *= detail; - FragColor = vec4(getLightFactor(color.xyz, vec3(1.), 1.), 1.); + float specmap = texture(SpecMap, uv).g; + FragColor = vec4(getLightFactor(color.xyz, vec3(1.), specmap), 1.); } diff --git a/data/shaders/grass_pass2.frag b/data/shaders/grass_pass2.frag index 10d747e1b..6b677ceea 100644 --- a/data/shaders/grass_pass2.frag +++ b/data/shaders/grass_pass2.frag @@ -1,9 +1,11 @@ #ifdef GL_ARB_bindless_texture layout(bindless_sampler) uniform sampler2D Albedo; layout(bindless_sampler) uniform sampler2D dtex; +layout(bindless_sampler) uniform sampler2D SpecMap; #else uniform sampler2D Albedo; uniform sampler2D dtex; +uniform sampler2D SpecMap; #endif uniform vec3 SunDir; @@ -38,7 +40,8 @@ void main(void) float fLdotNBack = max(0., - dot(nor, SunDir) * 0.6 + 0.4); float scattering = mix(fPowEdotL, fLdotNBack, .5); + float specmap = texture(SpecMap, uv).g; - vec3 LightFactor = color.xyz * (scattering * 0.3) + getLightFactor(color.xyz, vec3(1.), 1.); + vec3 LightFactor = color.xyz * (scattering * 0.3) + getLightFactor(color.xyz, vec3(1.), specmap); FragColor = vec4(color.xyz * LightFactor, 1.); } diff --git a/data/shaders/object_pass2.frag b/data/shaders/object_pass2.frag index 53341f689..dc2fca7f1 100644 --- a/data/shaders/object_pass2.frag +++ b/data/shaders/object_pass2.frag @@ -1,7 +1,9 @@ #ifdef GL_ARB_bindless_texture layout(bindless_sampler) uniform sampler2D Albedo; +layout(bindless_sampler) uniform sampler2D SpecMap; #else uniform sampler2D Albedo; +uniform sampler2D SpecMap; #endif in vec2 uv; @@ -21,5 +23,6 @@ void main(void) vec4 col = texture(Albedo, uv); #endif col.xyz *= pow(color.xyz, vec3(2.2)); - FragColor = vec4(getLightFactor(color.xyz, vec3(1.), 1.), 1.); + float specmap = texture(SpecMap, uv).g; + FragColor = vec4(getLightFactor(color.xyz, vec3(1.), specmap), 1.); } diff --git a/data/shaders/objectref_pass2.frag b/data/shaders/objectref_pass2.frag index d6b2d1f1c..ae1531a98 100644 --- a/data/shaders/objectref_pass2.frag +++ b/data/shaders/objectref_pass2.frag @@ -1,7 +1,9 @@ #ifdef GL_ARB_bindless_texture layout(bindless_sampler) uniform sampler2D Albedo; +layout(bindless_sampler) uniform sampler2D SpecMap; #else uniform sampler2D Albedo; +uniform sampler2D SpecMap; #endif in vec2 uv; @@ -20,5 +22,6 @@ void main(void) #endif col.xyz *= pow(color.xyz, vec3(2.2)); if (col.a * color.a < 0.5) discard; - FragColor = vec4(getLightFactor(color.xyz, vec3(1.), 1.), 1.); + float specmap = texture(SpecMap, uv).g; + FragColor = vec4(getLightFactor(color.xyz, vec3(1.), specmap), 1.); } diff --git a/src/graphics/shaders.cpp b/src/graphics/shaders.cpp index 61148e2ac..289d81660 100644 --- a/src/graphics/shaders.cpp +++ b/src/graphics/shaders.cpp @@ -854,7 +854,7 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_pass2.frag").c_str()); AssignUniforms("ModelMatrix", "TextureMatrix"); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo"); + AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "Specmap"); } InstancedObjectPass2Shader::InstancedObjectPass2Shader() @@ -886,7 +886,7 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/detailledobject_pass2.frag").c_str()); AssignUniforms("ModelMatrix"); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "Detail"); + AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "Detail", 5, "Specmap"); } InstancedDetailledObjectPass2Shader::InstancedDetailledObjectPass2Shader() @@ -926,7 +926,7 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass2.frag").c_str()); AssignUniforms("ModelMatrix", "TextureMatrix"); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo"); + AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "Specmap"); } GrassPass2Shader::GrassPass2Shader() @@ -936,7 +936,7 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/grass_pass2.frag").c_str()); AssignUniforms("ModelMatrix", "windDir"); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo"); + AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "Specmap"); } InstancedGrassPass2Shader::InstancedGrassPass2Shader() @@ -947,7 +947,7 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/instanced_grass_pass2.frag").c_str()); AssignUniforms("windDir", "SunDir"); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "dtex", 4, "Albedo", 4, "SpecMap"); + AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "dtex", 4, "Albedo", 5, "SpecMap"); } SphereMapShader::SphereMapShader() diff --git a/src/graphics/shaders.hpp b/src/graphics/shaders.hpp index 719bf63b0..3113ce75c 100644 --- a/src/graphics/shaders.hpp +++ b/src/graphics/shaders.hpp @@ -101,7 +101,7 @@ public: InstancedNormalMapShader(); }; -class ObjectPass2Shader : public ShaderHelperSingleton, public TextureRead +class ObjectPass2Shader : public ShaderHelperSingleton, public TextureRead { public: ObjectPass2Shader(); @@ -119,7 +119,7 @@ public: InstancedObjectRefPass2Shader(); }; -class DetailledObjectPass2Shader : public ShaderHelperSingleton, public TextureRead +class DetailledObjectPass2Shader : public ShaderHelperSingleton, public TextureRead { public: DetailledObjectPass2Shader(); @@ -143,13 +143,13 @@ public: InstancedObjectUnlitShader(); }; -class ObjectRefPass2Shader : public ShaderHelperSingleton, public TextureRead +class ObjectRefPass2Shader : public ShaderHelperSingleton, public TextureRead { public: ObjectRefPass2Shader(); }; -class GrassPass2Shader : public ShaderHelperSingleton, public TextureRead +class GrassPass2Shader : public ShaderHelperSingleton, public TextureRead { public: GrassPass2Shader(); From 297221ca3d13505fdfbb7e702f7ecb2bd10a9a0a Mon Sep 17 00:00:00 2001 From: Flakebi Date: Sun, 5 Oct 2014 21:32:14 +0200 Subject: [PATCH 17/30] Fix #1438 --- src/guiengine/widgets/ribbon_widget.cpp | 26 ++++--------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/src/guiengine/widgets/ribbon_widget.cpp b/src/guiengine/widgets/ribbon_widget.cpp index 2300dbf91..78e2b95d1 100644 --- a/src/guiengine/widgets/ribbon_widget.cpp +++ b/src/guiengine/widgets/ribbon_widget.cpp @@ -141,14 +141,8 @@ void RibbonWidget::add() total_needed_space += m_active_children[i].m_w; } - int free_w_space = m_w - total_needed_space; - //int biggest_y = 0; const int button_y = 10; - float global_zoom = 1; - - const int min_free_space = 50; - global_zoom = (float)m_w / (float)( m_w - free_w_space + min_free_space ); const int one_button_space = int(roundf((float)m_w / (float)subbuttons_amount)); @@ -320,22 +314,10 @@ void RibbonWidget::add() float image_h = (float)image->getSize().Height; float image_w = image_h*imageRatio; - - // scale to fit (FIXME: calculate the right value directly...) - float zoom = global_zoom; - - if (button_y + image_h*zoom + needed_space_under_button > m_h) - { - // scale down - while (button_y + image_h*zoom + - needed_space_under_button > m_h) zoom -= 0.01f; - } - else - { - // scale up - while (button_y + image_h*zoom + - needed_space_under_button < m_h) zoom += 0.01f; - } + float zoom = (float) (m_h - button_y - needed_space_under_button) / image_h; + float zoom_x = (float) one_button_space / image_w; + if(zoom_x < zoom) + zoom = zoom_x; // ---- add bitmap button part // backup and restore position in case the same object is added From 4c4aba2ad8c1c97c25d72694c4c6f00a43c0145a Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Sun, 5 Oct 2014 21:33:11 +0200 Subject: [PATCH 18/30] Some fixes --- src/graphics/render_geometry.cpp | 2 +- src/graphics/shaders.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/graphics/render_geometry.cpp b/src/graphics/render_geometry.cpp index 2bc9426ce..613c9c1e5 100644 --- a/src/graphics/render_geometry.cpp +++ b/src/graphics/render_geometry.cpp @@ -147,7 +147,7 @@ struct GrassMat }; const std::vector GrassMat::FirstPassTextures = { 0 }; -const std::vector GrassMat::SecondPassTextures = { 0 }; +const std::vector GrassMat::SecondPassTextures = { 0, 1 }; struct NormalMat { diff --git a/src/graphics/shaders.cpp b/src/graphics/shaders.cpp index 289d81660..d445f96a9 100644 --- a/src/graphics/shaders.cpp +++ b/src/graphics/shaders.cpp @@ -854,7 +854,7 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_pass2.frag").c_str()); AssignUniforms("ModelMatrix", "TextureMatrix"); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "Specmap"); + AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "SpecMap"); } InstancedObjectPass2Shader::InstancedObjectPass2Shader() @@ -886,7 +886,7 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/detailledobject_pass2.frag").c_str()); AssignUniforms("ModelMatrix"); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "Detail", 5, "Specmap"); + AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "Detail", 5, "SpecMap"); } InstancedDetailledObjectPass2Shader::InstancedDetailledObjectPass2Shader() @@ -926,7 +926,7 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass2.frag").c_str()); AssignUniforms("ModelMatrix", "TextureMatrix"); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "Specmap"); + AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "SpecMap"); } GrassPass2Shader::GrassPass2Shader() @@ -936,7 +936,7 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/grass_pass2.frag").c_str()); AssignUniforms("ModelMatrix", "windDir"); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "Specmap"); + AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "SpecMap"); } InstancedGrassPass2Shader::InstancedGrassPass2Shader() From 300a09746fafd44a7b46f661009cd5eeda03376d Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Sun, 5 Oct 2014 21:45:56 +0200 Subject: [PATCH 19/30] Additionnal fixes --- data/shaders/object_pass2.frag | 2 +- data/shaders/objectref_pass2.frag | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data/shaders/object_pass2.frag b/data/shaders/object_pass2.frag index dc2fca7f1..ba984f87d 100644 --- a/data/shaders/object_pass2.frag +++ b/data/shaders/object_pass2.frag @@ -24,5 +24,5 @@ void main(void) #endif col.xyz *= pow(color.xyz, vec3(2.2)); float specmap = texture(SpecMap, uv).g; - FragColor = vec4(getLightFactor(color.xyz, vec3(1.), specmap), 1.); + FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap), 1.); } diff --git a/data/shaders/objectref_pass2.frag b/data/shaders/objectref_pass2.frag index ae1531a98..a7fd08dca 100644 --- a/data/shaders/objectref_pass2.frag +++ b/data/shaders/objectref_pass2.frag @@ -23,5 +23,5 @@ void main(void) col.xyz *= pow(color.xyz, vec3(2.2)); if (col.a * color.a < 0.5) discard; float specmap = texture(SpecMap, uv).g; - FragColor = vec4(getLightFactor(color.xyz, vec3(1.), specmap), 1.); + FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap), 1.); } From 0db951f3741227568374771a8d72d0deba509ba6 Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Sun, 5 Oct 2014 21:53:06 +0200 Subject: [PATCH 20/30] Try to emulate enery conservation --- data/shaders/instanced_object_pass2.frag | 2 +- data/shaders/instanced_objectpass_spheremap.frag | 2 +- data/shaders/objectpass_spheremap.frag | 2 +- data/shaders/utils/getLightFactor.frag | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/data/shaders/instanced_object_pass2.frag b/data/shaders/instanced_object_pass2.frag index 8068bf40c..c260d7aab 100644 --- a/data/shaders/instanced_object_pass2.frag +++ b/data/shaders/instanced_object_pass2.frag @@ -26,5 +26,5 @@ void main(void) float specmap = texture(SpecMap, uv).g; #endif col.xyz *= pow(color.xyz, vec3(2.2)); - FragColor = vec4(getLightFactor(col.xyz, vec3(specmap), 1.), 1.); + FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap), 1.); } diff --git a/data/shaders/instanced_objectpass_spheremap.frag b/data/shaders/instanced_objectpass_spheremap.frag index 50ce74fb6..21414ee31 100644 --- a/data/shaders/instanced_objectpass_spheremap.frag +++ b/data/shaders/instanced_objectpass_spheremap.frag @@ -30,5 +30,5 @@ void main() { vec4 detail0 = texture(tex, r.xy / m + .5); #endif - FragColor = vec4(getLightFactor(detail0.xyz, vec3(1.), 1.), 1.); + FragColor = vec4(getLightFactor(detail0.xyz, vec3(1.), 0.), 1.); } diff --git a/data/shaders/objectpass_spheremap.frag b/data/shaders/objectpass_spheremap.frag index 5e1400a3d..e5ed033d1 100644 --- a/data/shaders/objectpass_spheremap.frag +++ b/data/shaders/objectpass_spheremap.frag @@ -31,5 +31,5 @@ void main() { #endif #endif - FragColor = vec4(getLightFactor(detail0.xyz, vec3(1.), 1.), 1.); + FragColor = vec4(getLightFactor(detail0.xyz, vec3(1.), 0.), 1.); } diff --git a/data/shaders/utils/getLightFactor.frag b/data/shaders/utils/getLightFactor.frag index 8c04c7694..7d974d56d 100644 --- a/data/shaders/utils/getLightFactor.frag +++ b/data/shaders/utils/getLightFactor.frag @@ -14,6 +14,6 @@ vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapVa vec3 DiffuseComponent = texture(DiffuseMap, tc).xyz; vec3 SpecularComponent = texture(SpecularMap, tc).xyz; float ao = texture(SSAO, tc).x; - vec3 tmp = diffuseMatColor * DiffuseComponent + specularMatColor * SpecularComponent * specMapValue; + vec3 tmp = diffuseMatColor * DiffuseComponent * (1. - specMapValue) + specularMatColor * SpecularComponent * specMapValue; return tmp * ao; } \ No newline at end of file From 019db1a11d3ff19e1d931475c35387a58c74c459 Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Sun, 5 Oct 2014 21:56:04 +0200 Subject: [PATCH 21/30] Revert "Revert "Prepare shader for specmap value"" This reverts commit 780482edba2b0de3358f7e2139db3de3318f729e. --- data/shaders/detailledobject_pass2.frag | 5 ++-- data/shaders/grass_pass2.frag | 19 +++++++------- .../instanced_detailledobject_pass2.frag | 5 ++-- data/shaders/instanced_grass_pass2.frag | 26 ++++++++++--------- data/shaders/instanced_object_pass2.frag | 5 ++-- .../instanced_objectpass_spheremap.frag | 5 ++-- data/shaders/instanced_objectref_pass2.frag | 5 ++-- data/shaders/object_pass2.frag | 5 ++-- data/shaders/objectpass_spheremap.frag | 5 ++-- data/shaders/objectref_pass2.frag | 5 ++-- data/shaders/splatting.frag | 5 ++-- data/shaders/utils/getLightFactor.frag | 4 +-- 12 files changed, 44 insertions(+), 50 deletions(-) diff --git a/data/shaders/detailledobject_pass2.frag b/data/shaders/detailledobject_pass2.frag index a426b6935..832a68f70 100644 --- a/data/shaders/detailledobject_pass2.frag +++ b/data/shaders/detailledobject_pass2.frag @@ -16,7 +16,7 @@ varying vec2 uv_bis; #define FragColor gl_FragColor #endif -vec3 getLightFactor(float specMapValue); +vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue); void main(void) { @@ -28,6 +28,5 @@ void main(void) #endif vec4 detail = texture(Detail, uv_bis); color *= detail; - vec3 LightFactor = getLightFactor(1. - color.a); - FragColor = vec4(color.xyz * LightFactor, 1.); + FragColor = vec4(getLightFactor(color.xyz, vec3(1.), 1.), 1.); } diff --git a/data/shaders/grass_pass2.frag b/data/shaders/grass_pass2.frag index 408e78365..10d747e1b 100644 --- a/data/shaders/grass_pass2.frag +++ b/data/shaders/grass_pass2.frag @@ -12,10 +12,18 @@ in vec3 nor; in vec2 uv; out vec4 FragColor; -vec3 getLightFactor(float specMapValue); +vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue); void main(void) { + vec4 color = texture(Albedo, uv); +#ifdef GL_ARB_bindless_texture +#ifdef SRGBBindlessFix + color.xyz = pow(color.xyz, vec3(2.2)); +#endif +#endif + if (color.a < 0.5) discard; + vec2 texc = gl_FragCoord.xy / screen; float z = texture(dtex, texc).x; @@ -31,13 +39,6 @@ void main(void) float fLdotNBack = max(0., - dot(nor, SunDir) * 0.6 + 0.4); float scattering = mix(fPowEdotL, fLdotNBack, .5); - vec4 color = texture(Albedo, uv); -#ifdef GL_ARB_bindless_texture -#ifdef SRGBBindlessFix - color.xyz = pow(color.xyz, vec3(2.2)); -#endif -#endif - if (color.a < 0.5) discard; - vec3 LightFactor = (scattering * 0.3) + getLightFactor(1.); + vec3 LightFactor = color.xyz * (scattering * 0.3) + getLightFactor(color.xyz, vec3(1.), 1.); FragColor = vec4(color.xyz * LightFactor, 1.); } diff --git a/data/shaders/instanced_detailledobject_pass2.frag b/data/shaders/instanced_detailledobject_pass2.frag index c631fe3ef..44790f61c 100644 --- a/data/shaders/instanced_detailledobject_pass2.frag +++ b/data/shaders/instanced_detailledobject_pass2.frag @@ -11,7 +11,7 @@ in vec2 uv; in vec2 uv_bis; out vec4 FragColor; -vec3 getLightFactor(float specMapValue); +vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue); void main(void) { @@ -26,6 +26,5 @@ void main(void) vec4 detail = texture(Detail, uv_bis); #endif color *= detail; - vec3 LightFactor = getLightFactor(1. - color.a); - FragColor = vec4(color.xyz * LightFactor, 1.); + FragColor = vec4(getLightFactor(color.xyz, vec3(1.), 1.), 1.); } diff --git a/data/shaders/instanced_grass_pass2.frag b/data/shaders/instanced_grass_pass2.frag index b297a4c88..fd48f1012 100644 --- a/data/shaders/instanced_grass_pass2.frag +++ b/data/shaders/instanced_grass_pass2.frag @@ -14,10 +14,20 @@ in vec3 nor; in vec2 uv; out vec4 FragColor; -vec3 getLightFactor(float specMapValue); +vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue); void main(void) { +#ifdef GL_ARB_bindless_texture + vec4 color = texture(handle, uv); +#ifdef SRGBBindlessFix + color.xyz = pow(color.xyz, vec3(2.2)); +#endif +#else + vec4 color = texture(Albedo, uv); +#endif + if (color.a < 0.5) discard; + vec2 texc = gl_FragCoord.xy / screen; float z = texture(dtex, texc).x; @@ -33,15 +43,7 @@ void main(void) float fLdotNBack = max(0., - dot(nor, SunDir) * 0.6 + 0.4); float scattering = mix(fPowEdotL, fLdotNBack, .5); -#ifdef GL_ARB_bindless_texture - vec4 color = texture(handle, uv); -#ifdef SRGBBindlessFix - color.xyz = pow(color.xyz, vec3(2.2)); -#endif -#else - vec4 color = texture(Albedo, uv); -#endif - if (color.a < 0.5) discard; - vec3 LightFactor = (scattering * 0.3) + getLightFactor(1.); - FragColor = vec4(color.xyz * LightFactor, 1.); + + vec3 LightFactor = color.xyz * (scattering * 0.3) + getLightFactor(color.xyz, vec3(1.), 1.); + FragColor = vec4(LightFactor, 1.); } diff --git a/data/shaders/instanced_object_pass2.frag b/data/shaders/instanced_object_pass2.frag index 76176ba37..feebe72f2 100644 --- a/data/shaders/instanced_object_pass2.frag +++ b/data/shaders/instanced_object_pass2.frag @@ -9,7 +9,7 @@ in vec2 uv; in vec4 color; out vec4 FragColor; -vec3 getLightFactor(float specMapValue); +vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue); void main(void) { @@ -22,6 +22,5 @@ void main(void) vec4 col = texture(Albedo, uv); #endif col.xyz *= pow(color.xyz, vec3(2.2)); - vec3 LightFactor = getLightFactor(1.); - FragColor = vec4(col.xyz * LightFactor, 1.); + FragColor = vec4(getLightFactor(col.xyz, vec3(1.), 1.), 1.); } diff --git a/data/shaders/instanced_objectpass_spheremap.frag b/data/shaders/instanced_objectpass_spheremap.frag index 5365dd7ef..50ce74fb6 100644 --- a/data/shaders/instanced_objectpass_spheremap.frag +++ b/data/shaders/instanced_objectpass_spheremap.frag @@ -12,7 +12,7 @@ out vec4 FragColor; vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix); -vec3 getLightFactor(float specMapValue); +vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue); void main() { vec3 texc = gl_FragCoord.xyz / vec3(screen, 1.); @@ -29,7 +29,6 @@ void main() { #else vec4 detail0 = texture(tex, r.xy / m + .5); #endif - vec3 LightFactor = getLightFactor(1.); - FragColor = vec4(detail0.xyz * LightFactor, 1.); + FragColor = vec4(getLightFactor(detail0.xyz, vec3(1.), 1.), 1.); } diff --git a/data/shaders/instanced_objectref_pass2.frag b/data/shaders/instanced_objectref_pass2.frag index 201f610a1..045706254 100644 --- a/data/shaders/instanced_objectref_pass2.frag +++ b/data/shaders/instanced_objectref_pass2.frag @@ -9,7 +9,7 @@ in vec2 uv; in vec4 color; out vec4 FragColor; -vec3 getLightFactor(float specMapValue); +vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue); void main(void) { @@ -23,6 +23,5 @@ void main(void) #endif col.xyz *= pow(color.xyz, vec3(2.2)); if (col.a * color.a < 0.5) discard; - vec3 LightFactor = getLightFactor(1.); - FragColor = vec4(col.xyz * LightFactor, 1.); + FragColor = vec4(getLightFactor(col.xyz, vec3(1.), 1.), 1.); } diff --git a/data/shaders/object_pass2.frag b/data/shaders/object_pass2.frag index 047f0a192..53341f689 100644 --- a/data/shaders/object_pass2.frag +++ b/data/shaders/object_pass2.frag @@ -8,7 +8,7 @@ in vec2 uv; in vec4 color; out vec4 FragColor; -vec3 getLightFactor(float specMapValue); +vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue); void main(void) { @@ -21,6 +21,5 @@ void main(void) vec4 col = texture(Albedo, uv); #endif col.xyz *= pow(color.xyz, vec3(2.2)); - vec3 LightFactor = getLightFactor(1.); - FragColor = vec4(col.xyz * LightFactor, 1.); + FragColor = vec4(getLightFactor(color.xyz, vec3(1.), 1.), 1.); } diff --git a/data/shaders/objectpass_spheremap.frag b/data/shaders/objectpass_spheremap.frag index 8e4e0f4fc..5e1400a3d 100644 --- a/data/shaders/objectpass_spheremap.frag +++ b/data/shaders/objectpass_spheremap.frag @@ -15,7 +15,7 @@ varying vec3 nor; #endif vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix); -vec3 getLightFactor(float specMapValue); +vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue); void main() { vec3 texc = gl_FragCoord.xyz / vec3(screen, 1.); @@ -30,7 +30,6 @@ void main() { detail0.xyz = pow(detail0.xyz, vec3(2.2)); #endif #endif - vec3 LightFactor = getLightFactor(1.); - FragColor = vec4(detail0.xyz * LightFactor, 1.); + FragColor = vec4(getLightFactor(detail0.xyz, vec3(1.), 1.), 1.); } diff --git a/data/shaders/objectref_pass2.frag b/data/shaders/objectref_pass2.frag index 13ff676f8..d6b2d1f1c 100644 --- a/data/shaders/objectref_pass2.frag +++ b/data/shaders/objectref_pass2.frag @@ -8,7 +8,7 @@ in vec2 uv; in vec4 color; out vec4 FragColor; -vec3 getLightFactor(float specMapValue); +vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue); void main(void) { @@ -20,6 +20,5 @@ void main(void) #endif col.xyz *= pow(color.xyz, vec3(2.2)); if (col.a * color.a < 0.5) discard; - vec3 LightFactor = getLightFactor(1.); - FragColor = vec4(col.xyz * LightFactor, 1.); + FragColor = vec4(getLightFactor(color.xyz, vec3(1.), 1.), 1.); } diff --git a/data/shaders/splatting.frag b/data/shaders/splatting.frag index d302908d2..3641c8d40 100644 --- a/data/shaders/splatting.frag +++ b/data/shaders/splatting.frag @@ -22,7 +22,7 @@ varying vec2 uv_bis; #define FragColor gl_FragColor #endif -vec3 getLightFactor(float specMapValue); +vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue); void main() { // Splatting part @@ -46,6 +46,5 @@ void main() { splatting.b * detail2 + max(0., (1.0 - splatting.r - splatting.g - splatting.b)) * detail3; - vec3 LightFactor = getLightFactor(1.); - FragColor = vec4(splatted.xyz * LightFactor, 1.); + FragColor = vec4(getLightFactor(splatted.xyz, vec3(1.), 1.), 1.); } diff --git a/data/shaders/utils/getLightFactor.frag b/data/shaders/utils/getLightFactor.frag index 9bf4cdf58..8c04c7694 100644 --- a/data/shaders/utils/getLightFactor.frag +++ b/data/shaders/utils/getLightFactor.frag @@ -8,12 +8,12 @@ uniform sampler2D SpecularMap; uniform sampler2D SSAO; #endif -vec3 getLightFactor(float specMapValue) +vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue) { vec2 tc = gl_FragCoord.xy / screen; vec3 DiffuseComponent = texture(DiffuseMap, tc).xyz; vec3 SpecularComponent = texture(SpecularMap, tc).xyz; float ao = texture(SSAO, tc).x; - vec3 tmp = DiffuseComponent + SpecularComponent * specMapValue; + vec3 tmp = diffuseMatColor * DiffuseComponent + specularMatColor * SpecularComponent * specMapValue; return tmp * ao; } \ No newline at end of file From 4bb73e0573ea9bea3cf867d2e817ac765268f949 Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Sun, 5 Oct 2014 22:23:10 +0200 Subject: [PATCH 22/30] Fix godray opacity --- src/graphics/post_processing.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/graphics/post_processing.cpp b/src/graphics/post_processing.cpp index dee6b68a4..d4370bb8b 100644 --- a/src/graphics/post_processing.cpp +++ b/src/graphics/post_processing.cpp @@ -662,7 +662,8 @@ FrameBuffer *PostProcessing::render(scene::ICameraSceneNode * const camnode, boo // Blend glEnable(GL_BLEND); - glBlendFunc(GL_ONE, GL_ONE); + glBlendColor(0., 0., 0., track->getGodRaysOpacity()); + glBlendFunc(GL_CONSTANT_ALPHA, GL_ONE); glBlendEquation(GL_FUNC_ADD); in_fbo->Bind(); From 44792a1490d529ef63d300e7237628f4e8a04b27 Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Sun, 5 Oct 2014 22:46:02 +0200 Subject: [PATCH 23/30] Fix splatting --- data/shaders/splatting.frag | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/shaders/splatting.frag b/data/shaders/splatting.frag index 3641c8d40..acc6fabc3 100644 --- a/data/shaders/splatting.frag +++ b/data/shaders/splatting.frag @@ -46,5 +46,5 @@ void main() { splatting.b * detail2 + max(0., (1.0 - splatting.r - splatting.g - splatting.b)) * detail3; - FragColor = vec4(getLightFactor(splatted.xyz, vec3(1.), 1.), 1.); + FragColor = vec4(getLightFactor(splatted.xyz, vec3(1.), 0.), 1.); } From 6f5b7aa4ae0e9e55b418f0aaf0c01b73944a17b8 Mon Sep 17 00:00:00 2001 From: hiker Date: Mon, 6 Oct 2014 07:48:15 +1100 Subject: [PATCH 24/30] Tried a different layout for the checkboxes (sorry, but I didn't like the previous approach at all). Only disadvantage now (I can think of) is that the width of the lables is now hard coded to 40% of the screen. --- data/gui/user_screen.stkgui | 16 ++++++---------- data/gui/user_screen_tab.stkgui | 16 +++++++--------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/data/gui/user_screen.stkgui b/data/gui/user_screen.stkgui index 0a7d83e31..a9c54f543 100644 --- a/data/gui/user_screen.stkgui +++ b/data/gui/user_screen.stkgui @@ -15,25 +15,23 @@
- - -
- - -
-
@@ -56,8 +54,6 @@ I18N="Login dialog" text="Add user" label_location="bottom"/> -
-
- - -