Shadow intensity can be set in video options.

Tilesets can set their own default shadow intensity with <shadow-intensity value="0.3"/>.
ShadowAlpha is beeing removed form ini files
This commit is contained in:
Titus Tscharntke 2013-09-22 00:51:47 +00:00
parent 836e61d5d6
commit 416ccaae4b
7 changed files with 52 additions and 6 deletions

View File

@ -69,7 +69,6 @@ RefreshFrequency=75
ScreenHeight=600
ScreenWidth=800
ServerIp=192.168.0.107
ShadowAlpha=0.2
ShadowFrameSkip=2
ShadowTextureSize=512
Shadows=Projected

View File

@ -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

View File

@ -248,7 +248,7 @@ private:
bool photoMode;
int shadowTextureSize;
int shadowFrameSkip;
float shadowAlpha;
float shadowIntensity;
bool focusArrows;
bool textures3D;
Shadows shadows;

View File

@ -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()));

View File

@ -77,6 +77,9 @@ private:
GraphicLabel labelGammaCorrection;
GraphicListBox listBoxGammaCorrection;
GraphicLabel labelShadowIntensity;
GraphicListBox listBoxShadowIntensity;
GraphicLabel labelShadowTextureSize;
GraphicListBox listBoxShadowTextureSize;

View File

@ -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

View File

@ -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<float> 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; }