mirror of
https://github.com/halpz/re3.git
synced 2025-07-17 09:28:16 +00:00
Remove hacky way of injecting PS2 matfx on RW 3.3, remove static patcher
This commit is contained in:
@ -2,9 +2,8 @@
|
||||
|
||||
#define WITHD3D
|
||||
#include "common.h"
|
||||
#ifdef RWLIBS
|
||||
#include "patcher.h"
|
||||
#endif
|
||||
#include "rwcore.h"
|
||||
#include "rpmatfx.h"
|
||||
|
||||
struct MatFXNothing { int pad[5]; int effect; };
|
||||
|
||||
@ -47,16 +46,16 @@ struct MatFX
|
||||
int effects;
|
||||
};
|
||||
|
||||
#ifdef RWLIBS
|
||||
extern "C" {
|
||||
extern int MatFXMaterialDataOffset;
|
||||
extern int MatFXAtomicDataOffset;
|
||||
|
||||
void _rpMatFXD3D8AtomicMatFXEnvRender(RxD3D8InstanceData* inst, int flags, int sel, RwTexture* texture, RwTexture* envMap);
|
||||
void _rpMatFXD3D8AtomicMatFXRenderBlack(RxD3D8InstanceData *inst);
|
||||
void _rpMatFXD3D8AtomicMatFXBumpMapRender(RxD3D8InstanceData *inst, int flags, RwTexture *texture, RwTexture *bumpMap, RwTexture *envMap);
|
||||
void _rpMatFXD3D8AtomicMatFXDualPassRender(RxD3D8InstanceData *inst, int flags, RwTexture *texture, RwTexture *dualTexture);
|
||||
}
|
||||
#else
|
||||
int &MatFXMaterialDataOffset = *(int*)0x66188C;
|
||||
int &MatFXAtomicDataOffset = *(int*)0x66189C;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef PS2_MATFX
|
||||
|
||||
@ -218,12 +217,96 @@ _rpMatFXD3D8AtomicMatFXEnvRender_ps2(RxD3D8InstanceData *inst, int flags, int se
|
||||
RwD3D8SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0);
|
||||
}
|
||||
|
||||
#ifdef RWLIBS
|
||||
STARTPATCHES
|
||||
InjectHook((uintptr)&_rpMatFXD3D8AtomicMatFXEnvRender, _rpMatFXD3D8AtomicMatFXEnvRender_ps2, PATCH_JUMP);
|
||||
ENDPATCHES
|
||||
#endif
|
||||
void
|
||||
_rwD3D8EnableClippingIfNeeded(void *object, RwUInt8 type)
|
||||
{
|
||||
int clip;
|
||||
if (type == rpATOMIC)
|
||||
clip = !RwD3D8CameraIsSphereFullyInsideFrustum(RwCameraGetCurrentCameraMacro(), RpAtomicGetWorldBoundingSphere((RpAtomic *)object));
|
||||
else
|
||||
clip = !RwD3D8CameraIsBBoxFullyInsideFrustum(RwCameraGetCurrentCameraMacro(), &((RpWorldSector *)object)->tightBoundingBox);
|
||||
RwD3D8SetRenderState(D3DRS_CLIPPING, clip);
|
||||
}
|
||||
|
||||
#endif
|
||||
void
|
||||
_rwD3D8AtomicMatFXRenderCallback(RwResEntry *repEntry, void *object, RwUInt8 type, RwUInt32 flags)
|
||||
{
|
||||
RwBool lighting;
|
||||
RwBool forceBlack;
|
||||
RxD3D8ResEntryHeader *header;
|
||||
RxD3D8InstanceData *inst;
|
||||
RwInt32 i;
|
||||
|
||||
#endif
|
||||
if (flags & rpGEOMETRYPRELIT) {
|
||||
RwD3D8SetRenderState(D3DRS_COLORVERTEX, 1);
|
||||
RwD3D8SetRenderState(D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_COLOR1);
|
||||
} else {
|
||||
RwD3D8SetRenderState(D3DRS_COLORVERTEX, 0);
|
||||
RwD3D8SetRenderState(D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_MATERIAL);
|
||||
}
|
||||
|
||||
_rwD3D8EnableClippingIfNeeded(object, type);
|
||||
|
||||
RwD3D8GetRenderState(D3DRS_LIGHTING, &lighting);
|
||||
if (lighting || flags & rpGEOMETRYPRELIT) {
|
||||
forceBlack = FALSE;
|
||||
} else {
|
||||
forceBlack = TRUE;
|
||||
RwD3D8SetTexture(nil, 0);
|
||||
RwD3D8SetRenderState(D3DRS_TEXTUREFACTOR, D3DCOLOR_RGBA(0, 0, 0, 255));
|
||||
RwD3D8SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG2);
|
||||
RwD3D8SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TFACTOR);
|
||||
}
|
||||
|
||||
header = (RxD3D8ResEntryHeader *)(repEntry + 1);
|
||||
inst = (RxD3D8InstanceData *)(header + 1);
|
||||
for (i = 0; i < header->numMeshes; i++) {
|
||||
if (forceBlack)
|
||||
_rpMatFXD3D8AtomicMatFXRenderBlack(inst);
|
||||
else {
|
||||
if (lighting)
|
||||
RwD3D8SetSurfaceProperties(&inst->material->color, &inst->material->surfaceProps, flags & rpGEOMETRYMODULATEMATERIALCOLOR);
|
||||
MatFX *matfx = *RWPLUGINOFFSET(MatFX *, inst->material, MatFXMaterialDataOffset);
|
||||
int effect = matfx ? matfx->effects : rpMATFXEFFECTNULL;
|
||||
switch (effect) {
|
||||
case rpMATFXEFFECTNULL:
|
||||
default:
|
||||
_rpMatFXD3D8AtomicMatFXDefaultRender(inst, flags, inst->material->texture);
|
||||
break;
|
||||
case rpMATFXEFFECTBUMPMAP:
|
||||
_rpMatFXD3D8AtomicMatFXBumpMapRender(inst, flags, inst->material->texture, matfx->fx[0].b.bumpedTex, nil);
|
||||
break;
|
||||
case rpMATFXEFFECTENVMAP:
|
||||
{
|
||||
// TODO: matfx switch in the settings
|
||||
//_rpMatFXD3D8AtomicMatFXEnvRender(inst, flags, 0, inst->material->texture, matfx->fx[0].e.envTex);
|
||||
_rpMatFXD3D8AtomicMatFXEnvRender_ps2(inst, flags, 0, inst->material->texture, matfx->fx[0].e.envTex);
|
||||
break;
|
||||
}
|
||||
case rpMATFXEFFECTBUMPENVMAP:
|
||||
_rpMatFXD3D8AtomicMatFXBumpMapRender(inst, flags, inst->material->texture, matfx->fx[0].b.bumpedTex, matfx->fx[1].e.envTex);
|
||||
break;
|
||||
case rpMATFXEFFECTDUAL:
|
||||
_rpMatFXD3D8AtomicMatFXDualPassRender(inst, flags, inst->material->texture, matfx->fx[0].d.dualTex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
inst++;
|
||||
}
|
||||
|
||||
if (forceBlack) {
|
||||
RwD3D8SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG2);
|
||||
RwD3D8SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ReplaceMatFxCallback()
|
||||
{
|
||||
RxD3D8AllInOneSetRenderCallBack(
|
||||
RxPipelineFindNodeByName(RpMatFXGetD3D8Pipeline(rpMATFXD3D8ATOMICPIPELINE), RxNodeDefinitionGetD3D8AtomicAllInOne()->name, nil, nil),
|
||||
_rwD3D8AtomicMatFXRenderCallback);
|
||||
}
|
||||
#endif // PS2_MATFX
|
||||
|
||||
#endif // !LIBRW
|
||||
|
Reference in New Issue
Block a user