Added "fake bloom" rendering mode for MP3 maps

This commit is contained in:
parax0 2015-07-28 12:22:08 -04:00
parent 7946f09eae
commit c16c0899bf
5 changed files with 38 additions and 11 deletions

View File

@ -148,8 +148,13 @@ void CRenderer::RenderBloom()
CColor((u8) 53, 53, 53, 255),
CColor((u8) 17, 17, 17, 255) };
float BloomWidth = (mBloomMode == eBloom ? mBloomWidth : mViewportWidth);
float BloomHeight = (mBloomMode == eBloom ? mBloomHeight : mViewportHeight);
float BloomHScale = (mBloomMode == eBloom ? mBloomHScale : 0);
float BloomVScale = (mBloomMode == eBloom ? mBloomVScale : 0);
glDisable(GL_DEPTH_TEST);
glViewport(0, 0, mBloomWidth, mBloomHeight);
glViewport(0, 0, BloomWidth, BloomHeight);
glClearColor(0.f, 0.f, 0.f, 0.f);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
@ -159,7 +164,7 @@ void CRenderer::RenderBloom()
CGraphics::UpdateMVPBlock();
// Pass 1: Alpha-blend the scene texture on a black background
mBloomFramebuffers[0].Resize(mBloomWidth, mBloomHeight);
mBloomFramebuffers[0].Resize(BloomWidth, BloomHeight);
mBloomFramebuffers[0].Bind();
glClear(GL_COLOR_BUFFER_BIT);
@ -169,7 +174,7 @@ void CRenderer::RenderBloom()
CDrawUtil::DrawSquare();
// Pass 2: Horizontal blur
mBloomFramebuffers[1].Resize(mBloomWidth, mBloomHeight);
mBloomFramebuffers[1].Resize(BloomWidth, BloomHeight);
mBloomFramebuffers[1].Bind();
CDrawUtil::UseTextureShader(CColor::skGray);
@ -180,7 +185,7 @@ void CRenderer::RenderBloom()
for (u32 iPass = 0; iPass < 6; iPass++)
{
CDrawUtil::UseTextureShader(skTintColors[iPass]);
CVector3f Translate(skHOffset[iPass] * mBloomHScale, 0.f, 0.f);
CVector3f Translate(skHOffset[iPass] * BloomHScale, 0.f, 0.f);
CGraphics::sMVPBlock.ModelMatrix = CTransform4f::TranslationMatrix(Translate).ToMatrix4f();
CGraphics::UpdateMVPBlock();
glBlendFunc(GL_ONE, GL_ONE);
@ -188,7 +193,7 @@ void CRenderer::RenderBloom()
}
// Pass 3: Vertical blur
mBloomFramebuffers[2].Resize(mBloomWidth, mBloomHeight);
mBloomFramebuffers[2].Resize(BloomWidth, BloomHeight);
mBloomFramebuffers[2].Bind();
glClear(GL_COLOR_BUFFER_BIT);
@ -200,7 +205,7 @@ void CRenderer::RenderBloom()
for (u32 iPass = 0; iPass < 6; iPass++)
{
CDrawUtil::UseTextureShader(skTintColors[iPass]);
CVector3f Translate(0.f, skVOffset[iPass] * mBloomVScale, 0.f);
CVector3f Translate(0.f, skVOffset[iPass] * BloomVScale, 0.f);
CGraphics::sMVPBlock.ModelMatrix = CTransform4f::TranslationMatrix(Translate).ToMatrix4f();
CGraphics::UpdateMVPBlock();
glBlendFunc(GL_ONE, GL_ONE);
@ -272,7 +277,7 @@ void CRenderer::BeginFrame()
void CRenderer::EndFrame()
{
// Post-processing
if (mBloomMode == eBloom)
if ((mBloomMode == eBloom) || (mBloomMode == eFakeBloom))
RenderBloom();
// Render result to screen
@ -293,7 +298,7 @@ void CRenderer::EndFrame()
mSceneFramebuffer.Texture()->Bind(0);
CDrawUtil::DrawSquare();
if (mBloomMode == eBloom)
if ((mBloomMode == eBloom) || (mBloomMode == eFakeBloom))
{
CDrawUtil::UseTextureShader();
glBlendFunc(GL_ONE, GL_ONE);

View File

@ -23,7 +23,7 @@ class CRenderer
{
public:
enum EBloomMode {
eNoBloom, eBloom, eBloomMaps
eNoBloom, eBloom, eBloomMaps, eFakeBloom
};
private:

View File

@ -104,11 +104,11 @@ void CWorldEditor::SetArea(CWorld *pWorld, CGameArea *pArea)
CVector3f AreaPosition(AreaTransform[0][3], AreaTransform[1][3], AreaTransform[2][3]);
ui->MainViewport->Camera().Snap(AreaPosition);
// Default bloom to ON for Metroid Prime 3; disable for other games
// Default bloom to Fake Bloom for Metroid Prime 3; disable for other games
if (mpWorld->Version() == eCorruption)
{
ui->menuBloom->setEnabled(true);
on_ActionBloom_triggered();
on_ActionFakeBloom_triggered();
}
else
@ -420,6 +420,7 @@ void CWorldEditor::on_ActionNoBloom_triggered()
mpRenderer->SetBloom(CRenderer::eNoBloom);
ui->ActionNoBloom->setChecked(true);
ui->ActionBloomMaps->setChecked(false);
ui->ActionFakeBloom->setChecked(false);
ui->ActionBloom->setChecked(false);
}
@ -428,6 +429,16 @@ void CWorldEditor::on_ActionBloomMaps_triggered()
mpRenderer->SetBloom(CRenderer::eBloomMaps);
ui->ActionNoBloom->setChecked(false);
ui->ActionBloomMaps->setChecked(true);
ui->ActionFakeBloom->setChecked(false);
ui->ActionBloom->setChecked(false);
}
void CWorldEditor::on_ActionFakeBloom_triggered()
{
mpRenderer->SetBloom(CRenderer::eFakeBloom);
ui->ActionNoBloom->setChecked(false);
ui->ActionBloomMaps->setChecked(false);
ui->ActionFakeBloom->setChecked(true);
ui->ActionBloom->setChecked(false);
}
@ -436,6 +447,7 @@ void CWorldEditor::on_ActionBloom_triggered()
mpRenderer->SetBloom(CRenderer::eBloom);
ui->ActionNoBloom->setChecked(false);
ui->ActionBloomMaps->setChecked(false);
ui->ActionFakeBloom->setChecked(false);
ui->ActionBloom->setChecked(true);
}

View File

@ -84,6 +84,7 @@ private slots:
void on_ActionWorldLighting_triggered();
void on_ActionNoBloom_triggered();
void on_ActionBloomMaps_triggered();
void on_ActionFakeBloom_triggered();
void on_ActionBloom_triggered();
void on_ActionZoomOnSelection_triggered();
void on_ActionDisableBackfaceCull_triggered();

View File

@ -84,6 +84,7 @@
</property>
<addaction name="ActionNoBloom"/>
<addaction name="ActionBloomMaps"/>
<addaction name="ActionFakeBloom"/>
<addaction name="ActionBloom"/>
</widget>
<addaction name="ActionZoomOnSelection"/>
@ -580,6 +581,14 @@
<string>Edit Layers</string>
</property>
</action>
<action name="ActionFakeBloom">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Fake Bloom</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>