Index: binaries/data/config/default.cfg =================================================================== --- binaries/data/config/default.cfg +++ binaries/data/config/default.cfg @@ -117,6 +117,10 @@ ; Use anti-aliasing techniques. antialiasing = "disabled" +; Use sharpening techniques. +sharpening = "disabled" +sharpness = 0.3 + ; Quality level of shader effects (set to 10 to display all effects) materialmgr.quality = 2.0 Index: binaries/data/mods/public/gui/options/options.json =================================================================== --- binaries/data/mods/public/gui/options/options.json +++ binaries/data/mods/public/gui/options/options.json @@ -130,6 +130,28 @@ "function": "Renderer_UpdateAntiAliasingTechnique" }, { + "type": "dropdown", + "label": "Sharpening", + "tooltip": "Reduce blurry effects.", + "dependencies": ["postproc"], + "config": "sharpening", + "list": [ + { "value": "disabled", "label": "Disabled", "tooltip": "Do not use sharpening." }, + { "value": "cas", "label": "CAS", "tooltip": "Contrast adaptive sharpening, a fast, contrast based sharpening pass." } + ], + "function": "Renderer_UpdateSharpeningTechnique" + }, + { + "type": "slider", + "label": "Sharpness factor", + "tooltip": "The sharpness of the choosen pass.", + "dependencies": ["postproc"], + "config": "sharpness", + "min": 0, + "max": 1, + "function": "Renderer_UpdateSharpnessFactor" + }, + { "type": "slider", "label": "Shader effects", "tooltip": "Number of shader effects. REQUIRES GAME RESTART", Index: binaries/data/mods/public/gui/options/options.xml =================================================================== --- binaries/data/mods/public/gui/options/options.xml +++ binaries/data/mods/public/gui/options/options.xml @@ -9,7 +9,7 @@ - + Game Options Index: source/ps/CStrInternStatic.h =================================================================== --- source/ps/CStrInternStatic.h +++ source/ps/CStrInternStatic.h @@ -135,6 +135,7 @@ X(shadowScale) X(shadowTex) X(shadowTransform) +X(sharpness) X(skinBlendMatrices) X2(skinBlendMatrices_0, "skinBlendMatrices[0]") X(skyBoxRot) Index: source/renderer/PostprocManager.h =================================================================== --- source/renderer/PostprocManager.h +++ source/renderer/PostprocManager.h @@ -50,6 +50,8 @@ // Triggers update of shaders and FBO if needed. void UpdateAntiAliasingTechnique(); + void UpdateSharpeningTechnique(); + void UpdateSharpnessFactor(); void SetDepthBufferClipPlanes(float nearPlane, float farPlane); @@ -91,6 +93,10 @@ CStrW m_PostProcEffect; CShaderTechniquePtr m_PostProcTech; + CStr m_SharpName; + CShaderTechniquePtr m_SharpTech; + float m_Sharpness; + CStr m_AAName; CShaderTechniquePtr m_AATech; Index: source/renderer/PostprocManager.cpp =================================================================== --- source/renderer/PostprocManager.cpp +++ source/renderer/PostprocManager.cpp @@ -81,6 +81,8 @@ m_Height = g_Renderer.GetHeight(); UpdateAntiAliasingTechnique(); + UpdateSharpeningTechnique(); + UpdateSharpnessFactor(); RecreateBuffers(); m_IsInitialized = true; @@ -428,6 +430,8 @@ shader->Uniform(str_zNear, m_NearPlane); shader->Uniform(str_zFar, m_FarPlane); + shader->Uniform(str_sharpness, m_Sharpness); + shader->Uniform(str_brightness, g_LightEnv.m_Brightness); shader->Uniform(str_hdr, g_LightEnv.m_Contrast); shader->Uniform(str_saturation, g_LightEnv.m_Saturation); @@ -504,6 +508,12 @@ ApplyEffect(m_AATech, pass); } + if (m_SharpTech) + { + for (int pass = 0; pass < m_SharpTech->GetNumPasses(); ++pass) + ApplyEffect(m_SharpTech, pass); + } + pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PongFbo); pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_DepthTex, 0); @@ -570,6 +580,29 @@ } } +void CPostprocManager::UpdateSharpeningTechnique() +{ + if (!g_RenderingOptions.GetPreferGLSL()) + return; + + CStr newSharpName; + CFG_GET_VAL("sharpening", newSharpName); + if (m_SharpName == newSharpName) + return; + m_SharpName = newSharpName; + m_SharpTech.reset(); + + if (m_SharpName == "cas") + { + m_SharpTech = g_Renderer.GetShaderManager().LoadEffect(CStrIntern(m_SharpName)); + } +} + +void CPostprocManager::UpdateSharpnessFactor() +{ + CFG_GET_VAL("sharpness", m_Sharpness); +} + void CPostprocManager::SetDepthBufferClipPlanes(float nearPlane, float farPlane) { m_NearPlane = nearPlane; @@ -633,6 +666,14 @@ { } +void CPostprocManager::UpdateSharpeningTechnique() +{ +} + +void CPostprocManager::UpdateSharpnessFactor() +{ +} + void CPostprocManager::CaptureRenderOutput() { } Index: source/renderer/scripting/JSInterface_Renderer.h =================================================================== --- source/renderer/scripting/JSInterface_Renderer.h +++ source/renderer/scripting/JSInterface_Renderer.h @@ -29,6 +29,8 @@ std::string GetRenderPath(ScriptInterface::CxPrivate* pCxPrivate); void SetRenderPath(ScriptInterface::CxPrivate* pCxPrivate, const std::string& name); void UpdateAntiAliasingTechnique(ScriptInterface::CxPrivate* pCxPrivate); + void UpdateSharpeningTechnique(ScriptInterface::CxPrivate* pCxPrivate); + void UpdateSharpnessFactor(ScriptInterface::CxPrivate* pCxPrivate); void RecreateShadowMap(ScriptInterface::CxPrivate* pCxPrivate); bool TextureExists(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& filename); Index: source/renderer/scripting/JSInterface_Renderer.cpp =================================================================== --- source/renderer/scripting/JSInterface_Renderer.cpp +++ source/renderer/scripting/JSInterface_Renderer.cpp @@ -72,6 +72,16 @@ g_Renderer.GetPostprocManager().UpdateAntiAliasingTechnique(); } +void JSI_Renderer::UpdateSharpeningTechnique(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) +{ + g_Renderer.GetPostprocManager().UpdateSharpeningTechnique(); +} + +void JSI_Renderer::UpdateSharpnessFactor(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) +{ + g_Renderer.GetPostprocManager().UpdateSharpnessFactor(); +} + void JSI_Renderer::RecreateShadowMap(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) { g_Renderer.GetShadowMap().RecreateTexture(); @@ -92,6 +102,8 @@ scriptInterface.RegisterFunction("Renderer_SetRenderPath"); scriptInterface.RegisterFunction("Renderer_RecreateShadowMap"); scriptInterface.RegisterFunction("Renderer_UpdateAntiAliasingTechnique"); + scriptInterface.RegisterFunction("Renderer_UpdateSharpeningTechnique"); + scriptInterface.RegisterFunction("Renderer_UpdateSharpnessFactor"); scriptInterface.RegisterFunction("TextureExists"); REGISTER_BOOLEAN_SCRIPT_SETTING(Shadows); REGISTER_BOOLEAN_SCRIPT_SETTING(ShadowPCF);