From 416ccaae4b04215bb4f301b2197a0e99a9aa1471 Mon Sep 17 00:00:00 2001 From: Titus Tscharntke Date: Sun, 22 Sep 2013 00:51:47 +0000 Subject: [PATCH] Shadow intensity can be set in video options. Tilesets can set their own default shadow intensity with . ShadowAlpha is beeing removed form ini files --- mk/linux/glest.ini | 1 - source/glest_game/graphics/renderer.cpp | 10 +++++-- source/glest_game/graphics/renderer.h | 2 +- .../menu/menu_state_options_graphics.cpp | 30 ++++++++++++++++++- .../menu/menu_state_options_graphics.h | 3 ++ source/glest_game/world/tileset.cpp | 8 +++++ source/glest_game/world/tileset.h | 4 +++ 7 files changed, 52 insertions(+), 6 deletions(-) diff --git a/mk/linux/glest.ini b/mk/linux/glest.ini index 893f65d3..672e955a 100644 --- a/mk/linux/glest.ini +++ b/mk/linux/glest.ini @@ -69,7 +69,6 @@ RefreshFrequency=75 ScreenHeight=600 ScreenWidth=800 ServerIp=192.168.0.107 -ShadowAlpha=0.2 ShadowFrameSkip=2 ShadowTextureSize=512 Shadows=Projected diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index dad7c359..32ccc634 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -168,7 +168,7 @@ Renderer::Renderer() : BaseRenderer() { //assert(0==1); Renderer::rendererEnded = false; - shadowAlpha = 0; + shadowIntensity = 0; shadowFrameSkip = 0; triangleCount = 0; smoothedRenderFps = 0; @@ -6957,7 +6957,11 @@ void Renderer::renderShadowsToTexture(const int renderFps){ glClear(GL_DEPTH_BUFFER_BIT); } else { - float color= 1.0f-shadowAlpha; + float shadowIntensityToSet=shadowIntensity*game->getWorld()->getTileset()->getShadowIntense(); + if(shadowIntensityToSet > 1.0f){ + shadowIntensityToSet=1.0f; + } + float color= 1.0f-shadowIntensityToSet; glColor3f(color, color, color); glClearColor(1.f, 1.f, 1.f, 1.f); glDisable(GL_DEPTH_TEST); @@ -7256,7 +7260,7 @@ void Renderer::loadConfig() { if(shadows==sProjected || shadows==sShadowMapping){ shadowTextureSize= config.getInt("ShadowTextureSize"); shadowFrameSkip= config.getInt("ShadowFrameSkip"); - shadowAlpha= config.getFloat("ShadowAlpha"); + shadowIntensity= config.getFloat("ShadowIntensity","1.0"); } //load filter settings diff --git a/source/glest_game/graphics/renderer.h b/source/glest_game/graphics/renderer.h index 8b442b5b..c53240de 100644 --- a/source/glest_game/graphics/renderer.h +++ b/source/glest_game/graphics/renderer.h @@ -248,7 +248,7 @@ private: bool photoMode; int shadowTextureSize; int shadowFrameSkip; - float shadowAlpha; + float shadowIntensity; bool focusArrows; bool textures3D; Shadows shadows; diff --git a/source/glest_game/menu/menu_state_options_graphics.cpp b/source/glest_game/menu/menu_state_options_graphics.cpp index 49a2ecfd..b9f43e89 100644 --- a/source/glest_game/menu/menu_state_options_graphics.cpp +++ b/source/glest_game/menu/menu_state_options_graphics.cpp @@ -151,7 +151,7 @@ MenuStateOptionsGraphics::MenuStateOptionsGraphics(Program *program, MainMenu *m } float gammaValue=config.getFloat("GammaValue","1.0"); if(gammaValue==0.0f) gammaValue=1.0f; - listBoxGammaCorrection.setSelectedItem(floatToStr(gammaValue)); + listBoxGammaCorrection.setSelectedItem(floatToStr(gammaValue),false); currentLine-=lineOffset; @@ -215,6 +215,22 @@ MenuStateOptionsGraphics::MenuStateOptionsGraphics(Program *program, MainMenu *m listBoxShadowTextureSize.setSelectedItem(intToStr(config.getInt("ShadowTextureSize","512")),false); currentLine-=lineOffset; + //shadows + labelShadowIntensity.registerGraphicComponent(containerName,"labelShadowIntensity"); + labelShadowIntensity.init(currentLabelStart, currentLine); + labelShadowIntensity.setText(lang.get("ShadowIntensity")); + + listBoxShadowIntensity.registerGraphicComponent(containerName,"listBoxShadowIntensity"); + listBoxShadowIntensity.init(currentColumnStart, currentLine, 200); + for (float f=0.5f;f<3.0f;f=f+0.1f) { + listBoxShadowIntensity.pushBackItem(floatToStr(f)); + } + float shadowIntensity=config.getFloat("ShadowIntensity","1.0"); + if(shadowIntensity<=0.0f) shadowIntensity=1.0f; + listBoxShadowIntensity.setSelectedItem(floatToStr(shadowIntensity),false); + + currentLine-=lineOffset; + //textures 3d labelTextures3D.registerGraphicComponent(containerName,"labelTextures3D"); labelTextures3D.init(currentLabelStart, currentLine); @@ -399,6 +415,13 @@ void MenuStateOptionsGraphics::reloadUI() { listBoxGammaCorrection.setItems(listboxData); + listboxData.clear(); + for (float f=0.5;f<3.0f;f=f+0.1f) { + listboxData.push_back(floatToStr(f)); + } + listBoxShadowIntensity.setItems(listboxData); + + labelShadows.setText(lang.get("Shadows")); labelShadowTextureSize.setText(lang.get("ShadowTextureSize")); @@ -661,6 +684,7 @@ void MenuStateOptionsGraphics::mouseClick(int x, int y, MouseButton mouseButton) listBoxShadows.mouseClick(x, y); listBoxAnimatedTilesetObjects.mouseClick(x, y); listBoxShadowTextureSize.mouseClick(x, y); + listBoxShadowIntensity.mouseClick(x, y); listBoxFilter.mouseClick(x, y); if(listBoxGammaCorrection.mouseClick(x, y)){ float gammaValue=strToFloat(listBoxGammaCorrection.getSelectedItem()); @@ -700,6 +724,7 @@ void MenuStateOptionsGraphics::mouseMove(int x, int y, const MouseState *ms){ buttonVideoInfo.mouseMove(x, y); listBoxFilter.mouseMove(x, y); listBoxGammaCorrection.mouseMove(x, y); + listBoxShadowIntensity.mouseMove(x, y); listBoxSelectionType.mouseMove(x, y); listBoxShadows.mouseMove(x, y); checkBoxTextures3D.mouseMove(x, y); @@ -775,6 +800,7 @@ void MenuStateOptionsGraphics::render(){ renderer.renderListBox(&listBoxLights); renderer.renderListBox(&listBoxFilter); renderer.renderListBox(&listBoxGammaCorrection); + renderer.renderListBox(&listBoxShadowIntensity); renderer.renderLabel(&labelShadows); renderer.renderLabel(&labelTextures3D); renderer.renderLabel(&labelUnitParticles); @@ -785,6 +811,7 @@ void MenuStateOptionsGraphics::render(){ renderer.renderLabel(&labelLights); renderer.renderLabel(&labelFilter); renderer.renderLabel(&labelGammaCorrection); + renderer.renderLabel(&labelShadowIntensity); renderer.renderLabel(&labelScreenModes); renderer.renderListBox(&listBoxScreenModes); renderer.renderLabel(&labelFullscreenWindowed); @@ -837,6 +864,7 @@ void MenuStateOptionsGraphics::saveConfig(){ config.setBool("Windowed", checkBoxFullscreenWindowed.getValue()); config.setString("Filter", listBoxFilter.getSelectedItem()); config.setFloat("GammaValue", strToFloat(listBoxGammaCorrection.getSelectedItem())); + config.setFloat("ShadowIntensity", strToFloat(listBoxShadowIntensity.getSelectedItem())); config.setBool("Textures3D", checkBoxTextures3D.getValue()); config.setBool("UnitParticles", (checkBoxUnitParticles.getValue())); config.setBool("TilesetParticles", (checkBoxTilesetParticles.getValue())); diff --git a/source/glest_game/menu/menu_state_options_graphics.h b/source/glest_game/menu/menu_state_options_graphics.h index 285c7224..48d701e0 100644 --- a/source/glest_game/menu/menu_state_options_graphics.h +++ b/source/glest_game/menu/menu_state_options_graphics.h @@ -77,6 +77,9 @@ private: GraphicLabel labelGammaCorrection; GraphicListBox listBoxGammaCorrection; + GraphicLabel labelShadowIntensity; + GraphicListBox listBoxShadowIntensity; + GraphicLabel labelShadowTextureSize; GraphicListBox listBoxShadowTextureSize; diff --git a/source/glest_game/world/tileset.cpp b/source/glest_game/world/tileset.cpp index ea1f4850..43926a46 100644 --- a/source/glest_game/world/tileset.cpp +++ b/source/glest_game/world/tileset.cpp @@ -30,6 +30,7 @@ using namespace Shared::Graphics; namespace Glest{ namespace Game{ const float Tileset::standardAirHeight= 5.0f; +const float Tileset::standardShadowIntensity= 0.2f; // ===================================================== // class AmbientSounds // ===================================================== @@ -421,6 +422,13 @@ void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetCheck moonLightColor.y= moonLightColorNode->getAttribute("green")->getFloatValue(); moonLightColor.z= moonLightColorNode->getAttribute("blue")->getFloatValue(); + if(parametersNode->hasChild("shadow-intensity")) { + const XmlNode *shadowIntenseNode= parametersNode->getChild("shadow-intensity"); + shadowIntensity= shadowIntenseNode->getAttribute("value")->getFloatValue(); + } else { + shadowIntensity=standardShadowIntensity; + } + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); //weather diff --git a/source/glest_game/world/tileset.h b/source/glest_game/world/tileset.h index 96dd6f2d..73680f5e 100644 --- a/source/glest_game/world/tileset.h +++ b/source/glest_game/world/tileset.h @@ -121,6 +121,7 @@ public: static const int objCount= 10; static const int transitionVars= 2; //number or different transition textures static const float standardAirHeight; + static const float standardShadowIntensity; public: typedef vector SurfProbs; @@ -145,6 +146,7 @@ private: Vec3f fogColor; Vec3f sunLightColor; Vec3f moonLightColor; + float shadowIntensity; Weather weather; float airHeight; @@ -162,6 +164,7 @@ public: fogDensity = 0.0f; weather= wSunny; airHeight= standardAirHeight; + shadowIntensity= standardShadowIntensity; for(int index = 0; index < surfCount; ++index) { partsArray[index] = 0; @@ -187,6 +190,7 @@ public: const Vec3f &getFogColor() const {return fogColor;} const Vec3f &getSunLightColor() const {return sunLightColor;} const Vec3f &getMoonLightColor() const {return moonLightColor;} + float getShadowIntense()const {return shadowIntensity;} Weather getWeather() const {return weather;} void setWeather(Weather value) { weather = value; }