summaryrefslogtreecommitdiffstats
path: root/src/extras
diff options
context:
space:
mode:
Diffstat (limited to 'src/extras')
-rw-r--r--src/extras/frontendoption.cpp173
-rw-r--r--src/extras/frontendoption.h87
-rw-r--r--src/extras/postfx.cpp199
-rw-r--r--src/extras/postfx.h12
-rw-r--r--src/extras/shaders/Makefile10
-rw-r--r--src/extras/shaders/colourfilterIII_PS.csobin452 -> 0 bytes
-rw-r--r--src/extras/shaders/colourfilterIII_PS.inc40
-rw-r--r--src/extras/shaders/colourfilterVC.frag (renamed from src/extras/shaders/colourfilterIII.frag)0
-rw-r--r--src/extras/shaders/colourfilterVC_PS.csobin0 -> 648 bytes
-rw-r--r--src/extras/shaders/colourfilterVC_PS.hlsl (renamed from src/extras/shaders/colourfilterIII_PS.hlsl)10
-rw-r--r--src/extras/shaders/colourfilterVC_PS.inc56
-rw-r--r--src/extras/shaders/colourfilterVC_fs_gl3.inc (renamed from src/extras/shaders/colourfilterIII_fs_gl3.inc)2
12 files changed, 190 insertions, 399 deletions
diff --git a/src/extras/frontendoption.cpp b/src/extras/frontendoption.cpp
deleted file mode 100644
index 51814f35..00000000
--- a/src/extras/frontendoption.cpp
+++ /dev/null
@@ -1,173 +0,0 @@
-#include "common.h"
-
-#ifdef CUSTOM_FRONTEND_OPTIONS
-#include "frontendoption.h"
-
-int numCustomFrontendOptions = 0;
-FrontendOption *customFrontendOptions;
-
-int optionCursor = -1;
-eMenuScreen currentMenu;
-
-void ChangeScreen(eMenuScreen screen, int option, bool fadeIn)
-{
- FrontEndMenuManager.m_nPrevScreen = FrontEndMenuManager.m_nCurrScreen;
- FrontEndMenuManager.m_nCurrScreen = screen;
- FrontEndMenuManager.m_nCurrOption = option;
- if (fadeIn)
- FrontEndMenuManager.m_nMenuFadeAlpha = 0;
-}
-
-void GoBack(bool fadeIn)
-{
- int screen = !FrontEndMenuManager.m_bGameNotLoaded ?
- aScreens[FrontEndMenuManager.m_nCurrScreen].m_PreviousPage[1] : aScreens[FrontEndMenuManager.m_nCurrScreen].m_PreviousPage[0];
- int option = !FrontEndMenuManager.m_bGameNotLoaded ?
- aScreens[FrontEndMenuManager.m_nCurrScreen].m_ParentEntry[1] : aScreens[FrontEndMenuManager.m_nCurrScreen].m_ParentEntry[0];
-
- FrontEndMenuManager.ThingsToDoBeforeGoingBack();
-
- ChangeScreen((eMenuScreen)screen, option, fadeIn);
-}
-
-uint8
-GetNumberOfMenuOptions(int screen)
-{
- uint8 Rows = 0;
- for (int i = 0; i < NUM_MENUROWS; i++) {
- if (aScreens[screen].m_aEntries[i].m_Action == MENUACTION_NOTHING)
- break;
-
- ++Rows;
- }
- return Rows;
-}
-
-// Used before populating options, but effective in InitialiseChangedLanguageSettings and debugmenu
-void
-RemoveCustomFrontendOptions()
-{
- if (numCustomFrontendOptions == 0)
- return;
-
- for (int i = 0; i < MENUPAGES; i++) {
- for (int j = 0; j < NUM_MENUROWS; j++) {
- if (aScreens[i].m_aEntries[j].m_Action == MENUACTION_TRIGGERFUNC) {
- int k;
- for (k = j; k < NUM_MENUROWS-1; k++) {
- memcpy(&aScreens[i].m_aEntries[k], &aScreens[i].m_aEntries[k+1], sizeof(CMenuScreen::CMenuEntry));
- }
- aScreens[i].m_aEntries[k].m_Action = MENUACTION_NOTHING;
- aScreens[i].m_aEntries[k].m_EntryName[0] = '\0';
- j--;
- }
- }
- }
- free(customFrontendOptions);
- numCustomFrontendOptions = 0;
-}
-
-int8 RegisterNewOption(int screen)
-{
- numCustomFrontendOptions++;
- if (numCustomFrontendOptions == 1)
- customFrontendOptions = (FrontendOption*)malloc(5 * sizeof(FrontendOption));
- else if (numCustomFrontendOptions % 5 == 1)
- customFrontendOptions = (FrontendOption*)realloc(customFrontendOptions, (numCustomFrontendOptions + 4) * sizeof(FrontendOption));
-
- assert(customFrontendOptions != nil && "Custom frontend options can't be allocated");
-
- uint8 nth = GetNumberOfMenuOptions(screen);
- if (optionCursor < 0) {
- if (optionCursor == -1) {
- if (!strcmp(aScreens[screen].m_aEntries[nth - 1].m_EntryName, "FEDS_TB") || !strcmp(aScreens[screen].m_aEntries[nth - 1].m_EntryName, "FESZ_CA")) {
- // Move back button one below
- memcpy(&aScreens[screen].m_aEntries[nth], &aScreens[screen].m_aEntries[nth - 1], sizeof(CMenuScreen::CMenuEntry));
- nth--;
- }
- }
- } else {
- if (aScreens[screen].m_aEntries[optionCursor].m_Action != MENUACTION_NOTHING) {
- for (int i = nth - 1; i >= optionCursor; i--) {
- memcpy(&aScreens[screen].m_aEntries[i + 1], &aScreens[screen].m_aEntries[i], sizeof(CMenuScreen::CMenuEntry));
- }
- }
- nth = optionCursor;
- optionCursor++;
- }
-
- aScreens[screen].m_aEntries[nth].m_Action = MENUACTION_TRIGGERFUNC;
- aScreens[screen].m_aEntries[nth].m_TargetMenu = numCustomFrontendOptions - 1;
- aScreens[screen].m_aEntries[nth].m_EntryName[0] = 1; // just something to fool it
- return nth;
-}
-
-void FrontendOptionSetPosition(eMenuScreen screen, int8 option)
-{
- currentMenu = screen;
- optionCursor = option;
-}
-
-void FrontendOptionAddSelect(const wchar* leftText, const wchar** rightTexts, int8 numRightTexts, int8 *var, bool onlyApplyOnEnter, ChangeFunc changeFunc, ReturnPrevPageFunc returnPrevPageFunc)
-{
- int8 screenOptionOrder = RegisterNewOption(currentMenu);
-
- FrontendOption& option = customFrontendOptions[numCustomFrontendOptions - 1];
- option.screen = currentMenu;
- option.type = FEOPTION_SELECT;
- option.leftText = leftText;
- option.rightTexts = rightTexts;
- option.numRightTexts = numRightTexts;
- option.value = var;
- option.displayedValue = *var;
- option.onlyApplyOnEnter = onlyApplyOnEnter;
- option.changeFunc = changeFunc;
- option.screenOptionOrder = screenOptionOrder;
- option.returnPrevPageFunc = returnPrevPageFunc;
-}
-
-void FrontendOptionAddDynamic(const wchar* leftText, DrawFunc drawFunc, ButtonPressFunc buttonPressFunc, ReturnPrevPageFunc returnPrevPageFunc)
-{
- int8 screenOptionOrder = RegisterNewOption(currentMenu);
-
- FrontendOption& option = customFrontendOptions[numCustomFrontendOptions - 1];
- option.screen = currentMenu;
- option.type = FEOPTION_DYNAMIC;
- option.drawFunc = drawFunc;
- option.buttonPressFunc = buttonPressFunc;
- option.leftText = leftText;
- option.onlyApplyOnEnter = false;
- option.screenOptionOrder = screenOptionOrder;
- option.returnPrevPageFunc = returnPrevPageFunc;
-}
-
-void FrontendOptionAddRedirect(const wchar* text, eMenuScreen to, int8 selectedOption, bool fadeIn)
-{
- int8 screenOptionOrder = RegisterNewOption(currentMenu);
-
- FrontendOption &option = customFrontendOptions[numCustomFrontendOptions - 1];
- option.screen = currentMenu;
- option.type = FEOPTION_REDIRECT;
- option.to = to;
- option.option = selectedOption;
- option.fadeIn = fadeIn;
- option.leftText = text;
- option.onlyApplyOnEnter = false;
- option.screenOptionOrder = screenOptionOrder;
- option.returnPrevPageFunc = nil;
-}
-
-void FrontendOptionAddBackButton(const wchar* text, bool fadeIn)
-{
- int8 screenOptionOrder = RegisterNewOption(currentMenu);
-
- FrontendOption& option = customFrontendOptions[numCustomFrontendOptions - 1];
- option.screen = currentMenu;
- option.type = FEOPTION_GOBACK;
- option.fadeIn = fadeIn;
- option.leftText = text;
- option.onlyApplyOnEnter = false;
- option.screenOptionOrder = screenOptionOrder;
- option.returnPrevPageFunc = nil;
-}
-#endif \ No newline at end of file
diff --git a/src/extras/frontendoption.h b/src/extras/frontendoption.h
deleted file mode 100644
index 7cfc09a7..00000000
--- a/src/extras/frontendoption.h
+++ /dev/null
@@ -1,87 +0,0 @@
-#pragma once
-#include "common.h"
-
-#ifdef CUSTOM_FRONTEND_OPTIONS
-#include "Frontend.h"
-
-// Warning: All of the code relies on that you won't use more then NUM_MENUROWS(18) options on one page. Also congrats if you can make 18 options visible at once.
-
-
-// Static/select: User allocates variable, passes it to function and it's set automatically from input among the strings given to function,
-// then you can handle ChangeFunc and ReturnPrevPageFunc if needed.
-//
-// Dynamic: Function doesn't accept value pointer, user should do operations with handling ButtonPressFunc.
-// Right-side text can be set via DrawFunc, which is called on every draw. ReturnPrevPageFunc is also here if needed.
-
-#define FEOPTION_SELECT 0
-#define FEOPTION_DYNAMIC 1
-#define FEOPTION_REDIRECT 2
-#define FEOPTION_GOBACK 3
-
-#define FEOPTION_ACTION_LEFT 0
-#define FEOPTION_ACTION_RIGHT 1
-#define FEOPTION_ACTION_SELECT 2
-#define FEOPTION_ACTION_FOCUSLOSS 3
-
-void RemoveCustomFrontendOptions();
-void CustomFrontendOptionsPopulate();
-
-// for static and dynamic options
-typedef void (*ReturnPrevPageFunc)();
-
-// for static options
-typedef void (*ChangeFunc)(int8 displayedValue); // called before updating the value
-
-// for dynamic options
-typedef wchar* (*DrawFunc)(bool* disabled); // should return pointer to right text. *disabled = true will make it dark yellow
-typedef void (*ButtonPressFunc)(int8 action); // see FEOPTION_ACTIONs above
-
-struct FrontendOption
-{
- int8 type;
- int8 screenOptionOrder;
- eMenuScreen screen;
- const wchar* leftText;
- ReturnPrevPageFunc returnPrevPageFunc;
-
- union {
- // Only for dynamic
- struct {
- DrawFunc drawFunc;
- ButtonPressFunc buttonPressFunc;
- };
-
- // Only for static/select
- struct {
- const wchar** rightTexts;
- int8 numRightTexts;
- int8 *value;
- int8 displayedValue; // if onlyApplyOnEnter enabled
- bool onlyApplyOnEnter;
- ChangeFunc changeFunc;
- };
-
- // Only for redirect
- struct {
- eMenuScreen to;
- int8 option;
- bool fadeIn;
- };
- };
-};
-
-extern int numCustomFrontendOptions;
-extern FrontendOption* customFrontendOptions;
-
-// To be used in ButtonPressFunc / ChangeFunc(but that would be weird):
-void ChangeScreen(eMenuScreen screen, int option = 0, bool fadeIn = true);
-void GoBack(bool fadeIn = true);
-
-// If option is positive number, all calls will increase it before using it (you can think it as cursor). -1 means before the back button, -2 is end of page
-void FrontendOptionSetPosition(eMenuScreen screen, int8 option = -1);
-
-void FrontendOptionAddSelect(const wchar* leftText, const wchar** rightTexts, int8 numRightTexts, int8 *var, bool onlyApplyOnEnter, ChangeFunc changeFunc, ReturnPrevPageFunc returnPrevPageFunc);
-void FrontendOptionAddDynamic(const wchar* leftText, DrawFunc rightTextDrawFunc, ButtonPressFunc buttonPressFunc, ReturnPrevPageFunc returnPrevPageFunc);
-void FrontendOptionAddRedirect(const wchar* text, eMenuScreen to, int8 selectedOption = 0, bool fadeIn = true);
-void FrontendOptionAddBackButton(const wchar* text, bool fadeIn = true);
-#endif \ No newline at end of file
diff --git a/src/extras/postfx.cpp b/src/extras/postfx.cpp
index 6355dfb1..7e9df4e7 100644
--- a/src/extras/postfx.cpp
+++ b/src/extras/postfx.cpp
@@ -17,6 +17,7 @@ RwRaster *CPostFX::pFrontBuffer;
RwRaster *CPostFX::pBackBuffer;
bool CPostFX::bJustInitialised;
int CPostFX::EffectSwitch = POSTFX_NORMAL;
+bool CPostFX::BlurOn = false;
bool CPostFX::MotionBlurOn = false;
static RwIm2DVertex Vertex[4];
@@ -24,14 +25,14 @@ static RwIm2DVertex Vertex2[4];
static RwImVertexIndex Index[6] = { 0, 1, 2, 0, 2, 3 };
#ifdef RW_D3D9
-void *colourfilterIII_PS;
+void *colourfilterVC_PS;
void *contrast_PS;
#endif
#ifdef RW_OPENGL
int32 u_blurcolor;
int32 u_contrastAdd;
int32 u_contrastMult;
-rw::gl3::Shader *colourFilterIII;
+rw::gl3::Shader *colourFilterVC;
rw::gl3::Shader *contrast;
#endif
@@ -142,25 +143,26 @@ CPostFX::Open(RwCamera *cam)
#ifdef RW_D3D9
-#include "shaders/colourfilterIII_PS.inc"
- colourfilterIII_PS = rw::d3d::createPixelShader(colourfilterIII_PS_cso);
+#include "shaders/colourfilterVC_PS.inc"
+ colourfilterVC_PS = rw::d3d::createPixelShader(colourfilterVC_PS_cso);
#include "shaders/contrastPS.inc"
contrast_PS = rw::d3d::createPixelShader(contrastPS_cso);
#endif
#ifdef RW_OPENGL
using namespace rw::gl3;
+
{
#ifdef RW_GLES2
#include "gl2_shaders/im2d_gl2.inc"
-#include "gl2_shaders/colourfilterIII_fs_gl2.inc"
+#include "gl2_shaders/colourfilterVC_fs_gl2.inc"
#else
#include "shaders/im2d_gl3.inc"
-#include "shaders/colourfilterIII_fs_gl3.inc"
+#include "shaders/colourfilterVC_fs_gl3.inc"
#endif
const char *vs[] = { shaderDecl, header_vert_src, im2d_vert_src, nil };
- const char *fs[] = { shaderDecl, header_frag_src, colourfilterIII_frag_src, nil };
- colourFilterIII = Shader::create(vs, fs);
- assert(colourFilterIII);
+ const char *fs[] = { shaderDecl, header_frag_src, colourfilterVC_frag_src, nil };
+ colourFilterVC = Shader::create(vs, fs);
+ assert(colourFilterVC);
}
{
@@ -192,9 +194,9 @@ CPostFX::Close(void)
pBackBuffer = nil;
}
#ifdef RW_D3D9
- if(colourfilterIII_PS){
- rw::d3d::destroyPixelShader(colourfilterIII_PS);
- colourfilterIII_PS = nil;
+ if(colourfilterVC_PS){
+ rw::d3d::destroyPixelShader(colourfilterVC_PS);
+ colourfilterVC_PS = nil;
}
if(contrast_PS){
rw::d3d::destroyPixelShader(contrast_PS);
@@ -202,9 +204,9 @@ CPostFX::Close(void)
}
#endif
#ifdef RW_OPENGL
- if(colourFilterIII){
- colourFilterIII->destroy();
- colourFilterIII = nil;
+ if(colourFilterVC){
+ colourFilterVC->destroy();
+ colourFilterVC = nil;
}
if(contrast){
contrast->destroy();
@@ -219,37 +221,35 @@ CPostFX::RenderOverlayBlur(RwCamera *cam, int32 r, int32 g, int32 b, int32 a)
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, pFrontBuffer);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
- RwIm2DVertexSetIntRGBA(&Vertex[0], r, g, b, a);
- RwIm2DVertexSetIntRGBA(&Vertex[1], r, g, b, a);
- RwIm2DVertexSetIntRGBA(&Vertex[2], r, g, b, a);
- RwIm2DVertexSetIntRGBA(&Vertex[3], r, g, b, a);
+ RwIm2DVertexSetIntRGBA(&Vertex[0], r*2, g*2, b*2, 30);
+ RwIm2DVertexSetIntRGBA(&Vertex[1], r*2, g*2, b*2, 30);
+ RwIm2DVertexSetIntRGBA(&Vertex[2], r*2, g*2, b*2, 30);
+ RwIm2DVertexSetIntRGBA(&Vertex[3], r*2, g*2, b*2, 30);
+ RwIm2DVertexSetIntRGBA(&Vertex2[0], r*2, g*2, b*2, 30);
+ RwIm2DVertexSetIntRGBA(&Vertex2[1], r*2, g*2, b*2, 30);
+ RwIm2DVertexSetIntRGBA(&Vertex2[2], r*2, g*2, b*2, 30);
+ RwIm2DVertexSetIntRGBA(&Vertex2[3], r*2, g*2, b*2, 30);
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
- RwIm2DRenderIndexedPrimitive(rwPRIMTYPETRILIST, Vertex, 4, Index, 6);
-}
+ RwIm2DRenderIndexedPrimitive(rwPRIMTYPETRILIST, BlurOn ? Vertex2 : Vertex, 4, Index, 6);
-void
-CPostFX::RenderOverlaySimple(RwCamera *cam, int32 r, int32 g, int32 b, int32 a)
-{
- RwRenderStateSet(rwRENDERSTATETEXTURERASTER, nil);
- RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
-
- r *= 0.6f;
- g *= 0.6f;
- b *= 0.6f;
- a *= 0.6f;
+ RwIm2DVertexSetIntRGBA(&Vertex2[0], r, g, b, a);
RwIm2DVertexSetIntRGBA(&Vertex[0], r, g, b, a);
+ RwIm2DVertexSetIntRGBA(&Vertex2[1], r, g, b, a);
RwIm2DVertexSetIntRGBA(&Vertex[1], r, g, b, a);
+ RwIm2DVertexSetIntRGBA(&Vertex2[2], r, g, b, a);
RwIm2DVertexSetIntRGBA(&Vertex[2], r, g, b, a);
+ RwIm2DVertexSetIntRGBA(&Vertex2[3], r, g, b, a);
RwIm2DVertexSetIntRGBA(&Vertex[3], r, g, b, a);
- RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
- RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
+ RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDONE);
+ RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE);
RwIm2DRenderIndexedPrimitive(rwPRIMTYPETRILIST, Vertex, 4, Index, 6);
+ RwIm2DRenderIndexedPrimitive(rwPRIMTYPETRILIST, BlurOn ? Vertex2 : Vertex, 4, Index, 6);
}
void
@@ -277,12 +277,12 @@ CPostFX::RenderOverlayShader(RwCamera *cam, int32 r, int32 g, int32 b, int32 a)
if(EffectSwitch == POSTFX_MOBILE){
float mult[3], add[3];
- mult[0] = (r-64)/384.0f + 1.14f;
- mult[1] = (g-64)/384.0f + 1.14f;
- mult[2] = (b-64)/384.0f + 1.14f;
- add[0] = r/1536.f;
- add[1] = g/1536.f;
- add[2] = b/1536.f;
+ mult[0] = (r-64)/256.0f + 1.4f;
+ mult[1] = (g-64)/256.0f + 1.4f;
+ mult[2] = (b-64)/256.0f + 1.4f;
+ add[0] = r/1536.f - 0.05f;
+ add[1] = g/1536.f - 0.05f;
+ add[2] = b/1536.f - 0.05f;
#ifdef RW_D3D9
rw::d3d::d3ddevice->SetPixelShaderConstantF(10, mult, 1);
rw::d3d::d3ddevice->SetPixelShaderConstantF(11, add, 1);
@@ -298,18 +298,18 @@ CPostFX::RenderOverlayShader(RwCamera *cam, int32 r, int32 g, int32 b, int32 a)
}else{
float f = Intensity;
float blurcolors[4];
- blurcolors[0] = r/255.0f;
- blurcolors[1] = g/255.0f;
- blurcolors[2] = b/255.0f;
- blurcolors[3] = a*f/255.0f;
+ blurcolors[0] = r*f/255.0f;
+ blurcolors[1] = g*f/255.0f;
+ blurcolors[2] = b*f/255.0f;
+ blurcolors[3] = 30/255.0f;
#ifdef RW_D3D9
rw::d3d::d3ddevice->SetPixelShaderConstantF(10, blurcolors, 1);
- rw::d3d::im2dOverridePS = colourfilterIII_PS;
+ rw::d3d::im2dOverridePS = colourfilterVC_PS;
#endif
#ifdef RW_OPENGL
- rw::gl3::im2dOverrideShader = colourFilterIII;
- colourFilterIII->use();
- glUniform4fv(colourFilterIII->uniformLocations[u_blurcolor], 1, blurcolors);
+ rw::gl3::im2dOverrideShader = colourFilterVC;
+ colourFilterVC->use();
+ glUniform4fv(colourFilterVC->uniformLocations[u_blurcolor], 1, blurcolors);
#endif
}
RwIm2DRenderIndexedPrimitive(rwPRIMTYPETRILIST, Vertex, 4, Index, 6);
@@ -346,9 +346,8 @@ CPostFX::NeedBackBuffer(void)
// Current frame -- needed for non-blur effect
switch(EffectSwitch){
case POSTFX_OFF:
- // no actual rendering here
- return false;
case POSTFX_SIMPLE:
+ // no actual rendering here
return false;
case POSTFX_NORMAL:
if(MotionBlurOn)
@@ -365,56 +364,43 @@ bool
CPostFX::NeedFrontBuffer(int32 type)
{
// Last frame -- needed for motion blur
- if(MotionBlurOn)
+ if(CMBlur::Drunkness > 0.0f)
return true;
if(type == MOTION_BLUR_SNIPER)
return true;
+ switch(EffectSwitch){
+ case POSTFX_OFF:
+ case POSTFX_SIMPLE:
+ // no actual rendering here
+ return false;
+ case POSTFX_NORMAL:
+ if(MotionBlurOn)
+ return true;
+ else
+ return false;
+ case POSTFX_MOBILE:
+ return false;
+ }
return false;
}
void
CPostFX::Render(RwCamera *cam, uint32 red, uint32 green, uint32 blue, uint32 blur, int32 type, uint32 bluralpha)
{
- switch(type)
- {
- case MOTION_BLUR_SECURITY_CAM:
- red = 0;
- green = 255;
- blue = 0;
- blur = 128;
- break;
- case MOTION_BLUR_INTRO:
- red = 100;
- green = 220;
- blue = 230;
- blur = 158;
- break;
- case MOTION_BLUR_INTRO2:
- red = 80;
- green = 255;
- blue = 230;
- blur = 138;
- break;
- case MOTION_BLUR_INTRO3:
- red = 255;
- green = 60;
- blue = 60;
- blur = 200;
- break;
- case MOTION_BLUR_INTRO4:
- red = 255;
- green = 180;
- blue = 180;
- blur = 128;
- break;
- }
-
if(pFrontBuffer == nil)
Open(cam);
assert(pFrontBuffer);
assert(pBackBuffer);
+ if(type == MOTION_BLUR_LIGHT_SCENE){
+ SmoothColor(red, green, blue, blur);
+ red = AvgRed;
+ green = AvgGreen;
+ blue = AvgBlue;
+ blur = AvgAlpha;
+ }
+
if(NeedBackBuffer()){
RwRasterPushContext(pBackBuffer);
RwRasterRenderFast(RwCameraGetRaster(cam), 0, 0);
@@ -433,10 +419,8 @@ CPostFX::Render(RwCamera *cam, uint32 red, uint32 green, uint32 blue, uint32 blu
RenderOverlaySniper(cam, red, green, blue, blur);
}else switch(EffectSwitch){
case POSTFX_OFF:
- // no actual rendering here
- break;
case POSTFX_SIMPLE:
- RenderOverlaySimple(cam, red, green, blue, blur);
+ // no actual rendering here
break;
case POSTFX_NORMAL:
if(MotionBlurOn){
@@ -451,10 +435,8 @@ CPostFX::Render(RwCamera *cam, uint32 red, uint32 green, uint32 blue, uint32 blu
break;
}
- // TODO? maybe we want this even without motion blur on sometimes?
- if(MotionBlurOn)
- if(!bJustInitialised)
- RenderMotionBlur(cam, bluralpha);
+ if(!bJustInitialised)
+ RenderMotionBlur(cam, 175.0f * CMBlur::Drunkness);
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE);
@@ -472,4 +454,39 @@ CPostFX::Render(RwCamera *cam, uint32 red, uint32 green, uint32 blue, uint32 blu
bJustInitialised = true;
}
+int CPostFX::PrevRed[NUMAVERAGE], CPostFX::AvgRed;
+int CPostFX::PrevGreen[NUMAVERAGE], CPostFX::AvgGreen;
+int CPostFX::PrevBlue[NUMAVERAGE], CPostFX::AvgBlue;
+int CPostFX::PrevAlpha[NUMAVERAGE], CPostFX::AvgAlpha;
+int CPostFX::Next;
+int CPostFX::NumValues;
+
+// This is rather annoying...the blur color can flicker slightly
+// which becomes very visible when amplified by the shader
+void
+CPostFX::SmoothColor(uint32 red, uint32 green, uint32 blue, uint32 alpha)
+{
+ PrevRed[Next] = red;
+ PrevGreen[Next] = green;
+ PrevBlue[Next] = blue;
+ PrevAlpha[Next] = alpha;
+ Next = (Next+1) % NUMAVERAGE;
+ NumValues = Min(NumValues+1, NUMAVERAGE);
+
+ AvgRed = 0;
+ AvgGreen = 0;
+ AvgBlue = 0;
+ AvgAlpha = 0;
+ for(int i = 0; i < NumValues; i++){
+ AvgRed += PrevRed[i];
+ AvgGreen += PrevGreen[i];
+ AvgBlue += PrevBlue[i];
+ AvgAlpha += PrevAlpha[i];
+ }
+ AvgRed /= NumValues;
+ AvgGreen /= NumValues;
+ AvgBlue /= NumValues;
+ AvgAlpha /= NumValues;
+}
+
#endif
diff --git a/src/extras/postfx.h b/src/extras/postfx.h
index 658c2d88..ace2e4a8 100644
--- a/src/extras/postfx.h
+++ b/src/extras/postfx.h
@@ -15,18 +15,28 @@ public:
static RwRaster *pBackBuffer;
static bool bJustInitialised;
static int EffectSwitch;
+ static bool BlurOn; // or use CMblur for that?
static bool MotionBlurOn; // or use CMblur for that?
static float Intensity;
+ // smooth blur color
+ enum { NUMAVERAGE = 20 };
+ static int PrevRed[NUMAVERAGE], AvgRed;
+ static int PrevGreen[NUMAVERAGE], AvgGreen;
+ static int PrevBlue[NUMAVERAGE], AvgBlue;
+ static int PrevAlpha[NUMAVERAGE], AvgAlpha;
+ static int Next;
+ static int NumValues;
+
static void InitOnce(void);
static void Open(RwCamera *cam);
static void Close(void);
static void RenderOverlayBlur(RwCamera *cam, int32 r, int32 g, int32 b, int32 a);
- static void RenderOverlaySimple(RwCamera *cam, int32 r, int32 g, int32 b, int32 a);
static void RenderOverlaySniper(RwCamera *cam, int32 r, int32 g, int32 b, int32 a);
static void RenderOverlayShader(RwCamera *cam, int32 r, int32 g, int32 b, int32 a);
static void RenderMotionBlur(RwCamera *cam, uint32 blur);
static void Render(RwCamera *cam, uint32 red, uint32 green, uint32 blue, uint32 blur, int32 type, uint32 bluralpha);
+ static void SmoothColor(uint32 red, uint32 green, uint32 blue, uint32 alpha);
static bool NeedBackBuffer(void);
static bool NeedFrontBuffer(int32 type);
static bool UseBlurColours(void) { return EffectSwitch != POSTFX_SIMPLE; }
diff --git a/src/extras/shaders/Makefile b/src/extras/shaders/Makefile
index 87be011e..effb6afc 100644
--- a/src/extras/shaders/Makefile
+++ b/src/extras/shaders/Makefile
@@ -1,14 +1,14 @@
-all: im2d_gl3.inc colourfilterIII_fs_gl3.inc contrast_fs_gl3.inc
+all: im2d_gl3.inc colourfilterVC_fs_gl3.inc contrast_fs_gl3.inc
im2d_gl3.inc: im2d.vert
(echo 'const char *im2d_vert_src =';\
sed 's/..*/"&\\n"/' im2d.vert;\
echo ';') >im2d_gl3.inc
-colourfilterIII_fs_gl3.inc: colourfilterIII.frag
- (echo 'const char *colourfilterIII_frag_src =';\
- sed 's/..*/"&\\n"/' colourfilterIII.frag;\
- echo ';') >colourfilterIII_fs_gl3.inc
+colourfilterVC_fs_gl3.inc: colourfilterVC.frag
+ (echo 'const char *colourfilterVC_frag_src =';\
+ sed 's/..*/"&\\n"/' colourfilterVC.frag;\
+ echo ';') >colourfilterVC_fs_gl3.inc
contrast_fs_gl3.inc: contrast.frag
(echo 'const char *contrast_frag_src =';\
diff --git a/src/extras/shaders/colourfilterIII_PS.cso b/src/extras/shaders/colourfilterIII_PS.cso
deleted file mode 100644
index cc41bcec..00000000
--- a/src/extras/shaders/colourfilterIII_PS.cso
+++ /dev/null
Binary files differ
diff --git a/src/extras/shaders/colourfilterIII_PS.inc b/src/extras/shaders/colourfilterIII_PS.inc
deleted file mode 100644
index db49de6c..00000000
--- a/src/extras/shaders/colourfilterIII_PS.inc
+++ /dev/null
@@ -1,40 +0,0 @@
-static unsigned char colourfilterIII_PS_cso[] = {
- 0x00, 0x02, 0xff, 0xff, 0xfe, 0xff, 0x2b, 0x00, 0x43, 0x54, 0x41, 0x42,
- 0x1c, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xff,
- 0x02, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
- 0x70, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0a, 0x00,
- 0x01, 0x00, 0x2a, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x5c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00,
- 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x6c, 0x75, 0x72,
- 0x63, 0x6f, 0x6c, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0x65, 0x78, 0x00,
- 0x04, 0x00, 0x0c, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x70, 0x73, 0x5f, 0x32, 0x5f, 0x30, 0x00, 0x4d,
- 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29,
- 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72,
- 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x39, 0x2e,
- 0x32, 0x39, 0x2e, 0x39, 0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00,
- 0x51, 0x00, 0x00, 0x05, 0x00, 0x00, 0x0f, 0xa0, 0x00, 0x00, 0x80, 0x3f,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x03, 0xb0,
- 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x90, 0x00, 0x08, 0x0f, 0xa0,
- 0x42, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xb0,
- 0x00, 0x08, 0xe4, 0xa0, 0x05, 0x00, 0x00, 0x03, 0x01, 0x00, 0x07, 0x80,
- 0x00, 0x00, 0xe4, 0x80, 0x0a, 0x00, 0xe4, 0xa0, 0x12, 0x00, 0x00, 0x04,
- 0x02, 0x00, 0x17, 0x80, 0x0a, 0x00, 0xff, 0xa0, 0x01, 0x00, 0xe4, 0x80,
- 0x00, 0x00, 0xe4, 0x80, 0x05, 0x00, 0x00, 0x03, 0x01, 0x00, 0x07, 0x80,
- 0x02, 0x00, 0xe4, 0x80, 0x0a, 0x00, 0xe4, 0xa0, 0x12, 0x00, 0x00, 0x04,
- 0x02, 0x00, 0x17, 0x80, 0x0a, 0x00, 0xff, 0xa0, 0x01, 0x00, 0xe4, 0x80,
- 0x00, 0x00, 0xe4, 0x80, 0x05, 0x00, 0x00, 0x03, 0x01, 0x00, 0x07, 0x80,
- 0x02, 0x00, 0xe4, 0x80, 0x0a, 0x00, 0xe4, 0xa0, 0x12, 0x00, 0x00, 0x04,
- 0x02, 0x00, 0x17, 0x80, 0x0a, 0x00, 0xff, 0xa0, 0x01, 0x00, 0xe4, 0x80,
- 0x00, 0x00, 0xe4, 0x80, 0x05, 0x00, 0x00, 0x03, 0x01, 0x00, 0x07, 0x80,
- 0x02, 0x00, 0xe4, 0x80, 0x0a, 0x00, 0xe4, 0xa0, 0x12, 0x00, 0x00, 0x04,
- 0x02, 0x00, 0x17, 0x80, 0x0a, 0x00, 0xff, 0xa0, 0x01, 0x00, 0xe4, 0x80,
- 0x00, 0x00, 0xe4, 0x80, 0x05, 0x00, 0x00, 0x03, 0x01, 0x00, 0x07, 0x80,
- 0x02, 0x00, 0xe4, 0x80, 0x0a, 0x00, 0xe4, 0xa0, 0x12, 0x00, 0x00, 0x04,
- 0x02, 0x00, 0x17, 0x80, 0x0a, 0x00, 0xff, 0xa0, 0x01, 0x00, 0xe4, 0x80,
- 0x00, 0x00, 0xe4, 0x80, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x08, 0x80,
- 0x00, 0x00, 0x00, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x00, 0x08, 0x0f, 0x80,
- 0x02, 0x00, 0xe4, 0x80, 0xff, 0xff, 0x00, 0x00
-};
diff --git a/src/extras/shaders/colourfilterIII.frag b/src/extras/shaders/colourfilterVC.frag
index e19a8600..e19a8600 100644
--- a/src/extras/shaders/colourfilterIII.frag
+++ b/src/extras/shaders/colourfilterVC.frag
diff --git a/src/extras/shaders/colourfilterVC_PS.cso b/src/extras/shaders/colourfilterVC_PS.cso
new file mode 100644
index 00000000..4b0e9f3f
--- /dev/null
+++ b/src/extras/shaders/colourfilterVC_PS.cso
Binary files differ
diff --git a/src/extras/shaders/colourfilterIII_PS.hlsl b/src/extras/shaders/colourfilterVC_PS.hlsl
index 27f099ef..1e62950b 100644
--- a/src/extras/shaders/colourfilterIII_PS.hlsl
+++ b/src/extras/shaders/colourfilterVC_PS.hlsl
@@ -1,13 +1,21 @@
sampler2D tex : register(s0);
float4 blurcol : register(c10);
+//float4 blurcols[10] : register(c15);
+
+
float4 main(in float2 texcoord : TEXCOORD0) : COLOR0
{
float a = blurcol.a;
+
+ float4 doublec = saturate(blurcol*2);
float4 dst = tex2D(tex, texcoord.xy);
float4 prev = dst;
for(int i = 0; i < 5; i++){
- float4 tmp = dst*(1-a) + prev*blurcol*a;
+// float4 doublec = saturate(blurcol*2);
+ float4 tmp = dst*(1-a) + prev*doublec*a;
+ tmp += prev*blurcol;
+ tmp += prev*blurcol;
prev = saturate(tmp);
}
prev.a = 1.0f;
diff --git a/src/extras/shaders/colourfilterVC_PS.inc b/src/extras/shaders/colourfilterVC_PS.inc
new file mode 100644
index 00000000..daa18360
--- /dev/null
+++ b/src/extras/shaders/colourfilterVC_PS.inc
@@ -0,0 +1,56 @@
+static unsigned char colourfilterVC_PS_cso[] = {
+ 0x00, 0x02, 0xff, 0xff, 0xfe, 0xff, 0x2b, 0x00, 0x43, 0x54, 0x41, 0x42,
+ 0x1c, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xff,
+ 0x02, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+ 0x70, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0a, 0x00,
+ 0x01, 0x00, 0x2a, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x5c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00,
+ 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x6c, 0x75, 0x72,
+ 0x63, 0x6f, 0x6c, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0x65, 0x78, 0x00,
+ 0x04, 0x00, 0x0c, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x70, 0x73, 0x5f, 0x32, 0x5f, 0x30, 0x00, 0x4d,
+ 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29,
+ 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72,
+ 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x39, 0x2e,
+ 0x32, 0x39, 0x2e, 0x39, 0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00,
+ 0x51, 0x00, 0x00, 0x05, 0x00, 0x00, 0x0f, 0xa0, 0x00, 0x00, 0x00, 0x40,
+ 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x03, 0xb0,
+ 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x90, 0x00, 0x08, 0x0f, 0xa0,
+ 0x42, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xb0,
+ 0x00, 0x08, 0xe4, 0xa0, 0x02, 0x00, 0x00, 0x03, 0x01, 0x00, 0x17, 0x80,
+ 0x0a, 0x00, 0xe4, 0xa0, 0x0a, 0x00, 0xe4, 0xa0, 0x05, 0x00, 0x00, 0x03,
+ 0x02, 0x00, 0x07, 0x80, 0x00, 0x00, 0xe4, 0x80, 0x01, 0x00, 0xe4, 0x80,
+ 0x12, 0x00, 0x00, 0x04, 0x03, 0x00, 0x07, 0x80, 0x0a, 0x00, 0xff, 0xa0,
+ 0x02, 0x00, 0xe4, 0x80, 0x00, 0x00, 0xe4, 0x80, 0x05, 0x00, 0x00, 0x03,
+ 0x02, 0x00, 0x07, 0x80, 0x00, 0x00, 0xe4, 0x80, 0x0a, 0x00, 0xe4, 0xa0,
+ 0x04, 0x00, 0x00, 0x04, 0x02, 0x00, 0x17, 0x80, 0x02, 0x00, 0xe4, 0x80,
+ 0x00, 0x00, 0x00, 0xa0, 0x03, 0x00, 0xe4, 0x80, 0x05, 0x00, 0x00, 0x03,
+ 0x03, 0x00, 0x07, 0x80, 0x01, 0x00, 0xe4, 0x80, 0x02, 0x00, 0xe4, 0x80,
+ 0x05, 0x00, 0x00, 0x03, 0x02, 0x00, 0x07, 0x80, 0x02, 0x00, 0xe4, 0x80,
+ 0x0a, 0x00, 0xe4, 0xa0, 0x12, 0x00, 0x00, 0x04, 0x04, 0x00, 0x07, 0x80,
+ 0x0a, 0x00, 0xff, 0xa0, 0x03, 0x00, 0xe4, 0x80, 0x00, 0x00, 0xe4, 0x80,
+ 0x04, 0x00, 0x00, 0x04, 0x02, 0x00, 0x17, 0x80, 0x02, 0x00, 0xe4, 0x80,
+ 0x00, 0x00, 0x00, 0xa0, 0x04, 0x00, 0xe4, 0x80, 0x05, 0x00, 0x00, 0x03,
+ 0x03, 0x00, 0x07, 0x80, 0x01, 0x00, 0xe4, 0x80, 0x02, 0x00, 0xe4, 0x80,
+ 0x05, 0x00, 0x00, 0x03, 0x02, 0x00, 0x07, 0x80, 0x02, 0x00, 0xe4, 0x80,
+ 0x0a, 0x00, 0xe4, 0xa0, 0x12, 0x00, 0x00, 0x04, 0x04, 0x00, 0x07, 0x80,
+ 0x0a, 0x00, 0xff, 0xa0, 0x03, 0x00, 0xe4, 0x80, 0x00, 0x00, 0xe4, 0x80,
+ 0x04, 0x00, 0x00, 0x04, 0x02, 0x00, 0x17, 0x80, 0x02, 0x00, 0xe4, 0x80,
+ 0x00, 0x00, 0x00, 0xa0, 0x04, 0x00, 0xe4, 0x80, 0x05, 0x00, 0x00, 0x03,
+ 0x03, 0x00, 0x07, 0x80, 0x01, 0x00, 0xe4, 0x80, 0x02, 0x00, 0xe4, 0x80,
+ 0x05, 0x00, 0x00, 0x03, 0x02, 0x00, 0x07, 0x80, 0x02, 0x00, 0xe4, 0x80,
+ 0x0a, 0x00, 0xe4, 0xa0, 0x12, 0x00, 0x00, 0x04, 0x04, 0x00, 0x07, 0x80,
+ 0x0a, 0x00, 0xff, 0xa0, 0x03, 0x00, 0xe4, 0x80, 0x00, 0x00, 0xe4, 0x80,
+ 0x04, 0x00, 0x00, 0x04, 0x02, 0x00, 0x17, 0x80, 0x02, 0x00, 0xe4, 0x80,
+ 0x00, 0x00, 0x00, 0xa0, 0x04, 0x00, 0xe4, 0x80, 0x05, 0x00, 0x00, 0x03,
+ 0x01, 0x00, 0x07, 0x80, 0x01, 0x00, 0xe4, 0x80, 0x02, 0x00, 0xe4, 0x80,
+ 0x05, 0x00, 0x00, 0x03, 0x02, 0x00, 0x07, 0x80, 0x02, 0x00, 0xe4, 0x80,
+ 0x0a, 0x00, 0xe4, 0xa0, 0x12, 0x00, 0x00, 0x04, 0x03, 0x00, 0x07, 0x80,
+ 0x0a, 0x00, 0xff, 0xa0, 0x01, 0x00, 0xe4, 0x80, 0x00, 0x00, 0xe4, 0x80,
+ 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x17, 0x80, 0x02, 0x00, 0xe4, 0x80,
+ 0x00, 0x00, 0x00, 0xa0, 0x03, 0x00, 0xe4, 0x80, 0x01, 0x00, 0x00, 0x02,
+ 0x00, 0x00, 0x08, 0x80, 0x00, 0x00, 0x55, 0xa0, 0x01, 0x00, 0x00, 0x02,
+ 0x00, 0x08, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0x80, 0xff, 0xff, 0x00, 0x00
+};
diff --git a/src/extras/shaders/colourfilterIII_fs_gl3.inc b/src/extras/shaders/colourfilterVC_fs_gl3.inc
index f57b9cdd..acb9b15c 100644
--- a/src/extras/shaders/colourfilterIII_fs_gl3.inc
+++ b/src/extras/shaders/colourfilterVC_fs_gl3.inc
@@ -1,4 +1,4 @@
-const char *colourfilterIII_frag_src =
+const char *colourfilterVC_frag_src =
"uniform sampler2D tex0;\n"
"uniform vec4 u_blurcolor;\n"