summaryrefslogtreecommitdiffstats
path: root/src/render
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2019-05-31 11:44:43 +0200
committeraap <aap@papnet.eu>2019-05-31 11:44:43 +0200
commit84204471a51f4bd0a4f89619d2dbdb5b59e21be7 (patch)
tree580a74d286d3392733aed0efbf41c9f132f066c8 /src/render
parentCCredits name cleanup (diff)
downloadre3-84204471a51f4bd0a4f89619d2dbdb5b59e21be7.tar
re3-84204471a51f4bd0a4f89619d2dbdb5b59e21be7.tar.gz
re3-84204471a51f4bd0a4f89619d2dbdb5b59e21be7.tar.bz2
re3-84204471a51f4bd0a4f89619d2dbdb5b59e21be7.tar.lz
re3-84204471a51f4bd0a4f89619d2dbdb5b59e21be7.tar.xz
re3-84204471a51f4bd0a4f89619d2dbdb5b59e21be7.tar.zst
re3-84204471a51f4bd0a4f89619d2dbdb5b59e21be7.zip
Diffstat (limited to 'src/render')
-rw-r--r--src/render/MBlur.cpp23
-rw-r--r--src/render/MBlur.h2
-rw-r--r--src/render/PointLights.cpp8
-rw-r--r--src/render/PointLights.h2
-rw-r--r--src/render/Renderer.cpp24
-rw-r--r--src/render/Renderer.h2
-rw-r--r--src/render/Shadows.cpp1
-rw-r--r--src/render/Shadows.h3
-rw-r--r--src/render/VisibilityPlugins.cpp26
-rw-r--r--src/render/VisibilityPlugins.h3
10 files changed, 80 insertions, 14 deletions
diff --git a/src/render/MBlur.cpp b/src/render/MBlur.cpp
index b7a65adc..1d344d35 100644
--- a/src/render/MBlur.cpp
+++ b/src/render/MBlur.cpp
@@ -1,6 +1,7 @@
#include "common.h"
#include "patcher.h"
#include "RwHelper.h"
+#include "Camera.h"
#include "MBlur.h"
RwRaster *&CMBlur::pFrontBuffer = *(RwRaster**)0x8E2C48;
@@ -104,26 +105,26 @@ CMBlur::CreateImmediateModeData(RwCamera *cam, RwRect *rect)
}
void
-CMBlur::MotionBlurRender(RwCamera *cam, uint32 red, uint32 green, uint32 blue, uint32 alpha, int32 type, uint32 bluralpha)
+CMBlur::MotionBlurRender(RwCamera *cam, uint32 red, uint32 green, uint32 blue, uint32 blur, int32 type, uint32 addalpha)
{
- RwRGBA color = { red, green, blue, alpha };
+ RwRGBA color = { red, green, blue, blur };
if(BlurOn){
if(pFrontBuffer){
if(ms_bJustInitialised)
ms_bJustInitialised = false;
else
- OverlayRender(cam, pFrontBuffer, color, type, bluralpha);
+ OverlayRender(cam, pFrontBuffer, color, type, addalpha);
}
RwRasterPushContext(pFrontBuffer);
RwRasterRenderFast(RwCameraGetRaster(cam), 0, 0);
RwRasterPopContext();
}else{
- OverlayRender(cam, nil, color, type, bluralpha);
+ OverlayRender(cam, nil, color, type, addalpha);
}
}
void
-CMBlur::OverlayRender(RwCamera *cam, RwRaster *raster, RwRGBA color, int32 type, uint32 bluralpha)
+CMBlur::OverlayRender(RwCamera *cam, RwRaster *raster, RwRGBA color, int32 type, uint32 addalpha)
{
int r, g, b, a;
@@ -135,31 +136,31 @@ CMBlur::OverlayRender(RwCamera *cam, RwRaster *raster, RwRGBA color, int32 type,
DefinedState();
switch(type){
- case 3:
+ case MBLUR_INTRO1:
r = 0;
g = 255;
b = 0;
a = 128;
break;
- case 5:
+ case MBLUR_INTRO3:
r = 100;
g = 220;
b = 230;
a = 158;
break;
- case 6:
+ case MBLUR_INTRO4:
r = 80;
g = 255;
b = 230;
a = 138;
break;
- case 8:
+ case MBLUR_INTRO6:
r = 255;
g = 60;
b = 60;
a = 200;
break;
- case 9:
+ case MBLUR_UNUSED:
r = 255;
g = 180;
b = 180;
@@ -191,7 +192,7 @@ CMBlur::OverlayRender(RwCamera *cam, RwRaster *raster, RwRGBA color, int32 type,
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
RwIm2DRenderIndexedPrimitive(rwPRIMTYPETRILIST, Vertex, 4, Index, 6);
- a = bluralpha/2;
+ a = addalpha/2;
if(a < 30)
a = 30;
diff --git a/src/render/MBlur.h b/src/render/MBlur.h
index 67ed658f..baa82b80 100644
--- a/src/render/MBlur.h
+++ b/src/render/MBlur.h
@@ -10,6 +10,6 @@ public:
static void MotionBlurOpen(RwCamera *cam);
static void MotionBlurClose(void);
static void CreateImmediateModeData(RwCamera *cam, RwRect *rect);
- static void MotionBlurRender(RwCamera *cam, uint32 red, uint32 green, uint32 blue, uint32 alpha, int32 type, uint32 bluralpha);
+ static void MotionBlurRender(RwCamera *cam, uint32 red, uint32 green, uint32 blue, uint32 blur, int32 type, uint32 addalpha);
static void OverlayRender(RwCamera *cam, RwRaster *raster, RwRGBA color, int32 type, uint32 bluralpha);
};
diff --git a/src/render/PointLights.cpp b/src/render/PointLights.cpp
index 8496d8aa..34cfa658 100644
--- a/src/render/PointLights.cpp
+++ b/src/render/PointLights.cpp
@@ -2,4 +2,12 @@
#include "patcher.h"
#include "PointLights.h"
+int16 &CPointLights::NumLights = *(int16*)0x95CC3E;
+
WRAPPER void CPointLights::RenderFogEffect(void) { EAXJMP(0x510C30); }
+
+void
+CPointLights::InitPerFrame(void)
+{
+ NumLights = 0;
+}
diff --git a/src/render/PointLights.h b/src/render/PointLights.h
index d20fbb7e..e72e8ede 100644
--- a/src/render/PointLights.h
+++ b/src/render/PointLights.h
@@ -2,6 +2,8 @@
class CPointLights
{
+ static int16 &NumLights;
public:
+ static void InitPerFrame(void);
static void RenderFogEffect(void);
};
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index 70002dcf..6979bb19 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -5,6 +5,7 @@
#include "Treadable.h"
#include "Ped.h"
#include "Vehicle.h"
+#include "Heli.h"
#include "Object.h"
#include "PathFind.h"
#include "Collision.h"
@@ -14,6 +15,7 @@
#include "Camera.h"
#include "ModelIndices.h"
#include "Streaming.h"
+#include "Shadows.h"
#include "Renderer.h"
bool gbShowPedRoadGroups;
@@ -48,6 +50,28 @@ CRenderer::Init(void)
gSortedVehiclesAndPeds.Init(40);
SortBIGBuildings();
}
+
+void
+CRenderer::PreRender(void)
+{
+ int i;
+ CLink<CVisibilityPlugins::AlphaObjectInfo> *node;
+
+ for(i = 0; i < ms_nNoOfVisibleEntities; i++)
+ ms_aVisibleEntityPtrs[i]->PreRender();
+
+ for(i = 0; i < ms_nNoOfInVisibleEntities; i++)
+ ms_aInVisibleEntityPtrs[i]->PreRender();
+
+ for(node = CVisibilityPlugins::m_alphaEntityList.tail.prev;
+ node != &CVisibilityPlugins::m_alphaEntityList.head;
+ node = node->prev)
+ ((CEntity*)node->item.entity)->PreRender();
+
+ CHeli::SpecialHeliPreRender();
+ CShadows::RenderExtraPlayerShadows();
+}
+
void
CRenderer::RenderOneRoad(CEntity *e)
{
diff --git a/src/render/Renderer.h b/src/render/Renderer.h
index 970d6ba5..38f2b6f7 100644
--- a/src/render/Renderer.h
+++ b/src/render/Renderer.h
@@ -26,7 +26,7 @@ class CRenderer
static bool &m_loadingPriority;
public:
static void Init(void);
- // TODO: PreRender, needs CHeli and CShadows
+ static void PreRender(void);
static void RenderRoads(void);
static void RenderFadingInEntities(void);
diff --git a/src/render/Shadows.cpp b/src/render/Shadows.cpp
index 81ba75aa..7e184ce7 100644
--- a/src/render/Shadows.cpp
+++ b/src/render/Shadows.cpp
@@ -5,3 +5,4 @@
WRAPPER void CShadows::AddPermanentShadow(unsigned char ShadowType, RwTexture* pTexture, CVector* pPosn, float fX1, float fY1, float fX2, float fY2, short nTransparency, unsigned char nRed, unsigned char nGreen, unsigned char nBlue, float fZDistance, unsigned int nTime, float fScale) { EAXJMP(0x512FD0); }
WRAPPER void CShadows::RenderStaticShadows(void) { EAXJMP(0x5145F0); }
WRAPPER void CShadows::RenderStoredShadows(void) { EAXJMP(0x514010); }
+WRAPPER void CShadows::RenderExtraPlayerShadows(void) { EAXJMP(0x516F90); }
diff --git a/src/render/Shadows.h b/src/render/Shadows.h
index 0a475f6f..9cb3bc71 100644
--- a/src/render/Shadows.h
+++ b/src/render/Shadows.h
@@ -8,4 +8,5 @@ public:
static void AddPermanentShadow(uint8 ShadowType, RwTexture* pTexture, CVector* pPosn, float fX1, float fY1, float fX2, float fY2, short nTransparency, uint8 nRed, uint8 nGreen, uint8 nBlue, float fZDistance, uint32 nTime, float fScale);
static void RenderStaticShadows(void);
static void RenderStoredShadows(void);
-}; \ No newline at end of file
+ static void RenderExtraPlayerShadows(void);
+};
diff --git a/src/render/VisibilityPlugins.cpp b/src/render/VisibilityPlugins.cpp
index d9e87553..5608c933 100644
--- a/src/render/VisibilityPlugins.cpp
+++ b/src/render/VisibilityPlugins.cpp
@@ -5,6 +5,7 @@
#include "ModelInfo.h"
#include "Lights.h"
#include "Renderer.h"
+#include "Camera.h"
#include "VisibilityPlugins.h"
#define FADE_DISTANCE 20.0f
@@ -24,6 +25,7 @@ int32 &CVisibilityPlugins::ms_atomicPluginOffset = *(int32*)0x600124;
int32 &CVisibilityPlugins::ms_framePluginOffset = *(int32*)0x600128;
int32 &CVisibilityPlugins::ms_clumpPluginOffset = *(int32*)0x60012C;
+RwCamera *&CVisibilityPlugins::ms_pCamera = *(RwCamera**)0x8F2514;
RwV3d *&CVisibilityPlugins::ms_pCameraPosn = *(RwV3d**)0x8F6270;
float &CVisibilityPlugins::ms_cullCompsDist = *(float*)0x8F2BC4;
float &CVisibilityPlugins::ms_vehicleLod0Dist = *(float*)0x885B28;
@@ -82,6 +84,28 @@ CVisibilityPlugins::InsertAtomicIntoSortedList(RpAtomic *a, float dist)
return ret;
}
+void
+CVisibilityPlugins::SetRenderWareCamera(RwCamera *camera)
+{
+ ms_pCamera = camera;
+ ms_pCameraPosn = RwMatrixGetPos(RwFrameGetMatrix(RwCameraGetFrame(camera)));
+
+ if(TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWN1 ||
+ TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWNPED)
+ ms_cullCompsDist = 1000000.0f;
+ else
+ ms_cullCompsDist = sq(TheCamera.LODDistMultiplier * 20.0f);
+
+ ms_vehicleLod0Dist = sq(70.0 * TheCamera.GenerationDistMultiplier);
+ ms_vehicleLod1Dist = sq(90.0 * TheCamera.GenerationDistMultiplier);
+ ms_vehicleFadeDist = sq(100.0 * TheCamera.GenerationDistMultiplier);
+ ms_bigVehicleLod0Dist = sq(60.0 * TheCamera.GenerationDistMultiplier);
+ ms_bigVehicleLod1Dist = sq(150.0 * TheCamera.GenerationDistMultiplier);
+ ms_pedLod0Dist = sq(25.0 * TheCamera.LODDistMultiplier);
+ ms_pedLod1Dist = sq(60.0 * TheCamera.LODDistMultiplier);
+ ms_pedFadeDist = sq(70.0 * TheCamera.LODDistMultiplier);
+}
+
RpMaterial*
SetAlphaCB(RpMaterial *material, void *data)
{
@@ -802,6 +826,8 @@ STARTPATCHES
InjectHook(0x528FF0, CVisibilityPlugins::InsertEntityIntoSortedList, PATCH_JUMP);
InjectHook(0x528F80, CVisibilityPlugins::InitAlphaAtomicList, PATCH_JUMP);
InjectHook(0x528FA0, CVisibilityPlugins::InsertAtomicIntoSortedList, PATCH_JUMP);
+ InjectHook(0x528C50, CVisibilityPlugins::SetRenderWareCamera, PATCH_JUMP);
+
InjectHook(0x527F60, SetAlphaCB, PATCH_JUMP);
InjectHook(0x529040, CVisibilityPlugins::RenderAlphaAtomics, PATCH_JUMP);
InjectHook(0x529070, CVisibilityPlugins::RenderFadingEntities, PATCH_JUMP);
diff --git a/src/render/VisibilityPlugins.h b/src/render/VisibilityPlugins.h
index f041b24e..89222dce 100644
--- a/src/render/VisibilityPlugins.h
+++ b/src/render/VisibilityPlugins.h
@@ -22,6 +22,7 @@ public:
static CLinkList<AlphaObjectInfo> &m_alphaList;
static CLinkList<AlphaObjectInfo> &m_alphaEntityList;
+ static RwCamera *&ms_pCamera;
static RwV3d *&ms_pCameraPosn;
static float &ms_cullCompsDist;
static float &ms_vehicleLod0Dist;
@@ -39,6 +40,8 @@ public:
static void InitAlphaAtomicList(void);
static bool InsertAtomicIntoSortedList(RpAtomic *a, float dist);
+ static void SetRenderWareCamera(RwCamera *camera);
+
static RpAtomic *RenderWheelAtomicCB(RpAtomic *atomic);
static RpAtomic *RenderObjNormalAtomic(RpAtomic *atomic);
static RpAtomic *RenderAlphaAtomic(RpAtomic *atomic, int alpha);