Changeset View
Changeset View
Standalone View
Standalone View
source/renderer/PostprocManager.cpp
Show All 29 Lines | |||||
#include "ps/Filesystem.h" | #include "ps/Filesystem.h" | ||||
#include "ps/Game.h" | #include "ps/Game.h" | ||||
#include "ps/World.h" | #include "ps/World.h" | ||||
#include "renderer/Renderer.h" | #include "renderer/Renderer.h" | ||||
#include "renderer/RenderingOptions.h" | #include "renderer/RenderingOptions.h" | ||||
#if !CONFIG2_GLES | #if !CONFIG2_GLES | ||||
CPostprocManager::CPostprocManager() | CPostprocManager::CPostprocManager() | ||||
Stan: Nuke. | |||||
: m_IsInitialized(false), m_PingFbo(0), m_PongFbo(0), m_PostProcEffect(L"default"), m_ColorTex1(0), m_ColorTex2(0), | : m_IsInitialized(false), m_PingFbo(0), m_PongFbo(0), m_PostProcEffect(L"default"), m_ColorTex1(0), m_ColorTex2(0), | ||||
m_DepthTex(0), m_BloomFbo(0), m_BlurTex2a(0), m_BlurTex2b(0), m_BlurTex4a(0), m_BlurTex4b(0), | m_DepthTex(0), m_BloomFbo(0), m_BlurTex2a(0), m_BlurTex2b(0), m_BlurTex4a(0), m_BlurTex4b(0), | ||||
m_BlurTex8a(0), m_BlurTex8b(0), m_WhichBuffer(true) | m_BlurTex8a(0), m_BlurTex8b(0), m_WhichBuffer(true) | ||||
{ | { | ||||
} | } | ||||
CPostprocManager::~CPostprocManager() | CPostprocManager::~CPostprocManager() | ||||
{ | { | ||||
Show All 29 Lines | void CPostprocManager::Initialize() | ||||
if (m_IsInitialized) | if (m_IsInitialized) | ||||
return; | return; | ||||
// The screen size starts out correct and then must be updated with Resize() | // The screen size starts out correct and then must be updated with Resize() | ||||
m_Width = g_Renderer.GetWidth(); | m_Width = g_Renderer.GetWidth(); | ||||
m_Height = g_Renderer.GetHeight(); | m_Height = g_Renderer.GetHeight(); | ||||
UpdateAntiAliasingTechnique(); | UpdateAntiAliasingTechnique(); | ||||
UpdateSharpeningTechnique(); | |||||
UpdateSharpnessFactor(); | |||||
RecreateBuffers(); | RecreateBuffers(); | ||||
m_IsInitialized = true; | m_IsInitialized = true; | ||||
// This might happen after the map is loaded and the effect chosen | // This might happen after the map is loaded and the effect chosen | ||||
SetPostEffect(m_PostProcEffect); | SetPostEffect(m_PostProcEffect); | ||||
} | } | ||||
void CPostprocManager::Resize() | void CPostprocManager::Resize() | ||||
▲ Show 20 Lines • Show All 331 Lines • ▼ Show 20 Lines | void CPostprocManager::ApplyEffect(CShaderTechniquePtr &shaderTech1, int pass) | ||||
shader->BindTexture(str_blurTex4, m_BlurTex4a); | shader->BindTexture(str_blurTex4, m_BlurTex4a); | ||||
shader->BindTexture(str_blurTex8, m_BlurTex8a); | shader->BindTexture(str_blurTex8, m_BlurTex8a); | ||||
shader->Uniform(str_width, m_Width); | shader->Uniform(str_width, m_Width); | ||||
shader->Uniform(str_height, m_Height); | shader->Uniform(str_height, m_Height); | ||||
shader->Uniform(str_zNear, m_NearPlane); | shader->Uniform(str_zNear, m_NearPlane); | ||||
shader->Uniform(str_zFar, m_FarPlane); | shader->Uniform(str_zFar, m_FarPlane); | ||||
shader->Uniform(str_sharpness, m_Sharpness); | |||||
shader->Uniform(str_brightness, g_LightEnv.m_Brightness); | shader->Uniform(str_brightness, g_LightEnv.m_Brightness); | ||||
shader->Uniform(str_hdr, g_LightEnv.m_Contrast); | shader->Uniform(str_hdr, g_LightEnv.m_Contrast); | ||||
shader->Uniform(str_saturation, g_LightEnv.m_Saturation); | shader->Uniform(str_saturation, g_LightEnv.m_Saturation); | ||||
shader->Uniform(str_bloom, g_LightEnv.m_Bloom); | shader->Uniform(str_bloom, g_LightEnv.m_Bloom); | ||||
float quadVerts[] = { | float quadVerts[] = { | ||||
1.0f, 1.0f, | 1.0f, 1.0f, | ||||
-1.0f, 1.0f, | -1.0f, 1.0f, | ||||
Show All 28 Lines | |||||
} | } | ||||
void CPostprocManager::ApplyPostproc() | void CPostprocManager::ApplyPostproc() | ||||
{ | { | ||||
ENSURE(m_IsInitialized); | ENSURE(m_IsInitialized); | ||||
// Don't do anything if we are using the default effect and no AA. | // Don't do anything if we are using the default effect and no AA. | ||||
const bool hasEffects = m_PostProcEffect != L"default"; | const bool hasEffects = m_PostProcEffect != L"default"; | ||||
if (!hasEffects && !m_AATech) | if (!hasEffects && !m_AATech && !m_SharpTech) | ||||
return; | return; | ||||
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PongFbo); | pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PongFbo); | ||||
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, 0, 0); | pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, 0, 0); | ||||
GLenum buffers[] = { GL_COLOR_ATTACHMENT0_EXT }; | GLenum buffers[] = { GL_COLOR_ATTACHMENT0_EXT }; | ||||
pglDrawBuffers(1, buffers); | pglDrawBuffers(1, buffers); | ||||
Show All 18 Lines | void CPostprocManager::ApplyPostproc() | ||||
} | } | ||||
if (m_AATech) | if (m_AATech) | ||||
{ | { | ||||
for (int pass = 0; pass < m_AATech->GetNumPasses(); ++pass) | for (int pass = 0; pass < m_AATech->GetNumPasses(); ++pass) | ||||
ApplyEffect(m_AATech, pass); | 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); | pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PongFbo); | ||||
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_DepthTex, 0); | pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_DepthTex, 0); | ||||
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PingFbo); | pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PingFbo); | ||||
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_DepthTex, 0); | pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_DepthTex, 0); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | void CPostprocManager::UpdateAntiAliasingTechnique() | ||||
// techinques strongly depend on the graphics pipeline. | // techinques strongly depend on the graphics pipeline. | ||||
// We might use enums in future though. | // We might use enums in future though. | ||||
if (m_AAName == "fxaa") | if (m_AAName == "fxaa") | ||||
{ | { | ||||
m_AATech = g_Renderer.GetShaderManager().LoadEffect(CStrIntern("fxaa")); | m_AATech = g_Renderer.GetShaderManager().LoadEffect(CStrIntern("fxaa")); | ||||
} | } | ||||
} | } | ||||
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") | |||||
Done Inline ActionsWondering if it wouldn't be better to always call m_SharpTech = g_Renderer.GetShaderManager().LoadEffect(CStrIntern(m_SharpName)); and let it error out if it isn't found. Maybe even better if you can load the json to figure that out. Stan: Wondering if it wouldn't be better to always call
```lang=cpp
m_SharpTech = g_Renderer. | |||||
Done Inline ActionsYou're right. If we check with the if (line 595) the allowed configurations, we don't need the errors, I think? OptimusShepard: You're right. If we check with the if (line 595) the allowed configurations, we don't need the… | |||||
Not Done Inline ActionsWell the question is what should we do when the user enters an incorrect / unsupported value, should we tell him? Stan: Well the question is what should we do when the user enters an incorrect / unsupported value… | |||||
Done Inline ActionsHm. As the user uses a drop down menu to select the filter, the only possibility to get an incorrect value is to edit the config file. But this wont lead to an crash. So is a error message really necessary? If we think so, we have to add error warnings to all parameter of the config file. OptimusShepard: Hm. As the user uses a drop down menu to select the filter, the only possibility to get an… | |||||
Done Inline ActionsI guess keep it consistent with what is done currently then:) Stan: I guess keep it consistent with what is done currently then:) | |||||
{ | |||||
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) | void CPostprocManager::SetDepthBufferClipPlanes(float nearPlane, float farPlane) | ||||
{ | { | ||||
m_NearPlane = nearPlane; | m_NearPlane = nearPlane; | ||||
m_FarPlane = farPlane; | m_FarPlane = farPlane; | ||||
} | } | ||||
#else | #else | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | |||||
void CPostprocManager::SetDepthBufferClipPlanes(float UNUSED(nearPlane), float UNUSED(farPlane)) | void CPostprocManager::SetDepthBufferClipPlanes(float UNUSED(nearPlane), float UNUSED(farPlane)) | ||||
{ | { | ||||
} | } | ||||
void CPostprocManager::UpdateAntiAliasingTechnique() | void CPostprocManager::UpdateAntiAliasingTechnique() | ||||
{ | { | ||||
} | } | ||||
void CPostprocManager::UpdateSharpeningTechnique() | |||||
{ | |||||
} | |||||
void CPostprocManager::UpdateSharpnessFactor() | |||||
{ | |||||
} | |||||
void CPostprocManager::CaptureRenderOutput() | void CPostprocManager::CaptureRenderOutput() | ||||
{ | { | ||||
} | } | ||||
void CPostprocManager::ApplyPostproc() | void CPostprocManager::ApplyPostproc() | ||||
{ | { | ||||
} | } | ||||
void CPostprocManager::ReleaseRenderOutput() | void CPostprocManager::ReleaseRenderOutput() | ||||
{ | { | ||||
} | } | ||||
#endif | #endif |
Wildfire Games · Phabricator
Nuke.