1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-11-06 05:45:55 +00:00

work on colourfilters

This commit is contained in:
aap 2021-01-19 20:42:16 +01:00
parent 8baae4c77f
commit 7e136a792f
9 changed files with 81 additions and 48 deletions

View file

@ -3863,7 +3863,7 @@ CCamera::GetScreenFadeStatus(void)
} }
//--LCS: TODO
void void
CCamera::RenderMotionBlur(void) CCamera::RenderMotionBlur(void)
{ {
@ -3872,7 +3872,8 @@ CCamera::RenderMotionBlur(void)
CMBlur::MotionBlurRender(m_pRwCamera, CMBlur::MotionBlurRender(m_pRwCamera,
m_BlurRed, m_BlurGreen, m_BlurBlue, m_BlurRed, m_BlurGreen, m_BlurBlue,
m_motionBlur, m_BlurType, m_imotionBlurAddAlpha); // m_motionBlur, m_BlurType, m_imotionBlurAddAlpha);
m_motionBlur, m_BlurType, 32); // hack hack
} }
void void

View file

@ -651,8 +651,8 @@ extern bool gbRenderWorld2;
#endif #endif
#ifdef EXTENDED_COLOURFILTER #ifdef EXTENDED_COLOURFILTER
static const char *filternames[] = { "None", "PS2" }; static const char *filternames[] = { "None", "PSP", "PS2" };
e = DebugMenuAddVar("Render", "Colourfilter", &CPostFX::EffectSwitch, nil, 1, CPostFX::POSTFX_OFF, CPostFX::POSTFX_NORMAL, filternames); e = DebugMenuAddVar("Render", "Colourfilter", &CPostFX::EffectSwitch, nil, 1, CPostFX::POSTFX_OFF, CPostFX::POSTFX_PS2, filternames);
DebugMenuEntrySetWrap(e, true); DebugMenuEntrySetWrap(e, true);
DebugMenuAddVar("Render", "Intensity", &CPostFX::Intensity, nil, 0.05f, 0, 10.0f); DebugMenuAddVar("Render", "Intensity", &CPostFX::Intensity, nil, 0.05f, 0, 10.0f);
DebugMenuAddVarBool8("Render", "Blur", &CPostFX::BlurOn, nil); DebugMenuAddVarBool8("Render", "Blur", &CPostFX::BlurOn, nil);

View file

@ -16,13 +16,15 @@
RwRaster *CPostFX::pFrontBuffer; RwRaster *CPostFX::pFrontBuffer;
RwRaster *CPostFX::pBackBuffer; RwRaster *CPostFX::pBackBuffer;
bool CPostFX::bJustInitialised; bool CPostFX::bJustInitialised;
int CPostFX::EffectSwitch = POSTFX_NORMAL; int CPostFX::EffectSwitch = POSTFX_PS2;
bool CPostFX::BlurOn = false; bool CPostFX::BlurOn = false;
bool CPostFX::MotionBlurOn = false; bool CPostFX::MotionBlurOn = false;
static RwIm2DVertex Vertex[4]; static RwIm2DVertex Vertex[4];
static RwIm2DVertex Vertex2[4]; static RwIm2DVertex Vertex2[4];
static RwImVertexIndex Index[6] = { 0, 1, 2, 0, 2, 3 }; static RwImVertexIndex Index[6] = { 0, 1, 2, 0, 2, 3 };
static RwIm2DVertex BlurVertex[12];
static RwImVertexIndex BlurIndex[18] = { 0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8, 10, 11 };
#ifdef RW_D3D9 #ifdef RW_D3D9
void *colourfilterLCS_PS; void *colourfilterLCS_PS;
@ -205,9 +207,44 @@ CPostFX::Close(void)
#endif #endif
} }
static float blurOffset = 0.6f;//3.0f/16.0f; // not quite sure sure about this
static float blurIntensity = 0.25f;
void void
CPostFX::RenderOverlayBlur(RwCamera *cam, int32 r, int32 g, int32 b, int32 a) CPostFX::RenderOverlayBlur(RwCamera *cam, int32 r, int32 g, int32 b, int32 a)
{ {
memcpy(BlurVertex, Vertex, sizeof(Vertex));
memcpy(BlurVertex+4, Vertex, sizeof(Vertex));
memcpy(BlurVertex+8, Vertex, sizeof(Vertex));
int intensity = 255*blurIntensity;
int i;
for(i = 0; i < 4; i++){
RwIm2DVertexSetScreenX(&BlurVertex[i], RwIm2DVertexGetScreenX(&BlurVertex[i]) + blurOffset);
RwIm2DVertexSetIntRGBA(&BlurVertex[i], 255, 255, 255, intensity);
}
for(i = 4; i < 8; i++){
RwIm2DVertexSetScreenX(&BlurVertex[i], RwIm2DVertexGetScreenX(&BlurVertex[i]) + blurOffset);
RwIm2DVertexSetScreenY(&BlurVertex[i], RwIm2DVertexGetScreenY(&BlurVertex[i]) + blurOffset);
RwIm2DVertexSetIntRGBA(&BlurVertex[i], 255, 255, 255, intensity);
}
for(i = 8; i < 12; i++){
RwIm2DVertexSetScreenY(&BlurVertex[i], RwIm2DVertexGetScreenY(&BlurVertex[i]) + blurOffset);
RwIm2DVertexSetIntRGBA(&BlurVertex[i], 255, 255, 255, intensity);
}
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, pBackBuffer);
RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
RwIm2DRenderIndexedPrimitive(rwPRIMTYPETRILIST, BlurVertex, 12, BlurIndex, 18);
// this sucks: should render colourfilter with blending instead
// but can't change equation to subtraction for PSP here
GetBackBuffer(cam);
/* the old way
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, pFrontBuffer); RwRenderStateSet(rwRENDERSTATETEXTURERASTER, pFrontBuffer);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
@ -240,6 +277,7 @@ CPostFX::RenderOverlayBlur(RwCamera *cam, int32 r, int32 g, int32 b, int32 a)
RwIm2DRenderIndexedPrimitive(rwPRIMTYPETRILIST, Vertex, 4, Index, 6); RwIm2DRenderIndexedPrimitive(rwPRIMTYPETRILIST, Vertex, 4, Index, 6);
RwIm2DRenderIndexedPrimitive(rwPRIMTYPETRILIST, BlurOn ? Vertex2 : Vertex, 4, Index, 6); RwIm2DRenderIndexedPrimitive(rwPRIMTYPETRILIST, BlurOn ? Vertex2 : Vertex, 4, Index, 6);
*/
} }
void void
@ -291,7 +329,7 @@ CPostFX::RenderOverlayShader(RwCamera *cam, int32 r, int32 g, int32 b, int32 a)
blurcolors[0] = r*f/255.0f; blurcolors[0] = r*f/255.0f;
blurcolors[1] = g*f/255.0f; blurcolors[1] = g*f/255.0f;
blurcolors[2] = b*f/255.0f; blurcolors[2] = b*f/255.0f;
blurcolors[3] = 30/255.0f; blurcolors[3] = EffectSwitch == POSTFX_PSP ? -1.0f : 1.0f;
#ifdef RW_D3D9 #ifdef RW_D3D9
rw::d3d::d3ddevice->SetPixelShaderConstantF(10, blurcolors, 1); rw::d3d::d3ddevice->SetPixelShaderConstantF(10, blurcolors, 1);
rw::d3d::im2dOverridePS = colourfilterLCS_PS; rw::d3d::im2dOverridePS = colourfilterLCS_PS;
@ -339,11 +377,8 @@ CPostFX::NeedBackBuffer(void)
case POSTFX_SIMPLE: case POSTFX_SIMPLE:
// no actual rendering here // no actual rendering here
return false; return false;
case POSTFX_NORMAL: case POSTFX_PSP:
if(MotionBlurOn) case POSTFX_PS2:
return false;
else
return true;
case POSTFX_MOBILE: case POSTFX_MOBILE:
return true; return true;
} }
@ -354,24 +389,11 @@ bool
CPostFX::NeedFrontBuffer(int32 type) CPostFX::NeedFrontBuffer(int32 type)
{ {
// Last frame -- needed for motion blur // Last frame -- needed for motion blur
if(CMBlur::Drunkness > 0.0f) if(MotionBlurOn)
return true; return true;
if(type == MOTION_BLUR_SNIPER) if(type == MOTION_BLUR_SNIPER)
return true; 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; return false;
} }
@ -386,11 +408,17 @@ CPostFX::GetBackBuffer(RwCamera *cam)
void void
CPostFX::Render(RwCamera *cam, uint32 red, uint32 green, uint32 blue, uint32 blur, int32 type, uint32 bluralpha) CPostFX::Render(RwCamera *cam, uint32 red, uint32 green, uint32 blue, uint32 blur, int32 type, uint32 bluralpha)
{ {
// LCS PS2 blur is drawn in three passes:
// blend frame with current frame 3 times to blur a bit
// blend one more time with colour filter
// motion blur like normal
if(pFrontBuffer == nil) if(pFrontBuffer == nil)
Open(cam); Open(cam);
assert(pFrontBuffer); assert(pFrontBuffer);
assert(pBackBuffer); assert(pBackBuffer);
/* // LCS: don't need that anymore
if(type == MOTION_BLUR_LIGHT_SCENE){ if(type == MOTION_BLUR_LIGHT_SCENE){
SmoothColor(red, green, blue, blur); SmoothColor(red, green, blue, blur);
red = AvgRed; red = AvgRed;
@ -398,6 +426,7 @@ CPostFX::Render(RwCamera *cam, uint32 red, uint32 green, uint32 blue, uint32 blu
blue = AvgBlue; blue = AvgBlue;
blur = AvgAlpha; blur = AvgAlpha;
} }
*/
if(NeedBackBuffer()) if(NeedBackBuffer())
GetBackBuffer(cam); GetBackBuffer(cam);
@ -405,10 +434,15 @@ CPostFX::Render(RwCamera *cam, uint32 red, uint32 green, uint32 blue, uint32 blu
DefinedState(); DefinedState();
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERNEAREST);
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE);
if(BlurOn)
RenderOverlayBlur(cam, 0, 0, 0, 0);
RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERNEAREST);
// TODO(LCS): check this out
if(type == MOTION_BLUR_SNIPER){ if(type == MOTION_BLUR_SNIPER){
if(!bJustInitialised) if(!bJustInitialised)
RenderOverlaySniper(cam, red, green, blue, blur); RenderOverlaySniper(cam, red, green, blue, blur);
@ -417,21 +451,16 @@ CPostFX::Render(RwCamera *cam, uint32 red, uint32 green, uint32 blue, uint32 blu
case POSTFX_SIMPLE: case POSTFX_SIMPLE:
// no actual rendering here // no actual rendering here
break; break;
case POSTFX_NORMAL: case POSTFX_PSP:
if(MotionBlurOn){ case POSTFX_PS2:
if(!bJustInitialised)
RenderOverlayBlur(cam, red, green, blue, blur);
}else{
RenderOverlayShader(cam, red, green, blue, blur);
}
break;
case POSTFX_MOBILE: case POSTFX_MOBILE:
RenderOverlayShader(cam, red, green, blue, blur); RenderOverlayShader(cam, red, green, blue, blur);
break; break;
} }
if(!bJustInitialised) if(MotionBlurOn)
RenderMotionBlur(cam, 175.0f * CMBlur::Drunkness); if(!bJustInitialised)
RenderMotionBlur(cam, bluralpha);
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE); RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE); RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE);

View file

@ -7,9 +7,8 @@ class CPostFX
public: public:
enum { enum {
POSTFX_OFF, POSTFX_OFF,
// POSTFX_SIMPLE, POSTFX_PSP,
POSTFX_NORMAL, POSTFX_PS2,
// POSTFX_MOBILE
// not so sensible for the moment // not so sensible for the moment
POSTFX_SIMPLE = -1, POSTFX_SIMPLE = -1,

View file

@ -1,13 +1,10 @@
sampler2D tex : register(s0); sampler2D tex : register(s0);
float4 blurcol : register(c10); float4 blurcol : register(c10);
//float4 blurcols[10] : register(c15);
float4 main(in float2 texcoord : TEXCOORD0) : COLOR0 float4 main(in float2 texcoord : TEXCOORD0) : COLOR0
{ {
float4 dst = tex2D(tex, texcoord.xy); float4 dst = tex2D(tex, texcoord.xy);
dst += dst*blurcol; dst += dst*blurcol*blurcol.a;
dst.a = 1.0; dst.a = 1.0;
return dst; return dst;
} }

View file

@ -19,9 +19,10 @@ static unsigned char colourfilterLCS_PS_cso[] = {
0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x03, 0xb0, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x03, 0xb0,
0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x90, 0x00, 0x08, 0x0f, 0xa0, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x90, 0x00, 0x08, 0x0f, 0xa0,
0x42, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xb0, 0x42, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xb0,
0x00, 0x08, 0xe4, 0xa0, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x07, 0x80, 0x00, 0x08, 0xe4, 0xa0, 0x05, 0x00, 0x00, 0x03, 0x01, 0x00, 0x07, 0x80,
0x00, 0x00, 0xe4, 0x80, 0x0a, 0x00, 0xe4, 0xa0, 0x00, 0x00, 0xe4, 0x80, 0x00, 0x00, 0xe4, 0x80, 0x0a, 0x00, 0xe4, 0xa0, 0x04, 0x00, 0x00, 0x04,
0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x08, 0x80, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x07, 0x80, 0x01, 0x00, 0xe4, 0x80, 0x0a, 0x00, 0xff, 0xa0,
0x01, 0x00, 0x00, 0x02, 0x00, 0x08, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0x80, 0x00, 0x00, 0xe4, 0x80, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x08, 0x80,
0xff, 0xff, 0x00, 0x00 0x00, 0x00, 0x00, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x00, 0x08, 0x0f, 0x80,
0x00, 0x00, 0xe4, 0x80, 0xff, 0xff, 0x00, 0x00
}; };

View file

@ -411,6 +411,9 @@ void RwIm2DVertexSetRecipCameraZ(RwIm2DVertex *vert, RwReal recipz) { vert->setR
void RwIm2DVertexSetScreenX(RwIm2DVertex *vert, RwReal scrnx) { vert->setScreenX(scrnx); } void RwIm2DVertexSetScreenX(RwIm2DVertex *vert, RwReal scrnx) { vert->setScreenX(scrnx); }
void RwIm2DVertexSetScreenY(RwIm2DVertex *vert, RwReal scrny) { vert->setScreenY(scrny); } void RwIm2DVertexSetScreenY(RwIm2DVertex *vert, RwReal scrny) { vert->setScreenY(scrny); }
void RwIm2DVertexSetScreenZ(RwIm2DVertex *vert, RwReal scrnz) { vert->setScreenZ(scrnz); } void RwIm2DVertexSetScreenZ(RwIm2DVertex *vert, RwReal scrnz) { vert->setScreenZ(scrnz); }
float RwIm2DVertexGetScreenX(RwIm2DVertex *vert) { return vert->getScreenX(); }
float RwIm2DVertexGetScreenY(RwIm2DVertex *vert) { return vert->getScreenY(); }
float RwIm2DVertexGetScreenZ(RwIm2DVertex *vert) { return vert->getScreenZ(); }
void RwIm2DVertexSetU(RwIm2DVertex *vert, RwReal texU, RwReal recipz) { vert->setU(texU, recipz); } void RwIm2DVertexSetU(RwIm2DVertex *vert, RwReal texU, RwReal recipz) { vert->setU(texU, recipz); }
void RwIm2DVertexSetV(RwIm2DVertex *vert, RwReal texV, RwReal recipz) { vert->setV(texV, recipz); } void RwIm2DVertexSetV(RwIm2DVertex *vert, RwReal texV, RwReal recipz) { vert->setV(texV, recipz); }
void RwIm2DVertexSetIntRGBA(RwIm2DVertex *vert, RwUInt8 red, RwUInt8 green, RwUInt8 blue, RwUInt8 alpha) { vert->setColor(red, green, blue, alpha); } void RwIm2DVertexSetIntRGBA(RwIm2DVertex *vert, RwUInt8 red, RwUInt8 green, RwUInt8 blue, RwUInt8 alpha) { vert->setColor(red, green, blue, alpha); }

View file

@ -34,6 +34,9 @@ void RwIm2DVertexSetRecipCameraZ(RwIm2DVertex *vert, RwReal recipz);
void RwIm2DVertexSetScreenX(RwIm2DVertex *vert, RwReal scrnx); void RwIm2DVertexSetScreenX(RwIm2DVertex *vert, RwReal scrnx);
void RwIm2DVertexSetScreenY(RwIm2DVertex *vert, RwReal scrny); void RwIm2DVertexSetScreenY(RwIm2DVertex *vert, RwReal scrny);
void RwIm2DVertexSetScreenZ(RwIm2DVertex *vert, RwReal scrnz); void RwIm2DVertexSetScreenZ(RwIm2DVertex *vert, RwReal scrnz);
float RwIm2DVertexGetScreenX(RwIm2DVertex *vert);
float RwIm2DVertexGetScreenY(RwIm2DVertex *vert);
float RwIm2DVertexGetScreenZ(RwIm2DVertex *vert);
void RwIm2DVertexSetU(RwIm2DVertex *vert, RwReal texU, RwReal recipz); void RwIm2DVertexSetU(RwIm2DVertex *vert, RwReal texU, RwReal recipz);
void RwIm2DVertexSetV(RwIm2DVertex *vert, RwReal texV, RwReal recipz); void RwIm2DVertexSetV(RwIm2DVertex *vert, RwReal texV, RwReal recipz);
void RwIm2DVertexSetIntRGBA(RwIm2DVertex *vert, RwUInt8 red, RwUInt8 green, RwUInt8 blue, RwUInt8 alpha); void RwIm2DVertexSetIntRGBA(RwIm2DVertex *vert, RwUInt8 red, RwUInt8 green, RwUInt8 blue, RwUInt8 alpha);