diff options
Diffstat (limited to 'src/extras')
21 files changed, 232 insertions, 641 deletions
diff --git a/src/extras/custompipes.cpp b/src/extras/custompipes.cpp index 79254eb4..2b4745e3 100644 --- a/src/extras/custompipes.cpp +++ b/src/extras/custompipes.cpp @@ -338,7 +338,7 @@ ReadTweakValueTable(char *fp, InterpolatedValue &interp) */ int32 VehiclePipeSwitch = VEHICLEPIPE_NEO; -float VehicleShininess = 0.7f; // the default is a bit extreme +float VehicleShininess = 1.0f; float VehicleSpecularity = 1.0f; InterpolatedFloat Fresnel(0.4f); InterpolatedFloat Power(18.0f); diff --git a/src/extras/custompipes_d3d9.cpp b/src/extras/custompipes_d3d9.cpp index bfc744a3..63e91063 100644 --- a/src/extras/custompipes_d3d9.cpp +++ b/src/extras/custompipes_d3d9.cpp @@ -181,7 +181,7 @@ DestroyVehiclePipe(void) */ static void *neoWorld_VS; -static void *neoWorldIII_PS; +static void *neoWorldVC_PS; static void worldRenderCB(rw::Atomic *atomic, rw::d3d9::InstanceDataHeader *header) @@ -234,7 +234,7 @@ worldRenderCB(rw::Atomic *atomic, rw::d3d9::InstanceDataHeader *header) d3d::setTexture(0, m->texture); else d3d::setTexture(0, gpWhiteTexture); - setPixelShader(neoWorldIII_PS); + setPixelShader(neoWorldVC_PS); drawInst(header, inst); inst++; @@ -253,9 +253,9 @@ CreateWorldPipe(void) neoWorld_VS = rw::d3d::createVertexShader(default_UV2_VS_cso); assert(neoWorld_VS); -#include "shaders/neoWorldIII_PS.inc" - neoWorldIII_PS = rw::d3d::createPixelShader(neoWorldIII_PS_cso); - assert(neoWorldIII_PS); +#include "shaders/neoWorldVC_PS.inc" + neoWorldVC_PS = rw::d3d::createPixelShader(neoWorldVC_PS_cso); + assert(neoWorldVC_PS); rw::d3d9::ObjPipeline *pipe = rw::d3d9::ObjPipeline::create(); @@ -270,8 +270,8 @@ DestroyWorldPipe(void) { rw::d3d::destroyVertexShader(neoWorld_VS); neoWorld_VS = nil; - rw::d3d::destroyPixelShader(neoWorldIII_PS); - neoWorldIII_PS = nil; + rw::d3d::destroyPixelShader(neoWorldVC_PS); + neoWorldVC_PS = nil; ((rw::d3d9::ObjPipeline*)worldPipe)->destroy(); diff --git a/src/extras/custompipes_gl.cpp b/src/extras/custompipes_gl.cpp index 5717c83b..cb434ea1 100644 --- a/src/extras/custompipes_gl.cpp +++ b/src/extras/custompipes_gl.cpp @@ -272,11 +272,11 @@ CreateWorldPipe(void) #include "gl2_shaders/neoWorldIII_fs_gl2.inc" #include "gl2_shaders/default_UV2_gl2.inc" #else -#include "shaders/neoWorldIII_fs_gl3.inc" +#include "shaders/neoWorldVC_fs_gl3.inc" #include "shaders/default_UV2_gl3.inc" #endif const char *vs[] = { shaderDecl, header_vert_src, default_UV2_vert_src, nil }; - const char *fs[] = { shaderDecl, header_frag_src, neoWorldIII_frag_src, nil }; + const char *fs[] = { shaderDecl, header_frag_src, neoWorldVC_frag_src, nil }; neoWorldShader = Shader::create(vs, fs); assert(neoWorldShader); } diff --git a/src/extras/frontendoption.cpp b/src/extras/frontendoption.cpp deleted file mode 100644 index 88a930a9..00000000 --- a/src/extras/frontendoption.cpp +++ /dev/null @@ -1,303 +0,0 @@ -#include "common.h" - -#ifdef CUSTOM_FRONTEND_OPTIONS -#include "frontendoption.h" -#include "Text.h" - -int numCustomFrontendOptions = 0; -FrontendOption *customFrontendOptions; - -int numCustomFrontendScreens = 0; -FrontendScreen* customFrontendScreens; - -int numFrontendOptionReplacements = 0; -CMenuScreen::CMenuEntry* frontendOptionReplacements; - -int lastOgScreen = MENUPAGES; // means no new pages - -int optionCursor = -2; -int currentMenu; -bool optionOverwrite = false; - -void ChangeScreen(int 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(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; -} - -uint8 -GetLastMenuScreen() -{ - int8 page = -1; - for (int i = 0; i < MENUPAGES; i++) { - if (strcmp(aScreens[i].m_ScreenName, "") == 0 && aScreens[i].unk == 0) - break; - - ++page; - } - return page; -} - -// Used before populating options, but effective in InitialiseChangedLanguageSettings and debugmenu -void -RemoveCustomFrontendOptions() -{ - if (numCustomFrontendOptions != 0) { - - for (int i = 0; i < MENUPAGES; i++) { - for (int j = 0; j < NUM_MENUROWS; j++) { - if (aScreens[i].m_aEntries[j].m_SaveSlot == SAVESLOT_CFO) { - int ogOptionId = customFrontendOptions[aScreens[i].m_aEntries[j].m_TargetMenu].ogOptionId; - - if (customFrontendOptions[aScreens[i].m_aEntries[j].m_TargetMenu].type == FEOPTION_SELECT) - free(customFrontendOptions[aScreens[i].m_aEntries[j].m_TargetMenu].rightTexts); - - if (ogOptionId == -1) { - 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_SaveSlot = SAVESLOT_NONE; - aScreens[i].m_aEntries[k].m_EntryName[0] = '\0'; - j--; - } else { - memcpy(&aScreens[i].m_aEntries[j], &frontendOptionReplacements[ogOptionId], sizeof(CMenuScreen::CMenuEntry)); - } - } - } - } - free(customFrontendOptions); - numCustomFrontendOptions = 0; - - if (numFrontendOptionReplacements != 0) { - free(frontendOptionReplacements); - numFrontendOptionReplacements = 0; - } - } - - if (numCustomFrontendScreens == 0) - return; - - for (int i = 0; i < MENUPAGES; i++) { - if (i > lastOgScreen) { - aScreens[i].m_ScreenName[0] = '\0'; - aScreens[i].unk = 0; - } - } - free(customFrontendScreens); - numCustomFrontendScreens = 0; - lastOgScreen = MENUPAGES; -} - -int8 RegisterNewScreen(const char *name, int prevPage) -{ - if (lastOgScreen == MENUPAGES) - lastOgScreen = GetLastMenuScreen(); - - numCustomFrontendScreens++; - if (numCustomFrontendScreens == 1) - customFrontendScreens = (FrontendScreen*)malloc(5 * sizeof(FrontendScreen)); - else if (numCustomFrontendScreens % 5 == 1) - customFrontendScreens = (FrontendScreen*)realloc(customFrontendScreens, (numCustomFrontendScreens + 4) * sizeof(FrontendScreen)); - - assert(customFrontendScreens != nil && "Custom frontend screens can't be allocated"); - - int id = lastOgScreen + numCustomFrontendScreens; - assert(id < MENUPAGES && "No room for new custom frontend screens! Increase MENUPAGES"); - strncpy(aScreens[id].m_ScreenName, name, 8); - aScreens[id].m_PreviousPage[0] = aScreens[id].m_PreviousPage[1] = prevPage; - aScreens[id].unk = 1; - return id; -} - -int8 RegisterNewOption() -{ - 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 numOptions = GetNumberOfMenuOptions(currentMenu); - uint8 curIdx; - if (optionCursor < 0) { - optionCursor = curIdx = numOptions + optionCursor + 1; - } else - curIdx = optionCursor; - - if (!optionOverwrite) { - if (aScreens[currentMenu].m_aEntries[curIdx].m_Action != MENUACTION_NOTHING) { - for (int i = numOptions - 1; i >= curIdx; i--) { - memcpy(&aScreens[currentMenu].m_aEntries[i + 1], &aScreens[currentMenu].m_aEntries[i], sizeof(CMenuScreen::CMenuEntry)); - } - } - } - optionCursor++; - - if (optionOverwrite) { - numFrontendOptionReplacements++; - if (numFrontendOptionReplacements == 1) - frontendOptionReplacements = (CMenuScreen::CMenuEntry*)malloc(5 * sizeof(CMenuScreen::CMenuEntry)); - else if (numFrontendOptionReplacements % 5 == 1) - frontendOptionReplacements = (CMenuScreen::CMenuEntry*)realloc(frontendOptionReplacements, (numFrontendOptionReplacements + 4) * sizeof(CMenuScreen::CMenuEntry)); - - memcpy(&frontendOptionReplacements[numFrontendOptionReplacements - 1], &aScreens[currentMenu].m_aEntries[curIdx], sizeof(CMenuScreen::CMenuEntry)); - customFrontendOptions[numCustomFrontendOptions - 1].ogOptionId = numFrontendOptionReplacements - 1; - } else { - customFrontendOptions[numCustomFrontendOptions - 1].ogOptionId = -1; - } - customFrontendOptions[numCustomFrontendOptions - 1].screen = currentMenu; - - aScreens[currentMenu].m_aEntries[curIdx].m_Action = MENUACTION_TRIGGERFUNC; - aScreens[currentMenu].m_aEntries[curIdx].m_SaveSlot = SAVESLOT_CFO; - aScreens[currentMenu].m_aEntries[curIdx].m_TargetMenu = numCustomFrontendOptions - 1; - aScreens[currentMenu].m_aEntries[curIdx].m_EntryName[0] = 1; // just something to fool it - return curIdx; -} - -void FrontendOptionSetCursor(int screen, int8 option, bool overwrite) -{ - currentMenu = screen; - optionCursor = option; - optionOverwrite = overwrite; -} - -void FrontendOptionAddBuiltinAction(const wchar* leftText, int action, ButtonPressFunc buttonPressFunc, ReturnPrevPageFunc returnPrevPageFunc) { - int8 screenOptionOrder = RegisterNewOption(); - - FrontendOption& option = customFrontendOptions[numCustomFrontendOptions - 1]; - - // To fool the Frontend, we will still display the text passed via first param. - switch (action) { - case MENUACTION_SCREENRES: - strcpy(aScreens[currentMenu].m_aEntries[screenOptionOrder].m_EntryName, "FED_RES"); - break; - case MENUACTION_AUDIOHW: - strcpy(aScreens[currentMenu].m_aEntries[screenOptionOrder].m_EntryName, "FEA_3DH"); - break; - } - aScreens[currentMenu].m_aEntries[screenOptionOrder].m_Action = action; - option.type = FEOPTION_BUILTIN_ACTION; - option.buttonPressFunc = buttonPressFunc; - TextCopy(option.leftText, leftText); - option.screenOptionOrder = screenOptionOrder; - option.returnPrevPageFunc = returnPrevPageFunc; - option.save = nil; -} - -void FrontendOptionAddSelect(const wchar* leftText, const wchar** rightTexts, int8 numRightTexts, int8 *var, bool onlyApplyOnEnter, ChangeFunc changeFunc, ReturnPrevPageFunc returnPrevPageFunc, const char* saveName) -{ - int8 screenOptionOrder = RegisterNewOption(); - - FrontendOption& option = customFrontendOptions[numCustomFrontendOptions - 1]; - option.type = FEOPTION_SELECT; - TextCopy(option.leftText, leftText); - option.rightTexts = (wchar**)malloc(numRightTexts * sizeof(wchar*)); - memcpy(option.rightTexts, rightTexts, numRightTexts * sizeof(wchar*)); - option.numRightTexts = numRightTexts; - option.value = var; - option.displayedValue = *var; - option.lastSavedValue = *var; - option.save = saveName; - option.onlyApplyOnEnter = onlyApplyOnEnter; - option.changeFunc = changeFunc; - option.screenOptionOrder = screenOptionOrder; - option.returnPrevPageFunc = returnPrevPageFunc; -} - -void FrontendOptionAddDynamic(const wchar* leftText, DrawFunc drawFunc, int8 *var, ButtonPressFunc buttonPressFunc, ReturnPrevPageFunc returnPrevPageFunc, const char* saveName) -{ - int8 screenOptionOrder = RegisterNewOption(); - - FrontendOption& option = customFrontendOptions[numCustomFrontendOptions - 1]; - option.type = FEOPTION_DYNAMIC; - option.drawFunc = drawFunc; - option.buttonPressFunc = buttonPressFunc; - TextCopy(option.leftText, leftText); - option.value = var; - option.save = saveName; - option.screenOptionOrder = screenOptionOrder; - option.returnPrevPageFunc = returnPrevPageFunc; -} - -void FrontendOptionAddRedirect(const wchar* text, int to, int8 selectedOption, bool fadeIn) -{ - int8 screenOptionOrder = RegisterNewOption(); - - FrontendOption &option = customFrontendOptions[numCustomFrontendOptions - 1]; - option.type = FEOPTION_REDIRECT; - option.to = to; - option.option = selectedOption; - option.fadeIn = fadeIn; - TextCopy(option.leftText, text); - option.screenOptionOrder = screenOptionOrder; - option.returnPrevPageFunc = nil; - option.save = nil; -} - -void FrontendOptionAddBackButton(const wchar* text, bool fadeIn) -{ - int8 screenOptionOrder = RegisterNewOption(); - - FrontendOption& option = customFrontendOptions[numCustomFrontendOptions - 1]; - option.type = FEOPTION_GOBACK; - option.fadeIn = fadeIn; - TextCopy(option.leftText, text); - option.screenOptionOrder = screenOptionOrder; - option.returnPrevPageFunc = nil; - option.save = nil; -} - -uint8 FrontendScreenAdd(const char* gxtKey, eMenuSprites sprite, int prevPage, int columnWidth, int headerHeight, int lineHeight, - int8 font, float fontScaleX, float fontScaleY, int8 alignment, bool showLeftRightHelper, ReturnPrevPageFunc returnPrevPageFunc) { - - uint8 screenOrder = RegisterNewScreen(gxtKey, prevPage); - - FrontendScreen &screen = customFrontendScreens[numCustomFrontendScreens - 1]; - screen.id = screenOrder; - screen.sprite = sprite; - screen.prevPage = prevPage; - strncpy(screen.name, gxtKey, 8); - screen.columnWidth = columnWidth; - screen.headerHeight = headerHeight; - screen.lineHeight = lineHeight; - screen.font = font; - screen.fontScaleX = fontScaleX; - screen.fontScaleY = fontScaleY; - screen.alignment = alignment; - screen.returnPrevPageFunc = returnPrevPageFunc; - - return screenOrder; -} -#endif diff --git a/src/extras/frontendoption.h b/src/extras/frontendoption.h deleted file mode 100644 index dac6be62..00000000 --- a/src/extras/frontendoption.h +++ /dev/null @@ -1,162 +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. - -// About texts: -// All text parameters accept wchar(including hardcoded wchar* and TheText.Get) -// except FrontendScreenAdd(it's char[8] GXT key by the design of Frontend). -// All texts reload if custom options reloaded too, which includes language changes and via live reload feature in debug menu! - -// Execute direction: -// All of the calls below eventually manipulate the aScreens array, so keep in mind to add/replace options in order, -// i.e. don't set cursor to 8 first and then 3. - -// Live reload: -// You can add/change/undo the new options in-game if you use VS. Change what you want, build the changed bits via "Edit and Continue", -// and hit the "Reload custom frontend options" from debug menu. Or call CustomFrontendOptionsPopulate() from somewhere else. - - -// -- Option types -// -// Static/select: You allocate the variable, pass it to function and game sets it from user input among the strings given to function, -// then you can handle ChangeFunc(only called on enter if onlyApplyOnEnter set, or set immediately) -// and ReturnPrevPageFunc optionally. You can store the option in an INI file if you pass the key(as a char array) to corresponding parameter. -// -// Dynamic: Passing variable to function is only needed if you want to store it, otherwise you should do -// all the operations with ButtonPressFunc, this includes allocating the variable. -// Left-side text is passed while creating and static, but ofc right-side text is dynamic - -// you should return it in DrawFunc, which is called on every draw. ReturnPrevPageFunc is also here if needed. -// -// Redirect: Redirection to another screen. selectedOption parameter is the highlighted option user will see after the redirection. -// -// Built-in action: As the name suggests, any action that game has built-in. But as an extra you can set the option text, -// and can be informed on button press/focus loss via buttonPressFunc. ReturnPrevPageFunc is also here. - -#define FEOPTION_SELECT 0 -#define FEOPTION_DYNAMIC 1 -#define FEOPTION_REDIRECT 2 -#define FEOPTION_GOBACK 3 -#define FEOPTION_BUILTIN_ACTION 4 - -// -- Returned via ButtonPressFunc() action param. -#define FEOPTION_ACTION_LEFT 0 -#define FEOPTION_ACTION_RIGHT 1 -#define FEOPTION_ACTION_SELECT 2 -#define FEOPTION_ACTION_FOCUSLOSS 3 - -// -- Passed via FrontendScreenAdd() -#define FESCREEN_CENTER 0 -#define FESCREEN_LEFT_ALIGN 1 -#define FESCREEN_RIGHT_ALIGN 2 - -// -- Callbacks - -// pretty much in everything I guess, and optional in all of them -typedef void (*ReturnPrevPageFunc)(); - -// for static options -typedef void (*ChangeFunc)(int8 displayedValue); // called before updating the value. - // only called on enter if onlyApplyOnEnter set, otherwise called on every value change - -// for dynamic options -typedef wchar* (*DrawFunc)(bool* disabled, bool userHovering); // you must return a pointer for right text. - // you can also set *disabled if you want to gray it out. -typedef void (*ButtonPressFunc)(int8 action); // see FEOPTION_ACTIONs above - -struct FrontendScreen -{ - int id; - char name[8]; - eMenuSprites sprite; - int prevPage; - int columnWidth; - int headerHeight; - int lineHeight; - int8 font; - float fontScaleX; - float fontScaleY; - int8 alignment; - bool showLeftRightHelper; - ReturnPrevPageFunc returnPrevPageFunc; -}; - -struct FrontendOption -{ - int8 type; - int8 screenOptionOrder; - int32 screen; - wchar leftText[128]; - ReturnPrevPageFunc returnPrevPageFunc; - int8* value; - int8 displayedValue; // only if onlyApplyOnEnter enabled for now - const char* save; - int32 ogOptionId; // for replacements, see overwrite parameter of SetCursor - - union { - // Only for dynamic / built-in action - struct { - DrawFunc drawFunc; - ButtonPressFunc buttonPressFunc; - }; - - // Only for static/select - struct { - wchar** rightTexts; - int8 numRightTexts; - bool onlyApplyOnEnter; - ChangeFunc changeFunc; - int8 lastSavedValue; // only if onlyApplyOnEnter enabled - }; - - // Only for redirect - struct { - int to; - int8 option; - bool fadeIn; - }; - }; -}; - -// -- Internal things -void RemoveCustomFrontendOptions(); -void CustomFrontendOptionsPopulate(); - -extern int lastOgScreen; // for reloading - -extern int numCustomFrontendOptions; -extern FrontendOption* customFrontendOptions; - -extern int numCustomFrontendScreens; -extern FrontendScreen* customFrontendScreens; - -// -- To be used in ButtonPressFunc / ChangeFunc(this one would be weird): -void ChangeScreen(int screen, int option = 0, bool fadeIn = true); -void GoBack(bool fadeIn = true); - -uint8 GetNumberOfMenuOptions(int screen); - -// -- Placing the cursor to append/overwrite option -// -// Done via FrontendOptionSetCursor(screen, position, overwrite = false), parameters explained below: -// Screen: as the name suggests. Also accepts the screen IDs returned from FrontendScreenAdd. -// Option: if positive, next AddOption call will put the option to there and progress the cursor. -// if negative, cursor will be placed on bottom-(pos+1), so -1 means the very bottom, -2 means before the back button etc. -// Overwrite: Use to overwrite the options, not appending a new one. AddOption calls will still progress the cursor. - -void FrontendOptionSetCursor(int screen, int8 option, bool overwrite = false); - -// var is optional in AddDynamic, enables you to save them in an INI file(also needs passing char array to saveName param. obv), otherwise pass nil/0 -void FrontendOptionAddBuiltinAction(const wchar* leftText, int action, ButtonPressFunc buttonPressFunc, ReturnPrevPageFunc returnPrevPageFunc); -void FrontendOptionAddSelect(const wchar* leftText, const wchar** rightTexts, int8 numRightTexts, int8 *var, bool onlyApplyOnEnter, ChangeFunc changeFunc, ReturnPrevPageFunc returnPrevPageFunc, const char* saveName = nil); -void FrontendOptionAddDynamic(const wchar* leftText, DrawFunc rightTextDrawFunc, int8 *var, ButtonPressFunc buttonPressFunc, ReturnPrevPageFunc returnPrevPageFunc, const char* saveName = nil); -void FrontendOptionAddRedirect(const wchar* text, int to, int8 selectedOption = 0, bool fadeIn = true); -void FrontendOptionAddBackButton(const wchar* text, bool fadeIn = true); - -uint8 FrontendScreenAdd(const char* gxtKey, eMenuSprites sprite, int prevPage, int columnWidth, int headerHeight, int lineHeight, int8 font, float fontScaleX, float fontScaleY, int8 alignment, bool showLeftRightHelper, ReturnPrevPageFunc returnPrevPageFunc = nil); -#endif 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 6cbbf237..605190c9 100644 --- a/src/extras/shaders/Makefile +++ b/src/extras/shaders/Makefile @@ -1,7 +1,7 @@ all: im2d_gl3.inc simple_fs_gl3.inc default_UV2_gl3.inc \ - colourfilterIII_fs_gl3.inc contrast_fs_gl3.inc \ + colourfilterVC_fs_gl3.inc contrast_fs_gl3.inc \ neoRim_gl3.inc neoRimSkin_gl3.inc \ - neoWorldIII_fs_gl3.inc neoGloss_vs_gl3.inc neoGloss_fs_gl3.inc \ + neoWorldVC_fs_gl3.inc neoGloss_vs_gl3.inc neoGloss_fs_gl3.inc \ neoVehicle_vs_gl3.inc neoVehicle_fs_gl3.inc im2d_gl3.inc: im2d.vert @@ -9,6 +9,10 @@ im2d_gl3.inc: im2d.vert sed 's/..*/"&\\n"/' im2d.vert;\ echo ';') >im2d_gl3.inc +colourfilterVC_fs_gl3.inc: colourfilterVC.frag + (echo 'const char *colourfilterVC_frag_src =';\ + sed 's/..*/"&\\n"/' colourfilterVC.frag;\ + echo ';') >colourfilterVC_fs_gl3.inc simple_fs_gl3.inc: simple.frag (echo 'const char *simple_frag_src =';\ sed 's/..*/"&\\n"/' simple.frag;\ @@ -21,11 +25,6 @@ default_UV2_gl3.inc: default_UV2.vert -colourfilterIII_fs_gl3.inc: colourfilterIII.frag - (echo 'const char *colourfilterIII_frag_src =';\ - sed 's/..*/"&\\n"/' colourfilterIII.frag;\ - echo ';') >colourfilterIII_fs_gl3.inc - contrast_fs_gl3.inc: contrast.frag (echo 'const char *contrast_frag_src =';\ sed 's/..*/"&\\n"/' contrast.frag;\ @@ -42,10 +41,10 @@ neoRimSkin_gl3.inc: neoRimSkin.vert sed 's/..*/"&\\n"/' neoRimSkin.vert;\ echo ';') >neoRimSkin_gl3.inc -neoWorldIII_fs_gl3.inc: neoWorldIII.frag - (echo 'const char *neoWorldIII_frag_src =';\ - sed 's/..*/"&\\n"/' neoWorldIII.frag;\ - echo ';') >neoWorldIII_fs_gl3.inc +neoWorldVC_fs_gl3.inc: neoWorldVC.frag + (echo 'const char *neoWorldVC_frag_src =';\ + sed 's/..*/"&\\n"/' neoWorldVC.frag;\ + echo ';') >neoWorldVC_fs_gl3.inc neoGloss_fs_gl3.inc: neoGloss.frag (echo 'const char *neoGloss_frag_src =';\ diff --git a/src/extras/shaders/colourfilterIII_PS.cso b/src/extras/shaders/colourfilterIII_PS.cso Binary files differdeleted file mode 100644 index cc41bcec..00000000 --- a/src/extras/shaders/colourfilterIII_PS.cso +++ /dev/null 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 4c9a8400..5069af52 100644 --- a/src/extras/shaders/colourfilterIII.frag +++ b/src/extras/shaders/colourfilterVC.frag @@ -11,10 +11,13 @@ void main(void) { float a = u_blurcolor.a; + vec4 doublec = clamp(u_blurcolor*2, 0.0, 1.0); vec4 dst = texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y)); vec4 prev = dst; for(int i = 0; i < 5; i++){ - vec4 tmp = dst*(1.0-a) + prev*u_blurcolor*a; + vec4 tmp = dst*(1.0-a) + prev*doublec*a; + tmp += prev*u_blurcolor; + tmp += prev*u_blurcolor; prev = clamp(tmp, 0.0, 1.0); } color.rgb = prev.rgb; diff --git a/src/extras/shaders/colourfilterVC_PS.cso b/src/extras/shaders/colourfilterVC_PS.cso Binary files differnew file mode 100644 index 00000000..4b0e9f3f --- /dev/null +++ b/src/extras/shaders/colourfilterVC_PS.cso 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 5530a4fa..d11cdc5a 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" @@ -12,10 +12,13 @@ const char *colourfilterIII_frag_src = "main(void)\n" "{\n" " float a = u_blurcolor.a;\n" +" vec4 doublec = clamp(u_blurcolor*2, 0.0, 1.0);\n" " vec4 dst = texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y));\n" " vec4 prev = dst;\n" " for(int i = 0; i < 5; i++){\n" -" vec4 tmp = dst*(1.0-a) + prev*u_blurcolor*a;\n" +" vec4 tmp = dst*(1.0-a) + prev*doublec*a;\n" +" tmp += prev*u_blurcolor;\n" +" tmp += prev*u_blurcolor;\n" " prev = clamp(tmp, 0.0, 1.0);\n" " }\n" " color.rgb = prev.rgb;\n" diff --git a/src/extras/shaders/neoWorldIII_PS.cso b/src/extras/shaders/neoWorldIII_PS.cso Binary files differdeleted file mode 100644 index 817888ef..00000000 --- a/src/extras/shaders/neoWorldIII_PS.cso +++ /dev/null diff --git a/src/extras/shaders/neoWorldIII.frag b/src/extras/shaders/neoWorldVC.frag index 4c5571ee..0270f305 100644 --- a/src/extras/shaders/neoWorldIII.frag +++ b/src/extras/shaders/neoWorldVC.frag @@ -16,7 +16,7 @@ main(void) vec4 t0 = texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y)); vec4 t1 = texture(tex1, vec2(v_tex1.x, 1.0-v_tex1.y)); - color = t0*v_color*(1 + u_lightMap*(2*t1-1)); + color = t0*v_color*(1 + u_lightMap*(t1-1)); color.a = v_color.a*t0.a*u_lightMap.a; color.rgb = mix(u_fogColor.rgb, color.rgb, v_fog); diff --git a/src/extras/shaders/neoWorldVC_PS.cso b/src/extras/shaders/neoWorldVC_PS.cso Binary files differnew file mode 100644 index 00000000..5e8d1696 --- /dev/null +++ b/src/extras/shaders/neoWorldVC_PS.cso diff --git a/src/extras/shaders/neoWorldIII_PS.hlsl b/src/extras/shaders/neoWorldVC_PS.hlsl index 8a3d5d86..fc4f1de9 100644 --- a/src/extras/shaders/neoWorldIII_PS.hlsl +++ b/src/extras/shaders/neoWorldVC_PS.hlsl @@ -16,7 +16,7 @@ main(PS_INPUT IN) : COLOR float4 t0 = tex2D(Diffuse, IN.Tex0.xy); float4 t1 = tex2D(Light, IN.Tex1); - float4 col = t0*IN.Color*(1 + lm*(2*t1-1)); + float4 col = t0*IN.Color*(1 + lm*(t1-1)); col.a = IN.Color.a*t0.a*lm.a; col.rgb = lerp(fogColor.rgb, col.rgb, IN.Tex0.z); diff --git a/src/extras/shaders/neoWorldIII_PS.inc b/src/extras/shaders/neoWorldVC_PS.inc index a4631efb..eb8bf2ee 100644 --- a/src/extras/shaders/neoWorldIII_PS.inc +++ b/src/extras/shaders/neoWorldVC_PS.inc @@ -1,4 +1,4 @@ -static unsigned char neoWorldIII_PS_cso[] = { +static unsigned char neoWorldVC_PS_cso[] = { 0x00, 0x02, 0xff, 0xff, 0xfe, 0xff, 0x3e, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, 0x00, 0x00, 0x00, 0xc2, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, @@ -21,7 +21,7 @@ static unsigned char neoWorldIII_PS_cso[] = { 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, 0xab, 0x51, 0x00, 0x00, 0x05, 0x02, 0x00, 0x0f, 0xa0, - 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, + 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x07, 0xb0, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, @@ -30,17 +30,17 @@ static unsigned char neoWorldIII_PS_cso[] = { 0x01, 0x08, 0x0f, 0xa0, 0x42, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0f, 0x80, 0x01, 0x00, 0xe4, 0xb0, 0x01, 0x08, 0xe4, 0xa0, 0x42, 0x00, 0x00, 0x03, 0x01, 0x00, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xb0, 0x00, 0x08, 0xe4, 0xa0, - 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0xe4, 0x80, - 0x02, 0x00, 0x00, 0xa0, 0x02, 0x00, 0x55, 0xa0, 0x01, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x08, 0x80, 0x02, 0x00, 0xaa, 0xa0, 0x04, 0x00, 0x00, 0x04, - 0x00, 0x00, 0x07, 0x80, 0x01, 0x00, 0xe4, 0xa0, 0x00, 0x00, 0xe4, 0x80, - 0x00, 0x00, 0xff, 0x80, 0x05, 0x00, 0x00, 0x03, 0x01, 0x00, 0x07, 0x80, - 0x01, 0x00, 0xe4, 0x80, 0x00, 0x00, 0xe4, 0x90, 0x05, 0x00, 0x00, 0x03, - 0x00, 0x00, 0x08, 0x80, 0x01, 0x00, 0xff, 0x80, 0x00, 0x00, 0xff, 0x90, - 0x05, 0x00, 0x00, 0x03, 0x02, 0x00, 0x08, 0x80, 0x00, 0x00, 0xff, 0x80, - 0x01, 0x00, 0xff, 0xa0, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x07, 0x80, - 0x01, 0x00, 0xe4, 0x80, 0x00, 0x00, 0xe4, 0x80, 0x00, 0x00, 0xe4, 0xa1, - 0x04, 0x00, 0x00, 0x04, 0x02, 0x00, 0x07, 0x80, 0x00, 0x00, 0xaa, 0xb0, - 0x00, 0x00, 0xe4, 0x80, 0x00, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, - 0x00, 0x08, 0x0f, 0x80, 0x02, 0x00, 0xe4, 0x80, 0xff, 0xff, 0x00, 0x00 + 0x02, 0x00, 0x00, 0x03, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0xe4, 0x80, + 0x02, 0x00, 0x00, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x08, 0x80, + 0x02, 0x00, 0x55, 0xa0, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x07, 0x80, + 0x01, 0x00, 0xe4, 0xa0, 0x00, 0x00, 0xe4, 0x80, 0x00, 0x00, 0xff, 0x80, + 0x05, 0x00, 0x00, 0x03, 0x01, 0x00, 0x07, 0x80, 0x01, 0x00, 0xe4, 0x80, + 0x00, 0x00, 0xe4, 0x90, 0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x08, 0x80, + 0x01, 0x00, 0xff, 0x80, 0x00, 0x00, 0xff, 0x90, 0x05, 0x00, 0x00, 0x03, + 0x02, 0x00, 0x08, 0x80, 0x00, 0x00, 0xff, 0x80, 0x01, 0x00, 0xff, 0xa0, + 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x07, 0x80, 0x01, 0x00, 0xe4, 0x80, + 0x00, 0x00, 0xe4, 0x80, 0x00, 0x00, 0xe4, 0xa1, 0x04, 0x00, 0x00, 0x04, + 0x02, 0x00, 0x07, 0x80, 0x00, 0x00, 0xaa, 0xb0, 0x00, 0x00, 0xe4, 0x80, + 0x00, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x00, 0x08, 0x0f, 0x80, + 0x02, 0x00, 0xe4, 0x80, 0xff, 0xff, 0x00, 0x00 }; diff --git a/src/extras/shaders/neoWorldIII_fs_gl3.inc b/src/extras/shaders/neoWorldVC_fs_gl3.inc index 5145f9cd..c861d334 100644 --- a/src/extras/shaders/neoWorldIII_fs_gl3.inc +++ b/src/extras/shaders/neoWorldVC_fs_gl3.inc @@ -1,4 +1,4 @@ -const char *neoWorldIII_frag_src = +const char *neoWorldVC_frag_src = "uniform sampler2D tex0;\n" "uniform sampler2D tex1;\n" @@ -17,7 +17,7 @@ const char *neoWorldIII_frag_src = " vec4 t0 = texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y));\n" " vec4 t1 = texture(tex1, vec2(v_tex1.x, 1.0-v_tex1.y));\n" -" color = t0*v_color*(1 + u_lightMap*(2*t1-1));\n" +" color = t0*v_color*(1 + u_lightMap*(t1-1));\n" " color.a = v_color.a*t0.a*u_lightMap.a;\n" " color.rgb = mix(u_fogColor.rgb, color.rgb, v_fog);\n" |