1
0
forked from 0ad/0ad

Shadow map quality option.

Differential Revision: https://code.wildfiregames.com/D745
Fixes #4351
Refs #743
Patch By: Vladislav
This was SVN commit r20001.
This commit is contained in:
elexis 2017-08-19 12:46:05 +00:00
parent 661284a403
commit 8df36bace4
4 changed files with 50 additions and 4 deletions

View File

@ -69,6 +69,8 @@ waterreflection = true
shadowsonwater = false
shadows = true
shadowquality = 0 ; Shadow map resolution. (-2 - Very Low, -1 - Low, 0 - Medium, 1 - High, 2 - Very High)
; High values can crash the game when using a graphics card with low memory!
shadowpcf = true
vsync = false
particles = true

View File

@ -161,7 +161,22 @@
"label": "Shadows",
"tooltip": "Enable shadows",
"parameters": { "config": "shadows", "renderer": "Shadows" },
"dependencies": [ "shadowpcf" ]
"dependencies": [ "shadowquality", "shadowpcf" ]
},
{
"type": "dropdown",
"label": "Shadow Quality",
"tooltip": "Shadow map resolution. High values can crash the game when using a graphics card with low memory! REQUIRES GAME RESTART",
"parameters": {
"config": "shadowquality",
"list": [
{ "value": -2, "label": "Very Low" },
{ "value": -1, "label": "Low" },
{ "value": 0, "label": "Medium" },
{ "value": 1, "label": "High" },
{ "value": 2, "label": "Very High" }
]
}
},
{
"type": "boolean",

View File

@ -35,7 +35,7 @@
<object style="ModernLabelText" type="text" size="0 5 100% 25">
<translatableAttribute id="caption">Graphics Settings</translatableAttribute>
</object>
<repeat count="21">
<repeat count="22">
<object name="graphicsSetting[n]" size="0 25 100% 50" hidden="true">
<object name="graphicsSettingLabel[n]" size="0 0 65% 100%" type="text" style="ModernLeftLabelText"/>
<object name="graphicsSettingTickbox[n]" size="90% 5 100% 100%+5" type="checkbox" style="ModernTickBox" hidden="true"/>

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2013 Wildfire Games.
/* Copyright (C) 2017 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -25,6 +25,7 @@
#include "lib/bits.h"
#include "lib/ogl.h"
#include "ps/CLogger.h"
#include "ps/ConfigDB.h"
#include "ps/Profile.h"
#include "graphics/LightEnv.h"
@ -55,6 +56,8 @@ struct ShadowMapInternals
GLuint Texture;
// width, height of shadow map
int Width, Height;
// Shadow map quality (-2 - Very Low, -1 - Low, 0 - Medium, 1 - High, 2 - Very High)
int QualityLevel;
// used width, height of shadow map
int EffectiveWidth, EffectiveHeight;
// transform light space into projected light space
@ -107,6 +110,7 @@ ShadowMap::ShadowMap()
m->DummyTexture = 0;
m->Width = 0;
m->Height = 0;
m->QualityLevel = 0;
m->EffectiveWidth = 0;
m->EffectiveHeight = 0;
m->DepthTextureBits = 0;
@ -385,8 +389,33 @@ void ShadowMapInternals::CreateTexture()
}
else
{
CFG_GET_VAL("shadowquality", QualityLevel);
// get shadow map size as next power of two up from view width/height
Width = Height = (int)round_up_to_pow2((unsigned)std::max(g_Renderer.GetWidth(), g_Renderer.GetHeight()));
int shadow_map_size = (int)round_up_to_pow2((unsigned)std::max(g_Renderer.GetWidth(), g_Renderer.GetHeight()));
switch (QualityLevel)
{
// Very Low
case -2:
shadow_map_size /= 4;
break;
// Low
case -1:
shadow_map_size /= 2;
break;
// High
case 1:
shadow_map_size *= 2;
break;
// Ultra
case 2:
shadow_map_size *= 4;
break;
// Medium as is
default:
break;
}
Width = Height = shadow_map_size;
}
// Clamp to the maximum texture size
Width = std::min(Width, (int)ogl_max_tex_size);