mirror of
https://github.com/blawar/GLideN64.git
synced 2024-06-25 22:09:35 +00:00
Code cleanup: remove commented code for blur post filter.
It will not be refactored.
This commit is contained in:
parent
168dccde2a
commit
bc1f2d37d4
|
@ -102,12 +102,6 @@ void Config::resetToDefaults()
|
|||
for (int i = 0; i < 4; ++i)
|
||||
font.colorf[i] = font.color[i] / 255.0f;
|
||||
|
||||
bloomFilter.enable = 0;
|
||||
bloomFilter.thresholdLevel = 4;
|
||||
bloomFilter.blendMode = 0;
|
||||
bloomFilter.blurAmount = 10;
|
||||
bloomFilter.blurStrength = 20;
|
||||
|
||||
gammaCorrection.force = 0;
|
||||
gammaCorrection.level = 2.0f;
|
||||
|
||||
|
|
10
src/Config.h
10
src/Config.h
|
@ -4,7 +4,7 @@
|
|||
#include <string>
|
||||
#include "Types.h"
|
||||
|
||||
#define CONFIG_VERSION_CURRENT 17U
|
||||
#define CONFIG_VERSION_CURRENT 18U
|
||||
|
||||
#define BILINEAR_3POINT 0
|
||||
#define BILINEAR_STANDARD 1
|
||||
|
@ -142,14 +142,6 @@ struct Config
|
|||
float colorf[4];
|
||||
} font;
|
||||
|
||||
struct {
|
||||
u32 enable;
|
||||
u32 thresholdLevel;
|
||||
u32 blendMode;
|
||||
u32 blurAmount;
|
||||
u32 blurStrength;
|
||||
} bloomFilter;
|
||||
|
||||
struct {
|
||||
u32 force;
|
||||
f32 level;
|
||||
|
|
|
@ -836,8 +836,7 @@ void FrameBufferList::_renderScreenSizeBuffer()
|
|||
GraphicsDrawer & drawer = wnd.getDrawer();
|
||||
FrameBuffer *pBuffer = &m_list.back();
|
||||
PostProcessor & postProcessor = PostProcessor::get();
|
||||
FrameBuffer * pFilteredBuffer = postProcessor.doBlur(postProcessor.doGammaCorrection(
|
||||
postProcessor.doOrientationCorrection(pBuffer)));
|
||||
FrameBuffer * pFilteredBuffer = postProcessor.doGammaCorrection(postProcessor.doOrientationCorrection(pBuffer));
|
||||
CachedTexture * pBufferTexture = pFilteredBuffer->m_pTexture;
|
||||
|
||||
|
||||
|
@ -1095,8 +1094,7 @@ void FrameBufferList::renderBuffer()
|
|||
srcY1 = srcY0 + srcHeight;
|
||||
}
|
||||
PostProcessor & postProcessor = PostProcessor::get();
|
||||
FrameBuffer * pFilteredBuffer = postProcessor.doBlur(postProcessor.doGammaCorrection(
|
||||
postProcessor.doOrientationCorrection(pBuffer)));
|
||||
FrameBuffer * pFilteredBuffer = postProcessor.doGammaCorrection(postProcessor.doOrientationCorrection(pBuffer));
|
||||
|
||||
if (rdpRes.vi_fsaa && rdpRes.vi_divot)
|
||||
Xdivot = 1;
|
||||
|
@ -1172,8 +1170,7 @@ void FrameBufferList::renderBuffer()
|
|||
|
||||
if (pNextBuffer != nullptr) {
|
||||
pNextBuffer->m_isMainBuffer = true;
|
||||
pFilteredBuffer = postProcessor.doBlur(postProcessor.doGammaCorrection(
|
||||
postProcessor.doOrientationCorrection(pNextBuffer)));
|
||||
pFilteredBuffer = postProcessor.doGammaCorrection(postProcessor.doOrientationCorrection(pNextBuffer));
|
||||
srcY1 = srcPartHeight;
|
||||
dstY0 = dstY1;
|
||||
dstY1 = dstY0 + dstPartHeight;
|
||||
|
|
|
@ -223,22 +223,6 @@ void ConfigDialog::_init()
|
|||
ui->txPathLabel->setText(QString::fromWCharArray(config.textureFilter.txPath));
|
||||
|
||||
// Post filter settings
|
||||
ui->bloomGroupBox->setChecked(config.bloomFilter.enable != 0);
|
||||
switch (config.bloomFilter.blendMode) {
|
||||
case 0:
|
||||
ui->bloomStrongRadioButton->setChecked(true);
|
||||
break;
|
||||
case 1:
|
||||
ui->bloomMildRadioButton->setChecked(true);
|
||||
break;
|
||||
case 2:
|
||||
ui->bloomLightRadioButton->setChecked(true);
|
||||
break;
|
||||
}
|
||||
ui->bloomThresholdSlider->setValue(config.bloomFilter.thresholdLevel);
|
||||
ui->blurAmountSlider->setValue(config.bloomFilter.blurAmount);
|
||||
ui->blurStrengthSlider->setValue(config.bloomFilter.blurStrength);
|
||||
|
||||
ui->gammaCorrectionGroupBox->setChecked(config.gammaCorrection.force != 0);
|
||||
ui->gammaLevelSpinBox->setValue(config.gammaCorrection.level);
|
||||
|
||||
|
@ -469,17 +453,6 @@ void ConfigDialog::accept()
|
|||
config.textureFilter.txPath[txPath.toWCharArray(config.textureFilter.txPath)] = L'\0';
|
||||
|
||||
// Post filter settings
|
||||
config.bloomFilter.enable = ui->bloomGroupBox->isChecked() ? 1 : 0;
|
||||
if (ui->bloomStrongRadioButton->isChecked())
|
||||
config.bloomFilter.blendMode = 0;
|
||||
else if (ui->bloomMildRadioButton->isChecked())
|
||||
config.bloomFilter.blendMode = 1;
|
||||
else if (ui->bloomLightRadioButton->isChecked())
|
||||
config.bloomFilter.blendMode = 2;
|
||||
config.bloomFilter.thresholdLevel = ui->bloomThresholdSlider->value();
|
||||
config.bloomFilter.blurAmount = ui->blurAmountSlider->value();
|
||||
config.bloomFilter.blurStrength = ui->blurStrengthSlider->value();
|
||||
|
||||
config.gammaCorrection.force = ui->gammaCorrectionGroupBox->isChecked() ? 1 : 0;
|
||||
config.gammaCorrection.level = ui->gammaLevelSpinBox->value();
|
||||
|
||||
|
|
|
@ -97,14 +97,6 @@ void _loadSettings(QSettings & settings)
|
|||
config.font.colorf[3] = config.font.color[3] == 0 ? 1.0f : _FIXED2FLOAT(config.font.color[3], 8);
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup("bloomFilter");
|
||||
config.bloomFilter.enable = settings.value("enable", config.bloomFilter.enable).toInt();
|
||||
config.bloomFilter.thresholdLevel = settings.value("thresholdLevel", config.bloomFilter.thresholdLevel).toInt();
|
||||
config.bloomFilter.blendMode = settings.value("blendMode", config.bloomFilter.blendMode).toInt();
|
||||
config.bloomFilter.blurAmount = settings.value("blurAmount", config.bloomFilter.blurAmount).toInt();
|
||||
config.bloomFilter.blurStrength = settings.value("blurStrength", config.bloomFilter.blurStrength).toInt();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup("gammaCorrection");
|
||||
config.gammaCorrection.force = settings.value("force", config.gammaCorrection.force).toInt();
|
||||
config.gammaCorrection.level = settings.value("level", config.gammaCorrection.level).toFloat();
|
||||
|
@ -217,14 +209,6 @@ void writeSettings(const QString & _strIniFolder)
|
|||
settings.setValue("color", QColor(config.font.color[0], config.font.color[1], config.font.color[2], config.font.color[3]));
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup("bloomFilter");
|
||||
settings.setValue("enable", config.bloomFilter.enable);
|
||||
settings.setValue("thresholdLevel", config.bloomFilter.thresholdLevel);
|
||||
settings.setValue("blendMode", config.bloomFilter.blendMode);
|
||||
settings.setValue("blurAmount", config.bloomFilter.blurAmount);
|
||||
settings.setValue("blurStrength", config.bloomFilter.blurStrength);
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup("gammaCorrection");
|
||||
settings.setValue("force", config.gammaCorrection.force);
|
||||
settings.setValue("level", config.gammaCorrection.level);
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>627</width>
|
||||
<height>644</height>
|
||||
<width>660</width>
|
||||
<height>639</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -35,6 +35,9 @@
|
|||
<height>450</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="usesScrollButtons">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
|
@ -2571,236 +2574,6 @@
|
|||
</property>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_50">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="bloomGroupBox">
|
||||
<property name="title">
|
||||
<string>Bloom</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_15">
|
||||
<property name="spacing">
|
||||
<number>18</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="bloomBlendModeFrame">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_39">
|
||||
<property name="spacing">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="bloomBlendModeLabel">
|
||||
<property name="text">
|
||||
<string>Blending:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="bloomStrongRadioButton">
|
||||
<property name="text">
|
||||
<string>Strong</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">bloomBlendModeButtonGroup</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="bloomMildRadioButton">
|
||||
<property name="text">
|
||||
<string>Medium</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">bloomBlendModeButtonGroup</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="bloomLightRadioButton">
|
||||
<property name="text">
|
||||
<string>Light</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">bloomBlendModeButtonGroup</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="horizontalSpacing">
|
||||
<number>12</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="4" column="0" alignment="Qt::AlignHCenter">
|
||||
<widget class="QSlider" name="blurStrengthSlider">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>150</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>99</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksBothSides</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2" alignment="Qt::AlignHCenter">
|
||||
<widget class="QSlider" name="bloomThresholdSlider">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>150</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksBothSides</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" alignment="Qt::AlignHCenter">
|
||||
<widget class="QSlider" name="blurAmountSlider">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>150</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksBothSides</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="bloomBlurLabel">
|
||||
<property name="text">
|
||||
<string>Blur amount:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="bloomBlurStrengthLabel">
|
||||
<property name="text">
|
||||
<string>Blur strength:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="bloomThresholdLabel">
|
||||
<property name="text">
|
||||
<string>Threshold level:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="blurStrengthLabel">
|
||||
<property name="text">
|
||||
<string notr="true"> 0</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QLabel" name="blurAmountLabel">
|
||||
<property name="text">
|
||||
<string notr="true"> 0</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QLabel" name="bloomThresholdLabel_2">
|
||||
<property name="text">
|
||||
<string notr="true"> 0</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
|
@ -3903,54 +3676,6 @@
|
|||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>blurStrengthSlider</sender>
|
||||
<signal>valueChanged(int)</signal>
|
||||
<receiver>blurStrengthLabel</receiver>
|
||||
<slot>setNum(int)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>50</x>
|
||||
<y>325</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>33</x>
|
||||
<y>332</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>blurAmountSlider</sender>
|
||||
<signal>valueChanged(int)</signal>
|
||||
<receiver>blurAmountLabel</receiver>
|
||||
<slot>setNum(int)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>125</x>
|
||||
<y>325</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>111</x>
|
||||
<y>332</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>bloomThresholdSlider</sender>
|
||||
<signal>valueChanged(int)</signal>
|
||||
<receiver>bloomThresholdLabel_2</receiver>
|
||||
<slot>setNum(int)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>206</x>
|
||||
<y>325</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>184</x>
|
||||
<y>332</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>fbInfoEnableCheckBox</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
|
@ -4193,11 +3918,11 @@
|
|||
</connection>
|
||||
</connections>
|
||||
<buttongroups>
|
||||
<buttongroup name="osdButtonGroup"/>
|
||||
<buttongroup name="factorButtonGroup"/>
|
||||
<buttongroup name="bloomBlendModeButtonGroup"/>
|
||||
<buttongroup name="screenshotButtonGroup"/>
|
||||
<buttongroup name="aspectButtonGroup"/>
|
||||
<buttongroup name="fixTexrectCoordsButtonGroup"/>
|
||||
<buttongroup name="bloomBlendModeButtonGroup"/>
|
||||
<buttongroup name="osdButtonGroup"/>
|
||||
<buttongroup name="factorButtonGroup"/>
|
||||
</buttongroups>
|
||||
</ui>
|
||||
|
|
|
@ -12,237 +12,8 @@
|
|||
|
||||
using namespace graphics;
|
||||
|
||||
#define NEW_POST_PROCESSOR
|
||||
|
||||
#ifdef OS_ANDROID
|
||||
PostProcessor PostProcessor::processor;
|
||||
#endif
|
||||
|
||||
#ifdef USE_OLD_SHADERS
|
||||
|
||||
#if defined(GLES3_1)
|
||||
#define SHADER_VERSION "#version 310 es \n"
|
||||
#elif defined(GLES3)
|
||||
#define SHADER_VERSION "#version 300 es \n"
|
||||
#elif defined(GLES2)
|
||||
#define SHADER_VERSION "#version 100 \n"
|
||||
#else
|
||||
#define SHADER_VERSION "#version 330 core \n"
|
||||
#endif
|
||||
|
||||
#ifdef GLES2
|
||||
#define FRAGMENT_SHADER_END " gl_FragColor = fragColor; \n"
|
||||
#else
|
||||
#define FRAGMENT_SHADER_END "\n"
|
||||
#endif
|
||||
|
||||
static const char * vertexShader =
|
||||
SHADER_VERSION
|
||||
"#if (__VERSION__ > 120) \n"
|
||||
"# define IN in \n"
|
||||
"# define OUT out \n"
|
||||
"#else \n"
|
||||
"# define IN attribute \n"
|
||||
"# define OUT varying \n"
|
||||
"#endif // __VERSION \n"
|
||||
#ifndef NEW_POST_PROCESSOR
|
||||
"IN highp vec2 aRectPosition; \n"
|
||||
#else
|
||||
"IN highp vec4 aRectPosition; \n"
|
||||
#endif
|
||||
"IN highp vec2 aTexCoord0; \n"
|
||||
"OUT mediump vec2 vTexCoord; \n"
|
||||
"void main() { \n"
|
||||
#ifndef NEW_POST_PROCESSOR
|
||||
"gl_Position = vec4(aRectPosition.x, aRectPosition.y, 0.0, 1.0);\n"
|
||||
#else
|
||||
" gl_Position = aRectPosition; \n"
|
||||
#endif
|
||||
"vTexCoord = aTexCoord0; \n"
|
||||
"} \n"
|
||||
;
|
||||
|
||||
static const char* extractBloomShader =
|
||||
SHADER_VERSION
|
||||
"#if (__VERSION__ > 120) \n"
|
||||
"# define IN in \n"
|
||||
"# define OUT out \n"
|
||||
"# define texture2D texture \n"
|
||||
"#else \n"
|
||||
"# define IN varying \n"
|
||||
"# define OUT \n"
|
||||
"#endif // __VERSION __ \n"
|
||||
"IN mediump vec2 vTexCoord; \n"
|
||||
"uniform sampler2D Sample0; \n"
|
||||
"OUT lowp vec4 fragColor; \n"
|
||||
" \n"
|
||||
"uniform lowp int ThresholdLevel; \n"
|
||||
" \n"
|
||||
"void main() \n"
|
||||
"{ \n"
|
||||
" lowp vec4 color = texture2D(Sample0, vTexCoord); \n"
|
||||
" \n"
|
||||
" mediump float lum = dot(vec4(0.30, 0.59, 0.11, 0.0), color);\n"
|
||||
" mediump float scale = lum; \n"
|
||||
" lowp int level = clamp(ThresholdLevel, 2, 6); \n"
|
||||
" for (int i = 1; i < level; ++i) \n"
|
||||
" scale *= lum; \n"
|
||||
" fragColor = scale*color; \n"
|
||||
" fragColor.a = 1.0; \n"
|
||||
FRAGMENT_SHADER_END
|
||||
"} \n"
|
||||
;
|
||||
|
||||
static const char* seperableBlurShader =
|
||||
/// Author: Nathaniel Meyer
|
||||
///
|
||||
/// Copyright: Nutty Software
|
||||
/// http://www.nutty.ca
|
||||
///
|
||||
/// Fragment shader for performing a seperable blur on the specified texture.
|
||||
SHADER_VERSION
|
||||
"#if (__VERSION__ > 120) \n"
|
||||
"# define IN in \n"
|
||||
"# define OUT out \n"
|
||||
"# define texture2D texture \n"
|
||||
"#else \n"
|
||||
"# define IN varying \n"
|
||||
"# define OUT \n"
|
||||
"#endif // __VERSION __ \n"
|
||||
// Uniform variables.
|
||||
"uniform sampler2D Sample0; \n"
|
||||
"uniform mediump vec2 TexelSize; \n"
|
||||
" \n"
|
||||
"uniform lowp int Orientation; \n"
|
||||
"uniform lowp int BlurAmount; \n"
|
||||
"uniform lowp float BlurScale; \n"
|
||||
"uniform lowp float BlurStrength; \n"
|
||||
" \n"
|
||||
"IN mediump vec2 vTexCoord; \n"
|
||||
"OUT lowp vec4 fragColor; \n"
|
||||
" \n"
|
||||
// Gets the Gaussian value in the first dimension.
|
||||
// "x" Distance from origin on the x-axis.
|
||||
// "deviation" Standard deviation.
|
||||
// returns The gaussian value on the x-axis.
|
||||
"mediump float Gaussian (in mediump float x, in mediump float deviation) \n"
|
||||
"{ \n"
|
||||
" return (1.0 / sqrt(2.0 * 3.141592 * deviation)) * exp(-((x * x) / (2.0 * deviation))); \n"
|
||||
"} \n"
|
||||
" \n"
|
||||
// Fragment shader entry.
|
||||
"void main () \n"
|
||||
"{ \n"
|
||||
" // Locals \n"
|
||||
" mediump float halfBlur = float(BlurAmount) * 0.5; \n"
|
||||
" mediump vec4 colour = vec4(0.0); \n"
|
||||
" \n"
|
||||
" // Gaussian deviation \n"
|
||||
" mediump float deviation = halfBlur * 0.35; \n"
|
||||
" deviation *= deviation; \n"
|
||||
" mediump float strength = 1.0 - BlurStrength; \n"
|
||||
" \n"
|
||||
" if ( Orientation == 0 ) \n"
|
||||
" { \n"
|
||||
" // Horizontal blur \n"
|
||||
" for (lowp int i = 0; i < BlurAmount; ++i) \n"
|
||||
" { \n"
|
||||
" mediump float offset = float(i) - halfBlur; \n"
|
||||
" colour += texture2D(Sample0, vTexCoord + vec2(offset * TexelSize.x * BlurScale, 0.0)) * Gaussian(offset * strength, deviation); \n"
|
||||
" } \n"
|
||||
" } \n"
|
||||
" else \n"
|
||||
" { \n"
|
||||
" // Vertical blur \n"
|
||||
" for (lowp int i = 0; i < BlurAmount; ++i) \n"
|
||||
" { \n"
|
||||
" mediump float offset = float(i) - halfBlur; \n"
|
||||
" colour += texture2D(Sample0, vTexCoord + vec2(0.0, offset * TexelSize.y * BlurScale)) * Gaussian(offset * strength, deviation); \n"
|
||||
" } \n"
|
||||
" } \n"
|
||||
" \n"
|
||||
" // Apply colour \n"
|
||||
" fragColor = clamp(colour, 0.0, 1.0); \n"
|
||||
" fragColor.a = 1.0; \n"
|
||||
FRAGMENT_SHADER_END
|
||||
"} \n"
|
||||
;
|
||||
|
||||
static const char* glowShader =
|
||||
/// Author: Nathaniel Meyer
|
||||
///
|
||||
/// Copyright: Nutty Software
|
||||
/// http://www.nutty.ca
|
||||
///
|
||||
/// Fragment shader for blending two textures using an algorithm that overlays the glowmap.
|
||||
SHADER_VERSION
|
||||
"#if (__VERSION__ > 120) \n"
|
||||
"# define IN in \n"
|
||||
"# define OUT out \n"
|
||||
"# define texture2D texture \n"
|
||||
"#else \n"
|
||||
"# define IN varying \n"
|
||||
"# define OUT \n"
|
||||
"#endif // __VERSION __ \n"
|
||||
// Uniform variables.
|
||||
"uniform sampler2D Sample0; \n"
|
||||
"uniform sampler2D Sample1; \n"
|
||||
"uniform lowp int BlendMode; \n"
|
||||
" \n"
|
||||
"IN mediump vec2 vTexCoord; \n"
|
||||
"OUT lowp vec4 fragColor; \n"
|
||||
" \n"
|
||||
// Fragment shader entry.
|
||||
"void main () \n"
|
||||
"{ \n"
|
||||
" lowp vec4 dst = texture2D(Sample0, vTexCoord); // rendered scene \n"
|
||||
" lowp vec4 src = texture2D(Sample1, vTexCoord); // glowmap \n"
|
||||
" \n"
|
||||
" if (BlendMode == 0) { \n"
|
||||
" // Additive blending (strong result, high overexposure) \n"
|
||||
" fragColor = min(src + dst, 1.0); \n"
|
||||
" fragColor.a = 1.0; \n"
|
||||
" } else if (BlendMode == 1) { \n"
|
||||
" fragColor = clamp((src + dst) - (src * dst), 0.0, 1.0); \n"
|
||||
" fragColor.a = 1.0; \n"
|
||||
" } else if (BlendMode == 2) { \n"
|
||||
" src = (src * 0.5) + 0.5; \n"
|
||||
" \n"
|
||||
" if (src.x <= 0.5) \n"
|
||||
" fragColor.x = dst.x - (1.0 - 2.0 * src.x) * dst.x * (1.0 - dst.x); \n"
|
||||
" else if ((src.x > 0.5) && (dst.x <= 0.25)) \n"
|
||||
" fragColor.x = dst.x + (2.0 * src.x - 1.0) * (4.0 * dst.x * (4.0 * dst.x + 1.0) * (dst.x - 1.0) + 7.0 * dst.x);\n"
|
||||
" else \n"
|
||||
" fragColor.x = dst.x + (2.0 * src.x - 1.0) * (sqrt(dst.x) - dst.x); \n"
|
||||
" if (src.y <= 0.5) \n"
|
||||
" fragColor.y = dst.y - (1.0 - 2.0 * src.y) * dst.y * (1.0 - dst.y); \n"
|
||||
" else if ((src.y > 0.5) && (dst.y <= 0.25)) \n"
|
||||
" fragColor.y = dst.y + (2.0 * src.y - 1.0) * (4.0 * dst.y * (4.0 * dst.y + 1.0) * (dst.y - 1.0) + 7.0 * dst.y);\n"
|
||||
" else \n"
|
||||
" fragColor.y = dst.y + (2.0 * src.y - 1.0) * (sqrt(dst.y) - dst.y); \n"
|
||||
" if (src.z <= 0.5) \n"
|
||||
" fragColor.z = dst.z - (1.0 - 2.0 * src.z) * dst.z * (1.0 - dst.z); \n"
|
||||
" else if ((src.z > 0.5) && (dst.z <= 0.25)) \n"
|
||||
" fragColor.z = dst.z + (2.0 * src.z - 1.0) * (4.0 * dst.z * (4.0 * dst.z + 1.0) * (dst.z - 1.0) + 7.0 * dst.z);\n"
|
||||
" else \n"
|
||||
" fragColor.z = dst.z + (2.0 * src.z - 1.0) * (sqrt(dst.z) - dst.z); \n"
|
||||
" fragColor.a = 1.0; \n"
|
||||
" } else { \n"
|
||||
" // Show just the glow map \n"
|
||||
" fragColor = src; \n"
|
||||
" } \n"
|
||||
FRAGMENT_SHADER_END
|
||||
"} \n"
|
||||
;
|
||||
|
||||
#endif
|
||||
|
||||
PostProcessor::PostProcessor()
|
||||
: m_FBO_glowMap(0)
|
||||
, m_FBO_blur(0)
|
||||
, m_pTextureOriginal(nullptr)
|
||||
, m_pTextureGlowMap(nullptr)
|
||||
, m_pTextureBlur(nullptr)
|
||||
: m_pTextureOriginal(nullptr)
|
||||
{}
|
||||
|
||||
void PostProcessor::_createResultBuffer(const FrameBuffer * _pMainBuffer)
|
||||
|
@ -298,61 +69,6 @@ void PostProcessor::_initGammaCorrection()
|
|||
m_gammaCorrectionProgram.reset(gfxContext.createGammaCorrectionShader());
|
||||
}
|
||||
|
||||
void PostProcessor::_initBlur()
|
||||
{
|
||||
/*
|
||||
m_extractBloomProgram = createRectShaderProgram(vertexShader, extractBloomShader);
|
||||
glUseProgram(m_extractBloomProgram);
|
||||
int loc = glGetUniformLocation(m_extractBloomProgram, "Sample0");
|
||||
assert(loc >= 0);
|
||||
glUniform1i(loc, 0);
|
||||
loc = glGetUniformLocation(m_extractBloomProgram, "ThresholdLevel");
|
||||
assert(loc >= 0);
|
||||
glUniform1i(loc, config.bloomFilter.thresholdLevel);
|
||||
|
||||
m_seperableBlurProgram = createRectShaderProgram(vertexShader, seperableBlurShader);
|
||||
glUseProgram(m_seperableBlurProgram);
|
||||
loc = glGetUniformLocation(m_seperableBlurProgram, "Sample0");
|
||||
assert(loc >= 0);
|
||||
glUniform1i(loc, 0);
|
||||
loc = glGetUniformLocation(m_seperableBlurProgram, "TexelSize");
|
||||
assert(loc >= 0);
|
||||
glUniform2f(loc, 1.0f / dwnd().getWidth(), 1.0f / dwnd().getHeight());
|
||||
loc = glGetUniformLocation(m_seperableBlurProgram, "Orientation");
|
||||
assert(loc >= 0);
|
||||
glUniform1i(loc, 0);
|
||||
loc = glGetUniformLocation(m_seperableBlurProgram, "BlurAmount");
|
||||
assert(loc >= 0);
|
||||
glUniform1i(loc, config.bloomFilter.blurAmount);
|
||||
loc = glGetUniformLocation(m_seperableBlurProgram, "BlurScale");
|
||||
assert(loc >= 0);
|
||||
glUniform1f(loc, 1.0f);
|
||||
loc = glGetUniformLocation(m_seperableBlurProgram, "BlurStrength");
|
||||
assert(loc >= 0);
|
||||
glUniform1f(loc, config.bloomFilter.blurStrength/100.0f);
|
||||
|
||||
m_glowProgram = createRectShaderProgram(vertexShader, glowShader);
|
||||
glUseProgram(m_glowProgram);
|
||||
loc = glGetUniformLocation(m_glowProgram, "Sample0");
|
||||
assert(loc >= 0);
|
||||
glUniform1i(loc, 0);
|
||||
loc = glGetUniformLocation(m_glowProgram, "Sample1");
|
||||
assert(loc >= 0);
|
||||
glUniform1i(loc, 1);
|
||||
loc = glGetUniformLocation(m_glowProgram, "BlendMode");
|
||||
assert(loc >= 0);
|
||||
glUniform1i(loc, config.bloomFilter.blendMode);
|
||||
|
||||
m_pTextureGlowMap = _createTexture();
|
||||
m_pTextureBlur = _createTexture();
|
||||
|
||||
m_FBO_glowMap = _createFBO(m_pTextureGlowMap);
|
||||
m_FBO_blur = _createFBO(m_pTextureBlur);
|
||||
|
||||
glUseProgram(0);
|
||||
*/
|
||||
}
|
||||
|
||||
void PostProcessor::_initOrientationCorrection()
|
||||
{
|
||||
m_orientationCorrectionProgram.reset(gfxContext.createOrientationCorrectionShader());
|
||||
|
@ -363,8 +79,6 @@ void PostProcessor::init()
|
|||
_initGammaCorrection();
|
||||
if (config.generalEmulation.enableBlitScreenWorkaround != 0)
|
||||
_initOrientationCorrection();
|
||||
if (config.bloomFilter.enable != 0)
|
||||
_initBlur();
|
||||
}
|
||||
|
||||
void PostProcessor::_destroyGammaCorrection()
|
||||
|
@ -377,47 +91,8 @@ void PostProcessor::_destroyOrientationCorrection()
|
|||
m_orientationCorrectionProgram.reset();
|
||||
}
|
||||
|
||||
void PostProcessor::_destroyBlur()
|
||||
{
|
||||
/*
|
||||
if (m_extractBloomProgram != 0)
|
||||
glDeleteProgram(m_extractBloomProgram);
|
||||
m_extractBloomProgram = 0;
|
||||
|
||||
if (m_seperableBlurProgram != 0)
|
||||
glDeleteProgram(m_seperableBlurProgram);
|
||||
m_seperableBlurProgram = 0;
|
||||
|
||||
if (m_glowProgram != 0)
|
||||
glDeleteProgram(m_glowProgram);
|
||||
m_glowProgram = 0;
|
||||
|
||||
if (m_bloomProgram != 0)
|
||||
glDeleteProgram(m_bloomProgram);
|
||||
m_bloomProgram = 0;
|
||||
|
||||
if (m_FBO_glowMap != 0)
|
||||
glDeleteFramebuffers(1, &m_FBO_glowMap);
|
||||
m_FBO_glowMap = 0;
|
||||
|
||||
if (m_FBO_blur != 0)
|
||||
glDeleteFramebuffers(1, &m_FBO_blur);
|
||||
m_FBO_blur = 0;
|
||||
|
||||
if (m_pTextureGlowMap != nullptr)
|
||||
textureCache().removeFrameBufferTexture(m_pTextureGlowMap);
|
||||
m_pTextureGlowMap = nullptr;
|
||||
|
||||
if (m_pTextureBlur != nullptr)
|
||||
textureCache().removeFrameBufferTexture(m_pTextureBlur);
|
||||
m_pTextureBlur = nullptr;
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
void PostProcessor::destroy()
|
||||
{
|
||||
_destroyBlur();
|
||||
_destroyGammaCorrection();
|
||||
_destroyOrientationCorrection();
|
||||
m_pResultBuffer.reset();
|
||||
|
@ -454,84 +129,6 @@ void PostProcessor::_postDraw()
|
|||
gfxContext.resetShaderProgram();
|
||||
}
|
||||
|
||||
FrameBuffer * PostProcessor::doBlur(FrameBuffer * _pBuffer)
|
||||
{
|
||||
return _pBuffer;
|
||||
/*
|
||||
if (_pBuffer == nullptr)
|
||||
return nullptr;
|
||||
|
||||
if (config.bloomFilter.enable == 0)
|
||||
return _pBuffer;
|
||||
|
||||
_preDraw(_pBuffer);
|
||||
|
||||
#ifndef NEW_POST_PROCESSOR
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_FBO_glowMap);
|
||||
textureCache().activateTexture(0, m_pTextureOriginal);
|
||||
glUseProgram(m_extractBloomProgram);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_FBO_blur);
|
||||
textureCache().activateTexture(0, m_pTextureGlowMap);
|
||||
glUseProgram(m_seperableBlurProgram);
|
||||
int loc = glGetUniformLocation(m_seperableBlurProgram, "Orientation");
|
||||
assert(loc >= 0);
|
||||
glUniform1i(loc, 0);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_FBO_glowMap);
|
||||
textureCache().activateTexture(0, m_pTextureBlur);
|
||||
glUniform1i(loc, 1);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_pResultBuffer->m_FBO);
|
||||
textureCache().activateTexture(0, m_pTextureOriginal);
|
||||
textureCache().activateTexture(1, m_pTextureGlowMap);
|
||||
glUseProgram(m_glowProgram);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
#else
|
||||
CachedTexture * pDstTex = m_pResultBuffer->m_pTexture;
|
||||
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_FBO_glowMap);
|
||||
video().getRender().copyTexturedRect(0, 0, m_pTextureOriginal->realWidth, m_pTextureOriginal->realHeight,
|
||||
m_pTextureOriginal->realWidth, m_pTextureOriginal->realHeight, m_pTextureOriginal->glName,
|
||||
0, 0, m_pTextureGlowMap->realWidth, m_pTextureGlowMap->realHeight,
|
||||
m_pTextureGlowMap->realWidth, m_pTextureGlowMap->realHeight, GL_NEAREST, m_extractBloomProgram);
|
||||
|
||||
glUseProgram(m_seperableBlurProgram);
|
||||
int loc = glGetUniformLocation(m_seperableBlurProgram, "Orientation");
|
||||
assert(loc >= 0);
|
||||
glUniform1i(loc, 0);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_FBO_blur);
|
||||
video().getRender().copyTexturedRect(0, 0, m_pTextureGlowMap->realWidth, m_pTextureGlowMap->realHeight,
|
||||
m_pTextureGlowMap->realWidth, m_pTextureGlowMap->realHeight, m_pTextureGlowMap->glName,
|
||||
0, 0, m_pTextureBlur->realWidth, m_pTextureBlur->realHeight,
|
||||
m_pTextureBlur->realWidth, m_pTextureBlur->realHeight, GL_NEAREST, m_seperableBlurProgram);
|
||||
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_FBO_glowMap);
|
||||
glUniform1i(loc, 1);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_FBO_blur);
|
||||
video().getRender().copyTexturedRect(0, 0, m_pTextureBlur->realWidth, m_pTextureBlur->realHeight,
|
||||
m_pTextureBlur->realWidth, m_pTextureBlur->realHeight, m_pTextureBlur->glName,
|
||||
0, 0, m_pTextureGlowMap->realWidth, m_pTextureGlowMap->realHeight,
|
||||
m_pTextureGlowMap->realWidth, m_pTextureGlowMap->realHeight, GL_NEAREST, m_seperableBlurProgram);
|
||||
|
||||
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_pResultBuffer->m_FBO);
|
||||
textureCache().activateTexture(1, m_pTextureGlowMap);
|
||||
video().getRender().copyTexturedRect(0, 0, m_pTextureGlowMap->realWidth, m_pTextureGlowMap->realHeight,
|
||||
m_pTextureGlowMap->realWidth, m_pTextureGlowMap->realHeight, m_pTextureOriginal->glName,
|
||||
0, 0, m_pTextureOriginal->realWidth, m_pTextureOriginal->realHeight,
|
||||
m_pTextureOriginal->realWidth, m_pTextureOriginal->realHeight, GL_NEAREST, m_glowProgram);
|
||||
|
||||
#endif
|
||||
|
||||
_postDraw();
|
||||
return m_pResultBuffer;
|
||||
*/
|
||||
}
|
||||
|
||||
FrameBuffer * PostProcessor::doGammaCorrection(FrameBuffer * _pBuffer)
|
||||
{
|
||||
if (_pBuffer == nullptr)
|
||||
|
|
|
@ -17,7 +17,6 @@ public:
|
|||
void init();
|
||||
void destroy();
|
||||
|
||||
FrameBuffer * doBlur(FrameBuffer * _pBuffer);
|
||||
FrameBuffer * doGammaCorrection(FrameBuffer * _pBuffer);
|
||||
FrameBuffer * doOrientationCorrection(FrameBuffer * _pBuffer);
|
||||
|
||||
|
@ -32,22 +31,13 @@ private:
|
|||
void _destroyGammaCorrection();
|
||||
void _initOrientationCorrection();
|
||||
void _destroyOrientationCorrection();
|
||||
void _initBlur();
|
||||
void _destroyBlur();
|
||||
void _preDraw(FrameBuffer * _pBuffer);
|
||||
void _postDraw();
|
||||
|
||||
std::unique_ptr<graphics::ShaderProgram> m_gammaCorrectionProgram;
|
||||
std::unique_ptr<graphics::ShaderProgram> m_orientationCorrectionProgram;
|
||||
|
||||
std::unique_ptr<FrameBuffer> m_pResultBuffer;
|
||||
|
||||
graphics::ObjectHandle m_FBO_glowMap;
|
||||
graphics::ObjectHandle m_FBO_blur;
|
||||
|
||||
CachedTexture * m_pTextureOriginal;
|
||||
CachedTexture * m_pTextureGlowMap;
|
||||
CachedTexture * m_pTextureBlur;
|
||||
|
||||
#ifdef OS_ANDROID
|
||||
static PostProcessor processor;
|
||||
|
|
|
@ -157,18 +157,6 @@ bool Config_SetDefault()
|
|||
res = ConfigSetDefaultString(g_configVideoGliden64, "fontColor", "B5E61D", "Font color in RGB format.");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
|
||||
//#Bloom filter settings
|
||||
res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableBloom", config.bloomFilter.enable, "Enable bloom filter");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
res = ConfigSetDefaultInt(g_configVideoGliden64, "bloomThresholdLevel", config.bloomFilter.thresholdLevel, "Brightness threshold level for bloom. Values [2, 6]");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
res = ConfigSetDefaultInt(g_configVideoGliden64, "bloomBlendMode", config.bloomFilter.blendMode, "Bloom blend mode (0=Strong, 1=Mild, 2=Light)");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
res = ConfigSetDefaultInt(g_configVideoGliden64, "blurAmount", config.bloomFilter.blurAmount, "Blur radius. Values [2, 10]");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
res = ConfigSetDefaultInt(g_configVideoGliden64, "blurStrength", config.bloomFilter.blurStrength, "Blur strength. Values [10, 100]");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
|
||||
//#Gamma correction settings
|
||||
res = ConfigSetDefaultBool(g_configVideoGliden64, "ForceGammaCorrection", config.gammaCorrection.force, "Force gamma correction.");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
|
@ -392,12 +380,6 @@ void Config_LoadConfig()
|
|||
config.font.size = ConfigGetParamInt(g_configVideoGliden64, "fontSize");
|
||||
if (config.font.size == 0)
|
||||
config.font.size = 30;
|
||||
//#Bloom filter settings
|
||||
config.bloomFilter.enable = ConfigGetParamBool(g_configVideoGliden64, "EnableBloom");
|
||||
config.bloomFilter.thresholdLevel = ConfigGetParamInt(g_configVideoGliden64, "bloomThresholdLevel");
|
||||
config.bloomFilter.blendMode = ConfigGetParamInt(g_configVideoGliden64, "bloomBlendMode");
|
||||
config.bloomFilter.blurAmount = ConfigGetParamInt(g_configVideoGliden64, "blurAmount");
|
||||
config.bloomFilter.blurStrength = ConfigGetParamInt(g_configVideoGliden64, "blurStrength");
|
||||
|
||||
//#Gamma correction settings
|
||||
config.gammaCorrection.force = ConfigGetParamBool(g_configVideoGliden64, "ForceGammaCorrection");
|
||||
|
|
Loading…
Reference in New Issue
Block a user