Skip to content

Commit

Permalink
timecycle alpha fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aap committed Mar 26, 2020
1 parent 8d19425 commit 988fc5f
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 10 deletions.
4 changes: 2 additions & 2 deletions shaders/ps/radiosityPS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ main(PS_INPUT IN) : COLOR

float4 c = tex2D(tex, uv);

c = saturate(c*2.0 - float4(1,1,1,1)*limit);
c.a = intensity*passes;
c = saturate(c*2.0 - float4(1,1,1,1)*limit) * intensity*passes;
c.a = 1.0;

return c;
}
27 changes: 27 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1235,6 +1235,19 @@ changeEnvMapSize(void)
// Patch(0x726570 + 6, mirrorVal);
//}

/*
WRAPPER void CTimeCycle__Initialise(bool) { EAXJMP(0x5BBAC0); }
void
LoadTimecycle(const char *filename)
{
static char timecyc[256];
strncpy(timecyc, filename, 256);
Patch(0x5BBAD9 + 1, timecyc);
CTimeCycle__Initialise(false);
}
*/

void
installMenu(void)
{
Expand Down Expand Up @@ -1326,6 +1339,20 @@ installMenu(void)

menu.crOffset = DebugMenuAddVar("SkyGFX|ScreenFX", "Cr offset", &config->crOffset, resetValues, 0.004f, -1.0f, 1.0f);

/*
DebugMenuAddVarBool32("SkyGFX", "Timecycle usePC", &config->usePCTimecyc, nil);
DebugMenuAddCmd("SkyGFX", "Timecycle PostFX Alpha *1", [](){
Nop(0x5BBF6F, 2);
Nop(0x5BBF83, 2);
});
DebugMenuAddCmd("SkyGFX", "Timecycle PostFX Alpha *2", [](){
Patch<uint16>(0x5BBF6F, 0xC0DC);
Patch<uint16>(0x5BBF83, 0xC0DC);
});
DebugMenuAddCmd("SkyGFX", "Load PS2 timecyc.dat", [](){ LoadTimecycle("timecyc.dat"); });
DebugMenuAddCmd("SkyGFX", "Load PS2 timecyc_pc.dat", [](){ LoadTimecycle("timecyc_pc.dat"); });
*/

//#ifdef DEBUG
// DebugMenuAddVar("Debug", "Mirror Z", &mirrorVal, fixMirrors, 0.05f, 200.0f, 250.0f);
//#endif
Expand Down
26 changes: 18 additions & 8 deletions src/postfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ CPostEffects::Radiosity_shader(int intensityLimit, int filterPasses, int renderP
RwD3D9SetPixelShaderConstant(1, params, 1);

RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)!m_bRadiosityDebug);
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDONE);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE);
overrideIm2dPixelShader = radiosityPS;
RwIm2DRenderIndexedPrimitive(rwPRIMTYPETRILIST, colorfilterVerts, 4, colorfilterIndices, 6);
Expand Down Expand Up @@ -1227,10 +1227,24 @@ CPostEffects::ColourFilter_switch(RwRGBA rgb1, RwRGBA rgb2)
keystate = false;
}

// Get Alphas into PS2 range always
RwRGBA rgb1pc = rgb1;
RwRGBA rgb2pc = rgb2;

if(config->usePCTimecyc){
// Gotta fix alpha for effects that assume PS2 alpha range
rgb1.alpha /= 2;
rgb2.alpha /= 2;
}else{
// Gotta fix alpha for effects that assume PC alpha range
// clamping this is important!
if(rgb1pc.alpha >= 128)
rgb1pc.alpha = 255;
else
rgb1pc.alpha *= 2;
if(rgb2pc.alpha >= 128)
rgb2pc.alpha = 255;
else
rgb2pc.alpha *= 2;
}

#ifdef VCS
Expand All @@ -1242,9 +1256,7 @@ CPostEffects::ColourFilter_switch(RwRGBA rgb1, RwRGBA rgb2)
break;
case COLORFILTER_PC:
// this effects expects PC alphas
rgb1.alpha *= 2;
rgb2.alpha *= 2;
CPostEffects::ColourFilter(rgb1, rgb2);
CPostEffects::ColourFilter(rgb1pc, rgb2pc);
break;
case COLORFILTER_MOBILE:
// this effects ignores alphas
Expand All @@ -1253,9 +1265,7 @@ CPostEffects::ColourFilter_switch(RwRGBA rgb1, RwRGBA rgb2)
break;
case COLORFILTER_III:
// this effects expects PC alphas
rgb1.alpha *= 2;
rgb2.alpha *= 2;
CPostEffects::ColourFilter_Generic(rgb1, rgb2, iiiTrailsPS);
CPostEffects::ColourFilter_Generic(rgb1pc, rgb2pc, iiiTrailsPS);
break;
case COLORFILTER_VC:
// this effects ignores alphas
Expand Down

0 comments on commit 988fc5f

Please sign in to comment.