From 2034d7b2aebdeb3759efb150a1d09c586f5d2ce3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Thu, 13 Aug 2020 01:29:34 +0300 Subject: [PATCH 1/4] Register start button for real --- src/core/ControllerConfig.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp index 6a5080e5..fe1821c2 100644 --- a/src/core/ControllerConfig.cpp +++ b/src/core/ControllerConfig.cpp @@ -633,6 +633,11 @@ void CControllerConfigManager::AffectControllerStateOn_ButtonDown(int32 button, } AffectControllerStateOn_ButtonDown_AllStates(button, type, *state); + +#ifdef REGISTER_START_BUTTON + if (button == 12) + state->Start = 255; +#endif } } } @@ -1036,6 +1041,11 @@ void CControllerConfigManager::AffectControllerStateOn_ButtonUp(int32 button, eC { if (FrontEndMenuManager.GetIsMenuActive()) AffectControllerStateOn_ButtonUp_All_Player_States(button, type, *state); + +#ifdef REGISTER_START_BUTTON + if (button == 12) + state->Start = 0; +#endif } } } From f0503edf62ff0263ae3e55b3a7916e03b2152b7a Mon Sep 17 00:00:00 2001 From: aap Date: Thu, 13 Aug 2020 16:29:42 +0200 Subject: [PATCH 2/4] fix render poly bug --- src/render/Renderer.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 717021a7..7ae29a2f 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -836,8 +836,13 @@ CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrL a2 = i; } } +#ifdef FIX_BUGS + y = Floor(miny); + yend = Floor(maxy); +#else y = miny; yend = maxy; +#endif // Go left in poly to find first edge b b2 = a2; @@ -875,8 +880,8 @@ CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrL while(y <= yend && y < NUMSECTORS_Y){ // scan one x-line if(y >= 0 && xstart < NUMSECTORS_X) - for(x = xstart; x <= xend; x++) - if(x >= 0 && x != NUMSECTORS_X) + for(x = xstart; x <= xend && x != NUMSECTORS_X; x++) + if(x >= 0) scanfunc(CWorld::GetSector(x, y)->m_lists); // advance one scan line From afed831aeda5415f1d99612d0f14541fdd34720f Mon Sep 17 00:00:00 2001 From: aap Date: Thu, 13 Aug 2020 18:14:24 +0200 Subject: [PATCH 3/4] extended postfx and sniper hud fix --- src/core/Game.cpp | 4 + src/core/config.h | 1 + src/core/re3.cpp | 9 + src/extras/postfx.cpp | 475 ++++++++++++++++++ src/extras/postfx.h | 35 ++ src/extras/shaders/Makefile | 16 + src/extras/shaders/colourfilterIII.frag | 28 ++ src/extras/shaders/colourfilterIII_PS.cso | Bin 0 -> 452 bytes src/extras/shaders/colourfilterIII_PS.hlsl | 15 + src/extras/shaders/colourfilterIII_PS.inc | 40 ++ src/extras/shaders/colourfilterIII_fs_gl3.inc | 30 ++ src/extras/shaders/contrast.frag | 18 + src/extras/shaders/contrastPS.cso | Bin 0 -> 344 bytes src/extras/shaders/contrastPS.hlsl | 21 + src/extras/shaders/contrastPS.inc | 31 ++ src/extras/shaders/contrast_fs_gl3.inc | 20 + src/extras/shaders/im2d.vert | 21 + src/extras/shaders/im2d_gl3.inc | 23 + src/extras/shaders/make.cmd | 3 + src/extras/shaders/makeinc.sh | 5 + src/render/Hud.cpp | 57 ++- src/render/MBlur.cpp | 16 +- src/render/Sprite2d.cpp | 17 +- 23 files changed, 851 insertions(+), 34 deletions(-) create mode 100644 src/extras/postfx.cpp create mode 100644 src/extras/postfx.h create mode 100644 src/extras/shaders/Makefile create mode 100644 src/extras/shaders/colourfilterIII.frag create mode 100644 src/extras/shaders/colourfilterIII_PS.cso create mode 100644 src/extras/shaders/colourfilterIII_PS.hlsl create mode 100644 src/extras/shaders/colourfilterIII_PS.inc create mode 100644 src/extras/shaders/colourfilterIII_fs_gl3.inc create mode 100644 src/extras/shaders/contrast.frag create mode 100644 src/extras/shaders/contrastPS.cso create mode 100644 src/extras/shaders/contrastPS.hlsl create mode 100644 src/extras/shaders/contrastPS.inc create mode 100644 src/extras/shaders/contrast_fs_gl3.inc create mode 100644 src/extras/shaders/im2d.vert create mode 100644 src/extras/shaders/im2d_gl3.inc create mode 100644 src/extras/shaders/make.cmd create mode 100644 src/extras/shaders/makeinc.sh diff --git a/src/core/Game.cpp b/src/core/Game.cpp index 08623c65..d5b376f6 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -87,6 +87,7 @@ #include "Zones.h" #include "debugmenu.h" #include "frontendoption.h" +#include "postfx.h" eLevelName CGame::currLevel; bool CGame::bDemoMode = true; @@ -148,6 +149,9 @@ CGame::InitialiseOnceBeforeRW(void) CFileMgr::Initialise(); CdStreamInit(MAX_CDCHANNELS); ValidateVersion(); +#ifdef EXTENDED_COLOURFILTER + CPostFX::InitOnce(); +#endif return true; } diff --git a/src/core/config.h b/src/core/config.h index 43fc54fa..bb6adce6 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -208,6 +208,7 @@ enum Config { //#define NO_ISLAND_LOADING // disable loadscreen between islands via loading all island data at once, consumes more memory and CPU //#define USE_TEXTURE_POOL #define CUTSCENE_BORDERS_SWITCH +//#define EXTENDED_COLOURFILTER // more options for colour filter (replaces mblur) // Particle //#define PC_PARTICLE diff --git a/src/core/re3.cpp b/src/core/re3.cpp index f9be4b51..9edd9497 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -29,6 +29,8 @@ #include "Text.h" #include "WaterLevel.h" #include "main.h" +#include "MBlur.h" +#include "postfx.h" #ifndef _WIN32 #include "assert.h" @@ -461,6 +463,13 @@ DebugMenuPopulate(void) DebugMenuAddVarBool8("Render", "Frame limiter", &FrontEndMenuManager.m_PrefsFrameLimiter, nil); DebugMenuAddVarBool8("Render", "VSynch", &FrontEndMenuManager.m_PrefsVsync, nil); DebugMenuAddVar("Render", "Max FPS", &RsGlobal.maxFPS, nil, 1, 1, 1000, nil); +#ifdef EXTENDED_COLOURFILTER + static const char *filternames[] = { "None", "Simple", "Normal", "Mobile" }; + e = DebugMenuAddVar("Render", "Colourfilter", &CPostFX::EffectSwitch, nil, 1, CPostFX::POSTFX_OFF, CPostFX::POSTFX_MOBILE, filternames); + DebugMenuEntrySetWrap(e, true); + DebugMenuAddVar("Render", "Intensity", &CPostFX::Intensity, nil, 0.05f, 0, 10.0f); + DebugMenuAddVarBool8("Render", "Motion Blur", &CPostFX::MotionBlurOn, nil); +#endif DebugMenuAddVarBool8("Render", "Show Ped Paths", &gbShowPedPaths, nil); DebugMenuAddVarBool8("Render", "Show Car Paths", &gbShowCarPaths, nil); DebugMenuAddVarBool8("Render", "Show Car Path Links", &gbShowCarPathsLinks, nil); diff --git a/src/extras/postfx.cpp b/src/extras/postfx.cpp new file mode 100644 index 00000000..6355dfb1 --- /dev/null +++ b/src/extras/postfx.cpp @@ -0,0 +1,475 @@ +#define WITHWINDOWS +#define WITH_D3D +#include "common.h" + +#ifdef EXTENDED_COLOURFILTER + +#ifndef LIBRW +#error "Need librw for EXTENDED_COLOURFILTER" +#endif + +#include "RwHelper.h" +#include "Camera.h" +#include "MBlur.h" +#include "postfx.h" + +RwRaster *CPostFX::pFrontBuffer; +RwRaster *CPostFX::pBackBuffer; +bool CPostFX::bJustInitialised; +int CPostFX::EffectSwitch = POSTFX_NORMAL; +bool CPostFX::MotionBlurOn = false; + +static RwIm2DVertex Vertex[4]; +static RwIm2DVertex Vertex2[4]; +static RwImVertexIndex Index[6] = { 0, 1, 2, 0, 2, 3 }; + +#ifdef RW_D3D9 +void *colourfilterIII_PS; +void *contrast_PS; +#endif +#ifdef RW_OPENGL +int32 u_blurcolor; +int32 u_contrastAdd; +int32 u_contrastMult; +rw::gl3::Shader *colourFilterIII; +rw::gl3::Shader *contrast; +#endif + +void +CPostFX::InitOnce(void) +{ +#ifdef RW_OPENGL + u_blurcolor = rw::gl3::registerUniform("u_blurcolor"); + u_contrastAdd = rw::gl3::registerUniform("u_contrastAdd"); + u_contrastMult = rw::gl3::registerUniform("u_contrastMult"); +#endif +} + +void +CPostFX::Open(RwCamera *cam) +{ + uint32 width = Pow(2.0f, int32(log2(RwRasterGetWidth (RwCameraGetRaster(cam))))+1); + uint32 height = Pow(2.0f, int32(log2(RwRasterGetHeight(RwCameraGetRaster(cam))))+1); + uint32 depth = RwRasterGetDepth(RwCameraGetRaster(cam)); + pFrontBuffer = RwRasterCreate(width, height, depth, rwRASTERTYPECAMERATEXTURE); + pBackBuffer = RwRasterCreate(width, height, depth, rwRASTERTYPECAMERATEXTURE); + bJustInitialised = true; + + float zero, xmax, ymax; + + if(RwRasterGetDepth(RwCameraGetRaster(cam)) == 16){ + zero = HALFPX; + xmax = width + HALFPX; + ymax = height + HALFPX; + }else{ + zero = -HALFPX; + xmax = width - HALFPX; + ymax = height - HALFPX; + } + + RwIm2DVertexSetScreenX(&Vertex[0], zero); + RwIm2DVertexSetScreenY(&Vertex[0], zero); + RwIm2DVertexSetScreenZ(&Vertex[0], RwIm2DGetNearScreenZ()); + RwIm2DVertexSetCameraZ(&Vertex[0], RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetRecipCameraZ(&Vertex[0], 1.0f/RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetU(&Vertex[0], 0.0f, 1.0f/RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetV(&Vertex[0], 0.0f, 1.0f/RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetIntRGBA(&Vertex[0], 255, 255, 255, 255); + + RwIm2DVertexSetScreenX(&Vertex[1], zero); + RwIm2DVertexSetScreenY(&Vertex[1], ymax); + RwIm2DVertexSetScreenZ(&Vertex[1], RwIm2DGetNearScreenZ()); + RwIm2DVertexSetCameraZ(&Vertex[1], RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetRecipCameraZ(&Vertex[1], 1.0f/RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetU(&Vertex[1], 0.0f, 1.0f/RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetV(&Vertex[1], 1.0f, 1.0f/RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetIntRGBA(&Vertex[1], 255, 255, 255, 255); + + RwIm2DVertexSetScreenX(&Vertex[2], xmax); + RwIm2DVertexSetScreenY(&Vertex[2], ymax); + RwIm2DVertexSetScreenZ(&Vertex[2], RwIm2DGetNearScreenZ()); + RwIm2DVertexSetCameraZ(&Vertex[2], RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetRecipCameraZ(&Vertex[2], 1.0f/RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetU(&Vertex[2], 1.0f, 1.0f/RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetV(&Vertex[2], 1.0f, 1.0f/RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetIntRGBA(&Vertex[2], 255, 255, 255, 255); + + RwIm2DVertexSetScreenX(&Vertex[3], xmax); + RwIm2DVertexSetScreenY(&Vertex[3], zero); + RwIm2DVertexSetScreenZ(&Vertex[3], RwIm2DGetNearScreenZ()); + RwIm2DVertexSetCameraZ(&Vertex[3], RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetRecipCameraZ(&Vertex[3], 1.0f/RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetU(&Vertex[3], 1.0f, 1.0f/RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetV(&Vertex[3], 0.0f, 1.0f/RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetIntRGBA(&Vertex[3], 255, 255, 255, 255); + + + RwIm2DVertexSetScreenX(&Vertex2[0], zero + 2.0f); + RwIm2DVertexSetScreenY(&Vertex2[0], zero + 2.0f); + RwIm2DVertexSetScreenZ(&Vertex2[0], RwIm2DGetNearScreenZ()); + RwIm2DVertexSetCameraZ(&Vertex2[0], RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetRecipCameraZ(&Vertex2[0], 1.0f/RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetU(&Vertex2[0], 0.0f, 1.0f/RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetV(&Vertex2[0], 0.0f, 1.0f/RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetIntRGBA(&Vertex2[0], 255, 255, 255, 255); + + RwIm2DVertexSetScreenX(&Vertex2[1], 2.0f); + RwIm2DVertexSetScreenY(&Vertex2[1], ymax + 2.0f); + RwIm2DVertexSetScreenZ(&Vertex2[1], RwIm2DGetNearScreenZ()); + RwIm2DVertexSetCameraZ(&Vertex2[1], RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetRecipCameraZ(&Vertex2[1], 1.0f/RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetU(&Vertex2[1], 0.0f, 1.0f/RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetV(&Vertex2[1], 1.0f, 1.0f/RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetIntRGBA(&Vertex2[1], 255, 255, 255, 255); + + RwIm2DVertexSetScreenX(&Vertex2[2], xmax + 2.0f); + RwIm2DVertexSetScreenY(&Vertex2[2], ymax + 2.0f); + RwIm2DVertexSetScreenZ(&Vertex2[2], RwIm2DGetNearScreenZ()); + RwIm2DVertexSetCameraZ(&Vertex2[2], RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetRecipCameraZ(&Vertex2[2], 1.0f/RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetU(&Vertex2[2], 1.0f, 1.0f/RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetV(&Vertex2[2], 1.0f, 1.0f/RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetIntRGBA(&Vertex2[2], 255, 255, 255, 255); + + RwIm2DVertexSetScreenX(&Vertex2[3], xmax + 2.0f); + RwIm2DVertexSetScreenY(&Vertex2[3], zero + 2.0f); + RwIm2DVertexSetScreenZ(&Vertex2[3], RwIm2DGetNearScreenZ()); + RwIm2DVertexSetCameraZ(&Vertex2[3], RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetRecipCameraZ(&Vertex2[3], 1.0f/RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetU(&Vertex2[3], 1.0f, 1.0f/RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetV(&Vertex2[3], 0.0f, 1.0f/RwCameraGetNearClipPlane(cam)); + RwIm2DVertexSetIntRGBA(&Vertex2[3], 255, 255, 255, 255); + + +#ifdef RW_D3D9 +#include "shaders/colourfilterIII_PS.inc" + colourfilterIII_PS = rw::d3d::createPixelShader(colourfilterIII_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" +#else +#include "shaders/im2d_gl3.inc" +#include "shaders/colourfilterIII_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); + } + + { +#ifdef RW_GLES2 +#include "gl2_shaders/im2d_gl2.inc" +#include "gl2_shaders/contrast_fs_gl2.inc" +#else +#include "shaders/im2d_gl3.inc" +#include "shaders/contrast_fs_gl3.inc" + const char *vs[] = { shaderDecl, header_vert_src, im2d_vert_src, nil }; + const char *fs[] = { shaderDecl, header_frag_src, contrast_frag_src, nil }; + contrast = Shader::create(vs, fs); + assert(contrast); +#endif + } + +#endif +} + +void +CPostFX::Close(void) +{ + if(pFrontBuffer){ + RwRasterDestroy(pFrontBuffer); + pFrontBuffer = nil; + } + if(pBackBuffer){ + RwRasterDestroy(pBackBuffer); + pBackBuffer = nil; + } +#ifdef RW_D3D9 + if(colourfilterIII_PS){ + rw::d3d::destroyPixelShader(colourfilterIII_PS); + colourfilterIII_PS = nil; + } + if(contrast_PS){ + rw::d3d::destroyPixelShader(contrast_PS); + contrast_PS = nil; + } +#endif +#ifdef RW_OPENGL + if(colourFilterIII){ + colourFilterIII->destroy(); + colourFilterIII = nil; + } + if(contrast){ + contrast->destroy(); + contrast = nil; + } +#endif +} + +void +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); + + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); + + RwIm2DRenderIndexedPrimitive(rwPRIMTYPETRILIST, 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(&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); + + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); + + RwIm2DRenderIndexedPrimitive(rwPRIMTYPETRILIST, Vertex, 4, Index, 6); +} + +void +CPostFX::RenderOverlaySniper(RwCamera *cam, int32 r, int32 g, int32 b, int32 a) +{ + RwRenderStateSet(rwRENDERSTATETEXTURERASTER, pFrontBuffer); + RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); + + RwIm2DVertexSetIntRGBA(&Vertex[0], r, g, b, 80); + RwIm2DVertexSetIntRGBA(&Vertex[1], r, g, b, 80); + RwIm2DVertexSetIntRGBA(&Vertex[2], r, g, b, 80); + RwIm2DVertexSetIntRGBA(&Vertex[3], r, g, b, 80); + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); + + RwIm2DRenderIndexedPrimitive(rwPRIMTYPETRILIST, Vertex, 4, Index, 6); +} + +float CPostFX::Intensity = 1.0f; + +void +CPostFX::RenderOverlayShader(RwCamera *cam, int32 r, int32 g, int32 b, int32 a) +{ + RwRenderStateSet(rwRENDERSTATETEXTURERASTER, pBackBuffer); + + 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; +#ifdef RW_D3D9 + rw::d3d::d3ddevice->SetPixelShaderConstantF(10, mult, 1); + rw::d3d::d3ddevice->SetPixelShaderConstantF(11, add, 1); + + rw::d3d::im2dOverridePS = contrast_PS; +#endif +#ifdef RW_OPENGL + rw::gl3::im2dOverrideShader = contrast; + contrast->use(); + glUniform3fv(contrast->uniformLocations[u_contrastMult], 1, mult); + glUniform3fv(contrast->uniformLocations[u_contrastAdd], 1, add); +#endif + }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; +#ifdef RW_D3D9 + rw::d3d::d3ddevice->SetPixelShaderConstantF(10, blurcolors, 1); + rw::d3d::im2dOverridePS = colourfilterIII_PS; +#endif +#ifdef RW_OPENGL + rw::gl3::im2dOverrideShader = colourFilterIII; + colourFilterIII->use(); + glUniform4fv(colourFilterIII->uniformLocations[u_blurcolor], 1, blurcolors); +#endif + } + RwIm2DRenderIndexedPrimitive(rwPRIMTYPETRILIST, Vertex, 4, Index, 6); +#ifdef RW_D3D9 + rw::d3d::im2dOverridePS = nil; +#endif +#ifdef RW_OPENGL + rw::gl3::im2dOverrideShader = nil; +#endif +} + +void +CPostFX::RenderMotionBlur(RwCamera *cam, uint32 blur) +{ + if(blur == 0) + return; + + RwRenderStateSet(rwRENDERSTATETEXTURERASTER, pFrontBuffer); + RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); + + RwIm2DVertexSetIntRGBA(&Vertex[0], 255, 255, 255, blur); + RwIm2DVertexSetIntRGBA(&Vertex[1], 255, 255, 255, blur); + RwIm2DVertexSetIntRGBA(&Vertex[2], 255, 255, 255, blur); + RwIm2DVertexSetIntRGBA(&Vertex[3], 255, 255, 255, blur); + + RwIm2DRenderIndexedPrimitive(rwPRIMTYPETRILIST, Vertex, 4, Index, 6); +} + +bool +CPostFX::NeedBackBuffer(void) +{ + // Current frame -- needed for non-blur effect + switch(EffectSwitch){ + case POSTFX_OFF: + // no actual rendering here + return false; + case POSTFX_SIMPLE: + return false; + case POSTFX_NORMAL: + if(MotionBlurOn) + return false; + else + return true; + case POSTFX_MOBILE: + return true; + } + return false; +} + +bool +CPostFX::NeedFrontBuffer(int32 type) +{ + // Last frame -- needed for motion blur + if(MotionBlurOn) + return true; + if(type == MOTION_BLUR_SNIPER) + return true; + + 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(NeedBackBuffer()){ + RwRasterPushContext(pBackBuffer); + RwRasterRenderFast(RwCameraGetRaster(cam), 0, 0); + RwRasterPopContext(); + } + + DefinedState(); + + RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE); + RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERNEAREST); + RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE); + RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE); + + if(type == MOTION_BLUR_SNIPER){ + if(!bJustInitialised) + 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); + break; + case POSTFX_NORMAL: + if(MotionBlurOn){ + if(!bJustInitialised) + RenderOverlayBlur(cam, red, green, blue, blur); + }else{ + RenderOverlayShader(cam, red, green, blue, blur); + } + break; + case POSTFX_MOBILE: + RenderOverlayShader(cam, red, green, blue, blur); + break; + } + + // TODO? maybe we want this even without motion blur on sometimes? + if(MotionBlurOn) + if(!bJustInitialised) + RenderMotionBlur(cam, bluralpha); + + RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE); + RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE); + RwRenderStateSet(rwRENDERSTATETEXTURERASTER, nil); + RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE); + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); + + if(NeedFrontBuffer(type)){ + RwRasterPushContext(pFrontBuffer); + RwRasterRenderFast(RwCameraGetRaster(cam), 0, 0); + RwRasterPopContext(); + bJustInitialised = false; + }else + bJustInitialised = true; +} + +#endif diff --git a/src/extras/postfx.h b/src/extras/postfx.h new file mode 100644 index 00000000..658c2d88 --- /dev/null +++ b/src/extras/postfx.h @@ -0,0 +1,35 @@ +#pragma once + +#ifdef EXTENDED_COLOURFILTER + +class CPostFX +{ +public: + enum { + POSTFX_OFF, + POSTFX_SIMPLE, + POSTFX_NORMAL, + POSTFX_MOBILE + }; + static RwRaster *pFrontBuffer; + static RwRaster *pBackBuffer; + static bool bJustInitialised; + static int EffectSwitch; + static bool MotionBlurOn; // or use CMblur for that? + static float Intensity; + + 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 bool NeedBackBuffer(void); + static bool NeedFrontBuffer(int32 type); + static bool UseBlurColours(void) { return EffectSwitch != POSTFX_SIMPLE; } +}; + +#endif diff --git a/src/extras/shaders/Makefile b/src/extras/shaders/Makefile new file mode 100644 index 00000000..87be011e --- /dev/null +++ b/src/extras/shaders/Makefile @@ -0,0 +1,16 @@ +all: im2d_gl3.inc colourfilterIII_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 + +contrast_fs_gl3.inc: contrast.frag + (echo 'const char *contrast_frag_src =';\ + sed 's/..*/"&\\n"/' contrast.frag;\ + echo ';') >contrast_fs_gl3.inc diff --git a/src/extras/shaders/colourfilterIII.frag b/src/extras/shaders/colourfilterIII.frag new file mode 100644 index 00000000..e19a8600 --- /dev/null +++ b/src/extras/shaders/colourfilterIII.frag @@ -0,0 +1,28 @@ +uniform sampler2D tex0; +uniform vec4 u_blurcolor; + +in vec4 v_color; +in vec2 v_tex0; +in float v_fog; + +out vec4 color; + +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 doublec = clamp(u_blurcolor*2, 0.0, 1.0); + 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; + color.a = 1.0f; +} + diff --git a/src/extras/shaders/colourfilterIII_PS.cso b/src/extras/shaders/colourfilterIII_PS.cso new file mode 100644 index 0000000000000000000000000000000000000000..cc41bcecdbe4f6ba923ce659c433607b86209dd8 GIT binary patch literal 452 zcmd5&&1%9x7@TaB1}Ox3@lt4x{y=CV9&(bZ2M_Vk>QT_v9}J`=cj&ha^UdtH%j`lZbx~c6=5NDi0KWw236j<@fRr>Q1R9hbgxY5<2$L|lvm)#I zihr_o64Nt@8gZ+`_DJnN8JB?yC zf$Ilu(D&V*=XrPs>VPeQVsO8zq8A;JCR3g7{Rx&WhgD3QetCvfN**>1JZN1sP|7Eu hCeUQBq(M*ne>38r%<#{IfW>TJM!wUs3!P0V;0j=6S9$;d literal 0 HcmV?d00001 diff --git a/src/extras/shaders/colourfilterIII_PS.hlsl b/src/extras/shaders/colourfilterIII_PS.hlsl new file mode 100644 index 00000000..27f099ef --- /dev/null +++ b/src/extras/shaders/colourfilterIII_PS.hlsl @@ -0,0 +1,15 @@ +sampler2D tex : register(s0); +float4 blurcol : register(c10); + +float4 main(in float2 texcoord : TEXCOORD0) : COLOR0 +{ + float a = blurcol.a; + float4 dst = tex2D(tex, texcoord.xy); + float4 prev = dst; + for(int i = 0; i < 5; i++){ + float4 tmp = dst*(1-a) + prev*blurcol*a; + prev = saturate(tmp); + } + prev.a = 1.0f; + return prev; +} diff --git a/src/extras/shaders/colourfilterIII_PS.inc b/src/extras/shaders/colourfilterIII_PS.inc new file mode 100644 index 00000000..db49de6c --- /dev/null +++ b/src/extras/shaders/colourfilterIII_PS.inc @@ -0,0 +1,40 @@ +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_fs_gl3.inc b/src/extras/shaders/colourfilterIII_fs_gl3.inc new file mode 100644 index 00000000..f57b9cdd --- /dev/null +++ b/src/extras/shaders/colourfilterIII_fs_gl3.inc @@ -0,0 +1,30 @@ +const char *colourfilterIII_frag_src = +"uniform sampler2D tex0;\n" +"uniform vec4 u_blurcolor;\n" + +"in vec4 v_color;\n" +"in vec2 v_tex0;\n" +"in float v_fog;\n" + +"out vec4 color;\n" + +"void\n" +"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 doublec = clamp(u_blurcolor*2, 0.0, 1.0);\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" +" color.a = 1.0f;\n" +"}\n" + +; diff --git a/src/extras/shaders/contrast.frag b/src/extras/shaders/contrast.frag new file mode 100644 index 00000000..d6dec478 --- /dev/null +++ b/src/extras/shaders/contrast.frag @@ -0,0 +1,18 @@ +uniform sampler2D tex0; +uniform vec3 u_contrastAdd; +uniform vec3 u_contrastMult; + +in vec4 v_color; +in vec2 v_tex0; +in float v_fog; + +out vec4 color; + +void +main(void) +{ + vec4 dst = texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y)); + color.rgb = dst.rgb*u_contrastMult + u_contrastAdd; + color.a = 1.0f; +} + diff --git a/src/extras/shaders/contrastPS.cso b/src/extras/shaders/contrastPS.cso new file mode 100644 index 0000000000000000000000000000000000000000..a87c48d787046a393b0093c906f6d0714d199153 GIT binary patch literal 344 zcmY+8F^j@L5QSf&Vo)J}K)958MKBSIREOGFXyIvborqBs)JU=ima)6?%Ii#@#vhg6 z;ojRA1ZVd#v)|j<9q3ZtWe>x7f6xSQr9f64eD4Ls`iwM9%V_Y9T8}tI3wP1MWVZ@~DA)+A_1U&Y zQjAH`F7dQ)Q)a?)E-|H3enK|Z=k lp50(%3IEqMRO1@5qzrIZl^1JNolN Date: Fri, 14 Aug 2020 09:27:30 +0200 Subject: [PATCH 4/4] fixed clouds render --- src/render/Clouds.cpp | 84 ++++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/src/render/Clouds.cpp b/src/render/Clouds.cpp index 60450213..05ddbcdc 100644 --- a/src/render/Clouds.cpp +++ b/src/render/Clouds.cpp @@ -78,6 +78,43 @@ CClouds::Update(void) #endif } +float StarCoorsX[9] = { 0.0f, 0.05f, 0.12f, 0.5f, 0.8f, 0.6f, 0.27f, 0.55f, 0.75f }; +float StarCoorsY[9] = { 0.0f, 0.45f, 0.9f, 1.0f, 0.85f, 0.52f, 0.48f, 0.35f, 0.2f }; +float StarSizes[9] = { 1.0f, 1.4f, 0.9f, 1.0f, 0.6f, 1.5f, 1.3f, 1.0f, 0.8f }; + +float LowCloudsX[12] = { 1.0f, 0.7f, 0.0f, -0.7f, -1.0f, -0.7f, 0.0f, 0.7f, 0.8f, -0.8f, 0.4f, -0.4f }; +float LowCloudsY[12] = { 0.0f, -0.7f, -1.0f, -0.7f, 0.0f, 0.7f, 1.0f, 0.7f, 0.4f, 0.4f, -0.8f, -0.8f }; +float LowCloudsZ[12] = { 0.0f, 1.0f, 0.5f, 0.0f, 1.0f, 0.3f, 0.9f, 0.4f, 1.3f, 1.4f, 1.2f, 1.7f }; + +float CoorsOffsetX[37] = { + 0.0f, 60.0f, 72.0f, 48.0f, 21.0f, 12.0f, + 9.0f, -3.0f, -8.4f, -18.0f, -15.0f, -36.0f, + -40.0f, -48.0f, -60.0f, -24.0f, 100.0f, 100.0f, + 100.0f, 100.0f, 100.0f, 100.0f, 100.0f, 100.0f, + 100.0f, 100.0f, -30.0f, -20.0f, 10.0f, 30.0f, + 0.0f, -100.0f, -100.0f, -100.0f, -100.0f, -100.0f, -100.0f +}; +float CoorsOffsetY[37] = { + 100.0f, 100.0f, 100.0f, 100.0f, 100.0f, 100.0f, + 100.0f, 100.0f, 100.0f, 100.0f, 100.0f, 100.0f, + 100.0f, 100.0f, 100.0f, 100.0f, -30.0f, 10.0f, + -25.0f, -5.0f, 28.0f, -10.0f, 10.0f, 0.0f, + 15.0f, 40.0f, -100.0f, -100.0f, -100.0f, -100.0f, + -100.0f, -40.0f, -20.0f, 0.0f, 10.0f, 30.0f, 35.0f +}; +float CoorsOffsetZ[37] = { + 2.0f, 1.0f, 0.0f, 0.3f, 0.7f, 1.4f, + 1.7f, 0.24f, 0.7f, 1.3f, 1.6f, 1.0f, + 1.2f, 0.3f, 0.7f, 1.4f, 0.0f, 0.1f, + 0.5f, 0.4f, 0.55f, 0.75f, 1.0f, 1.4f, + 1.7f, 2.0f, 2.0f, 2.3f, 1.9f, 2.4f, + 2.0f, 2.0f, 1.5f, 1.2f, 1.7f, 1.5f, 2.1f +}; + +uint8 BowRed[6] = { 30, 30, 30, 10, 0, 15 }; +uint8 BowGreen[6] = { 0, 15, 30, 30, 0, 0 }; +uint8 BowBlue[6] = { 0, 0, 0, 10, 30, 30 }; + void CClouds::Render(void) { @@ -98,11 +135,10 @@ CClouds::Render(void) int minute = CClock::GetHours()*60 + CClock::GetMinutes(); RwV3d campos = *(RwV3d*)&TheCamera.GetPosition(); - float coverage = Max(CWeather::Foggyness, CWeather::Foggyness); - // Moon int moonfadeout = Abs(minute - 180); // fully visible at 3AM if(moonfadeout < 180){ // fade in/out 3 hours + float coverage = Max(CWeather::Foggyness, CWeather::CloudCoverage); int brightness = (1.0f - coverage) * (180 - moonfadeout); RwV3d pos = { 0.0f, -100.0f, 15.0f }; RwV3dAdd(&worldpos, &campos, &pos); @@ -131,11 +167,10 @@ CClouds::Render(void) else if(CClock::GetHours() == 5) starintens = 255 * (60 - CClock::GetMinutes())/60.0f; if(starintens != 0){ - // R - static float StarCoorsX[9] = { 0.0f, 0.05f, 0.12f, 0.5f, 0.8f, 0.6f, 0.27f, 0.55f, 0.75f }; - static float StarCoorsY[9] = { 0.0f, 0.45f, 0.9f, 1.0f, 0.85f, 0.52f, 0.48f, 0.35f, 0.2f }; - static float StarSizes[9] = { 1.0f, 1.4f, 0.9f, 1.0f, 0.6f, 1.5f, 1.3f, 1.0f, 0.8f }; + float coverage = Max(CWeather::Foggyness, CWeather::CloudCoverage); int brightness = (1.0f - coverage) * starintens; + + // R RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(gpCoronaTexture[0])); for(i = 0; i < 11; i++){ RwV3d pos = { 100.0f, 0.0f, 10.0f }; @@ -164,13 +199,7 @@ CClouds::Render(void) } // Low clouds - static float LowCloudsX[12] = { 1.0f, 0.7f, 0.0f, -0.7f, -1.0f, -0.7f, - 0.0f, 0.7f, 0.8f, -0.8f, 0.4f, -0.4f }; - static float LowCloudsY[12] = { 0.0f, -0.7f, -1.0f, -0.7f, 0.0f, 0.7f, - 1.0f, 0.7f, 0.4f, 0.4f, -0.8f, -0.8f }; - static float LowCloudsZ[12] = { 0.0f, 1.0f, 0.5f, 0.0f, 1.0f, 0.3f, - 0.9f, 0.4f, 1.3f, 1.4f, 1.2f, 1.7f }; - float lowcloudintensity = 1.0f - coverage; + float lowcloudintensity = 1.0f - Max(CWeather::Foggyness, CWeather::CloudCoverage); int r = CTimeCycle::GetLowCloudsRed() * lowcloudintensity; int g = CTimeCycle::GetLowCloudsGreen() * lowcloudintensity; int b = CTimeCycle::GetLowCloudsBlue() * lowcloudintensity; @@ -193,30 +222,6 @@ CClouds::Render(void) float rot_cos = Cos(CloudRotation); int fluffyalpha = 160 * (1.0f - CWeather::Foggyness); if(fluffyalpha != 0){ - static float CoorsOffsetX[37] = { - 0.0f, 60.0f, 72.0f, 48.0f, 21.0f, 12.0f, - 9.0f, -3.0f, -8.4f, -18.0f, -15.0f, -36.0f, - -40.0f, -48.0f, -60.0f, -24.0f, 100.0f, 100.0f, - 100.0f, 100.0f, 100.0f, 100.0f, 100.0f, 100.0f, - 100.0f, 100.0f, -30.0f, -20.0f, 10.0f, 30.0f, - 0.0f, -100.0f, -100.0f, -100.0f, -100.0f, -100.0f, -100.0f - }; - static float CoorsOffsetY[37] = { - 100.0f, 100.0f, 100.0f, 100.0f, 100.0f, 100.0f, - 100.0f, 100.0f, 100.0f, 100.0f, 100.0f, 100.0f, - 100.0f, 100.0f, 100.0f, 100.0f, -30.0f, 10.0f, - -25.0f, -5.0f, 28.0f, -10.0f, 10.0f, 0.0f, - 15.0f, 40.0f, -100.0f, -100.0f, -100.0f, -100.0f, - -100.0f, -40.0f, -20.0f, 0.0f, 10.0f, 30.0f, 35.0f - }; - static float CoorsOffsetZ[37] = { - 2.0f, 1.0f, 0.0f, 0.3f, 0.7f, 1.4f, - 1.7f, 0.24f, 0.7f, 1.3f, 1.6f, 1.0f, - 1.2f, 0.3f, 0.7f, 1.4f, 0.0f, 0.1f, - 0.5f, 0.4f, 0.55f, 0.75f, 1.0f, 1.4f, - 1.7f, 2.0f, 2.0f, 2.3f, 1.9f, 2.4f, - 2.0f, 2.0f, 1.5f, 1.2f, 1.7f, 1.5f, 2.1f - }; static bool bCloudOnScreen[37]; float hilight; @@ -238,7 +243,7 @@ CClouds::Render(void) int bg = CTimeCycle::GetFluffyCloudsBottomGreen(); int bb = CTimeCycle::GetFluffyCloudsBottomBlue(); if(sundist < SCREEN_WIDTH/2){ - hilight = (1.0f - coverage) * (1.0f - sundist/(SCREEN_WIDTH/2)); + hilight = (1.0f - Max(CWeather::Foggyness, CWeather::CloudCoverage)) * (1.0f - sundist/(SCREEN_WIDTH/2)); tr = tr*(1.0f-hilight) + 255*hilight; tg = tg*(1.0f-hilight) + 190*hilight; tb = tb*(1.0f-hilight) + 190*hilight; @@ -286,9 +291,6 @@ CClouds::Render(void) // Rainbow if(CWeather::Rainbow != 0.0f){ - static uint8 BowRed[6] = { 30, 30, 30, 10, 0, 15 }; - static uint8 BowGreen[6] = { 0, 15, 30, 30, 0, 0 }; - static uint8 BowBlue[6] = { 0, 0, 0, 10, 30, 30 }; RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(gpCoronaTexture[0])); for(i = 0; i < 6; i++){ RwV3d pos = { i*1.5f, 100.0f, 5.0f };