Allow to reduce shadow resolution
This commit is contained in:
parent
cf3e79484c
commit
019ec344fe
@ -6,6 +6,7 @@ uniform float split0;
|
||||
uniform float split1;
|
||||
uniform float split2;
|
||||
uniform float splitmax;
|
||||
uniform float shadow_res;
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 Diff;
|
||||
@ -29,7 +30,7 @@ float getShadowFactor(vec3 pos, int index)
|
||||
for (float i = -1.; i <= 1.; i += 1.)
|
||||
{
|
||||
for (float j = -1.; j <= 1.; j += 1.)
|
||||
result += texture(shadowtex, vec4(shadowtexcoord + vec2(i,j) / 1024., float(index), d));
|
||||
result += texture(shadowtex, vec4(shadowtexcoord + vec2(i,j) / shadow_res, float(index), d));
|
||||
}
|
||||
|
||||
return result / 9.;
|
||||
|
@ -640,10 +640,10 @@ namespace UserConfigParams
|
||||
PARAM_DEFAULT(BoolUserConfigParam(false,
|
||||
"ssao", &m_graphics_quality,
|
||||
"Enable Screen Space Ambient Occlusion") );
|
||||
PARAM_PREFIX IntUserConfigParam m_shadows
|
||||
PARAM_PREFIX IntUserConfigParam m_shadows_resolution
|
||||
PARAM_DEFAULT( IntUserConfigParam(0,
|
||||
"shadows", &m_graphics_quality,
|
||||
"Whether shadows are enabled (0 = disabled, 1 = low, 2 = high") );
|
||||
"shadows_resoltion", &m_graphics_quality,
|
||||
"Shadow resolution (0 = disabled") );
|
||||
|
||||
// ---- Misc
|
||||
PARAM_PREFIX BoolUserConfigParam m_cache_overworld
|
||||
|
@ -272,7 +272,7 @@ bool CentralVideoSettings::supportsComputeShadersFiltering() const
|
||||
|
||||
bool CentralVideoSettings::isShadowEnabled() const
|
||||
{
|
||||
return supportsShadows() && UserConfigParams::m_shadows;
|
||||
return supportsShadows() && (UserConfigParams::m_shadows_resolution > 0);
|
||||
}
|
||||
|
||||
bool CentralVideoSettings::isGlobalIlluminationEnabled() const
|
||||
|
@ -349,7 +349,7 @@ void IrrDriver::renderScene(scene::ICameraSceneNode * const camnode, unsigned po
|
||||
// To avoid wrong culling, use the largest view possible
|
||||
m_scene_manager->setActiveCamera(m_suncam);
|
||||
if (UserConfigParams::m_dynamic_lights &&
|
||||
UserConfigParams::m_shadows && CVS->isShadowEnabled() && hasShadow)
|
||||
CVS->isShadowEnabled() && hasShadow)
|
||||
{
|
||||
PROFILER_PUSH_CPU_MARKER("- Shadow", 0x30, 0x6F, 0x90);
|
||||
renderShadows();
|
||||
|
@ -132,7 +132,7 @@ extern float shadowSplit[5];
|
||||
void IrrDriver::renderLights(unsigned pointlightcount, bool hasShadow)
|
||||
{
|
||||
//RH
|
||||
if (UserConfigParams::m_gi && UserConfigParams::m_shadows && hasShadow)
|
||||
if (CVS->isGlobalIlluminationEnabled() && hasShadow)
|
||||
{
|
||||
ScopedGPUTimer timer(irr_driver->getGPUTimer(Q_RH));
|
||||
glDisable(GL_BLEND);
|
||||
@ -195,12 +195,12 @@ void IrrDriver::renderLights(unsigned pointlightcount, bool hasShadow)
|
||||
if (CVS->isESMEnabled())
|
||||
{
|
||||
FullScreenShader::ShadowedSunLightShaderESM::getInstance()->SetTextureUnits(irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), irr_driver->getDepthStencilTexture(), m_rtts->getShadowFBO().getRTT()[0]);
|
||||
DrawFullScreenEffect<FullScreenShader::ShadowedSunLightShaderESM>(shadowSplit[1], shadowSplit[2], shadowSplit[3], shadowSplit[4], irr_driver->getSunDirection(), irr_driver->getSunColor());
|
||||
DrawFullScreenEffect<FullScreenShader::ShadowedSunLightShaderESM>(shadowSplit[1], shadowSplit[2], shadowSplit[3], shadowSplit[4]);
|
||||
}
|
||||
else
|
||||
{
|
||||
FullScreenShader::ShadowedSunLightShaderPCF::getInstance()->SetTextureUnits(irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), irr_driver->getDepthStencilTexture(), m_rtts->getShadowFBO().getDepthTexture());
|
||||
DrawFullScreenEffect<FullScreenShader::ShadowedSunLightShaderPCF>(shadowSplit[1], shadowSplit[2], shadowSplit[3], shadowSplit[4], irr_driver->getSunDirection(), irr_driver->getSunColor());
|
||||
DrawFullScreenEffect<FullScreenShader::ShadowedSunLightShaderPCF>(shadowSplit[1], shadowSplit[2], shadowSplit[3], shadowSplit[4], UserConfigParams::m_shadows_resolution);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -245,12 +245,12 @@ RTT::RTT(size_t width, size_t height)
|
||||
|
||||
if (CVS->isShadowEnabled())
|
||||
{
|
||||
shadowColorTex = generateRTT3D(GL_TEXTURE_2D_ARRAY, 1024, 1024, 4, GL_R32F, GL_RED, GL_FLOAT, 10);
|
||||
shadowDepthTex = generateRTT3D(GL_TEXTURE_2D_ARRAY, 1024, 1024, 4, GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, 1);
|
||||
shadowColorTex = generateRTT3D(GL_TEXTURE_2D_ARRAY, UserConfigParams::m_shadows_resolution, UserConfigParams::m_shadows_resolution, 4, GL_R32F, GL_RED, GL_FLOAT, 10);
|
||||
shadowDepthTex = generateRTT3D(GL_TEXTURE_2D_ARRAY, UserConfigParams::m_shadows_resolution, UserConfigParams::m_shadows_resolution, 4, GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, 1);
|
||||
|
||||
somevector.clear();
|
||||
somevector.push_back(shadowColorTex);
|
||||
m_shadow_FBO = new FrameBuffer(somevector, shadowDepthTex, 1024, 1024, true);
|
||||
m_shadow_FBO = new FrameBuffer(somevector, shadowDepthTex, UserConfigParams::m_shadows_resolution, UserConfigParams::m_shadows_resolution, true);
|
||||
}
|
||||
|
||||
if (CVS->isGlobalIlluminationEnabled())
|
||||
|
@ -1702,7 +1702,7 @@ namespace FullScreenShader
|
||||
|
||||
// Use 8 to circumvent a catalyst bug when binding sampler
|
||||
AssignSamplerNames(Program, 0, "ntex", 1, "dtex", 8, "shadowtex");
|
||||
AssignUniforms("split0", "split1", "split2", "splitmax", "direction", "col");
|
||||
AssignUniforms("split0", "split1", "split2", "splitmax", "shadow_res");
|
||||
}
|
||||
|
||||
ShadowedSunLightShaderESM::ShadowedSunLightShaderESM()
|
||||
@ -1718,7 +1718,7 @@ namespace FullScreenShader
|
||||
|
||||
// Use 8 to circumvent a catalyst bug when binding sampler
|
||||
AssignSamplerNames(Program, 0, "ntex", 1, "dtex", 8, "shadowtex");
|
||||
AssignUniforms("split0", "split1", "split2", "splitmax", "direction", "col");
|
||||
AssignUniforms("split0", "split1", "split2", "splitmax");
|
||||
}
|
||||
|
||||
RadianceHintsConstructionShader::RadianceHintsConstructionShader()
|
||||
|
@ -426,13 +426,13 @@ public:
|
||||
IBLShader();
|
||||
};
|
||||
|
||||
class ShadowedSunLightShaderPCF : public ShaderHelperSingleton<ShadowedSunLightShaderPCF, float, float, float, float, core::vector3df, video::SColorf>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Shadow_Sampler>
|
||||
class ShadowedSunLightShaderPCF : public ShaderHelperSingleton<ShadowedSunLightShaderPCF, float, float, float, float, float>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Shadow_Sampler>
|
||||
{
|
||||
public:
|
||||
ShadowedSunLightShaderPCF();
|
||||
};
|
||||
|
||||
class ShadowedSunLightShaderESM : public ShaderHelperSingleton<ShadowedSunLightShaderESM, float, float, float, float, core::vector3df, video::SColorf>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Trilinear_Clamped_Array2D>
|
||||
class ShadowedSunLightShaderESM : public ShaderHelperSingleton<ShadowedSunLightShaderESM, float, float, float, float>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Trilinear_Clamped_Array2D>
|
||||
{
|
||||
public:
|
||||
ShadowedSunLightShaderESM();
|
||||
|
@ -362,7 +362,7 @@ handleSTKCommon(scene::ISceneNode *Node, std::vector<scene::ISceneNode *> *Immed
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!UserConfigParams::m_shadows)
|
||||
if (!CVS->isShadowEnabled())
|
||||
return;
|
||||
for (unsigned cascade = 0; cascade < 4; ++cascade)
|
||||
{
|
||||
|
@ -86,7 +86,7 @@ void CustomVideoSettingsDialog::beforeAddingWidgets()
|
||||
shadows->addLabel(_("low")); // 1
|
||||
shadows->addLabel(_("high")); // 2
|
||||
if (CVS->supportsShadows())
|
||||
shadows->setValue(UserConfigParams::m_shadows);
|
||||
shadows->setValue(UserConfigParams::m_shadows_resolution / 512);
|
||||
else
|
||||
shadows->setValue(0);
|
||||
getWidget<CheckBoxWidget>("dynamiclight")->setState(UserConfigParams::m_dynamic_lights);
|
||||
@ -132,12 +132,12 @@ GUIEngine::EventPropagation CustomVideoSettingsDialog::processEvent(const std::s
|
||||
|
||||
if (advanced_pipeline && CVS->supportsShadows())
|
||||
{
|
||||
UserConfigParams::m_shadows =
|
||||
getWidget<SpinnerWidget>("shadows")->getValue();
|
||||
UserConfigParams::m_shadows_resolution =
|
||||
getWidget<SpinnerWidget>("shadows")->getValue() * 512;
|
||||
}
|
||||
else
|
||||
{
|
||||
UserConfigParams::m_shadows = 0;
|
||||
UserConfigParams::m_shadows_resolution = 0;
|
||||
}
|
||||
|
||||
UserConfigParams::m_mlaa =
|
||||
|
@ -371,7 +371,7 @@ void OptionsScreenVideo::updateGfxSlider()
|
||||
GFX_PRESETS[l].mlaa == UserConfigParams::m_mlaa &&
|
||||
GFX_PRESETS[l].motionblur == UserConfigParams::m_motionblur &&
|
||||
//GFX_PRESETS[l].shaders == UserConfigParams::m_pixel_shaders
|
||||
GFX_PRESETS[l].shadows == UserConfigParams::m_shadows &&
|
||||
GFX_PRESETS[l].shadows == UserConfigParams::m_shadows_resolution &&
|
||||
GFX_PRESETS[l].ssao == UserConfigParams::m_ssao &&
|
||||
GFX_PRESETS[l].weather == UserConfigParams::m_weather_effects &&
|
||||
GFX_PRESETS[l].dof == UserConfigParams::m_dof &&
|
||||
@ -443,7 +443,7 @@ void OptionsScreenVideo::updateTooltip()
|
||||
UserConfigParams::m_ssao ? enabled : disabled);
|
||||
//I18N: in graphical options
|
||||
tooltip = tooltip + L"\n" + _("Shadows: %s",
|
||||
UserConfigParams::m_shadows == 1 ? "low" : UserConfigParams::m_shadows == 2 ?
|
||||
UserConfigParams::m_shadows_resolution == 1 ? "low" : UserConfigParams::m_shadows_resolution == 2 ?
|
||||
"high" : disabled);
|
||||
//I18N: in graphical options
|
||||
tooltip = tooltip + L"\n" + _("Bloom : %s",
|
||||
@ -540,7 +540,7 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
|
||||
UserConfigParams::m_mlaa = GFX_PRESETS[level].mlaa;
|
||||
UserConfigParams::m_motionblur = GFX_PRESETS[level].motionblur;
|
||||
//UserConfigParams::m_pixel_shaders = GFX_PRESETS[level].shaders;
|
||||
UserConfigParams::m_shadows = GFX_PRESETS[level].shadows;
|
||||
UserConfigParams::m_shadows_resolution = GFX_PRESETS[level].shadows;
|
||||
UserConfigParams::m_ssao = GFX_PRESETS[level].ssao;
|
||||
UserConfigParams::m_weather_effects = GFX_PRESETS[level].weather;
|
||||
UserConfigParams::m_dof = GFX_PRESETS[level].dof;
|
||||
|
Loading…
Reference in New Issue
Block a user