Previous dual pass can't work. Emulating PS2 alpha test now.

This commit is contained in:
aap 2014-11-30 13:48:02 +01:00
parent d290806c66
commit 2f3e170922

View file

@ -382,33 +382,71 @@ RpAtomic* TwoPassAlphaRender(RpAtomic* atomic)
int nZWrite; int nZWrite;
int nAlphaBlending; int nAlphaBlending;
// RwRenderStateGet(rwRENDERSTATEALPHATESTFUNCTIONREF, &nPushedAlpha); RwRenderStateGet(rwRENDERSTATEALPHATESTFUNCTIONREF, &nPushedAlpha);
RwRenderStateGet(rwRENDERSTATEZWRITEENABLE, &nZWrite); RwRenderStateGet(rwRENDERSTATEZWRITEENABLE, &nZWrite);
RwRenderStateGet(rwRENDERSTATEVERTEXALPHAENABLE, &nAlphaBlending); RwRenderStateGet(rwRENDERSTATEVERTEXALPHAENABLE, &nAlphaBlending);
RwRenderStateGet(rwRENDERSTATEALPHATESTFUNCTION, &nAlphaFunction); RwRenderStateGet(rwRENDERSTATEALPHATESTFUNCTION, &nAlphaFunction);
// 1st pass // 1st pass
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, FALSE); RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, reinterpret_cast<void*>(TRUE));
RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTION, reinterpret_cast<void*>(rwALPHATESTFUNCTIONALWAYS)); if (nPushedAlpha == 100) // or should we just force it? do we ever use something else anyway?
// RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTION, reinterpret_cast<void*>(rwALPHATESTFUNCTIONLESS)); RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTIONREF, reinterpret_cast<void*>(128));
RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTION, reinterpret_cast<void*>(rwALPHATESTFUNCTIONGREATEREQUAL));
atomic = AtomicDefaultRenderCallBack(atomic);
if ( atomic )
{
// 2nd pass
RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTION, reinterpret_cast<void*>(rwALPHATESTFUNCTIONLESS));
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, FALSE); RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, FALSE);
AtomicDefaultRenderCallBack(atomic);
}
RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTIONREF, reinterpret_cast<void*>(nPushedAlpha));
RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTION, reinterpret_cast<void*>(nAlphaFunction));
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, reinterpret_cast<void*>(nZWrite));
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, reinterpret_cast<void*>(nAlphaBlending));
return atomic;
}
RpAtomic* TwoPassAlphaRenderSilent(RpAtomic* atomic)
{
// For cutscenes, fall back to one-pass render
if ( CCutsceneMgr__ms_running && !CanSeeOutSideFromCurrArea() )
return OnePassAlphaRender(atomic);
int nPushedAlpha, nAlphaFunction;
int nZWrite;
int nAlphaBlending;
RwRenderStateGet(rwRENDERSTATEALPHATESTFUNCTIONREF, &nPushedAlpha);
RwRenderStateGet(rwRENDERSTATEZWRITEENABLE, &nZWrite);
RwRenderStateGet(rwRENDERSTATEVERTEXALPHAENABLE, &nAlphaBlending);
RwRenderStateGet(rwRENDERSTATEALPHATESTFUNCTION, &nAlphaFunction);
// 1st pass
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, reinterpret_cast<void*>(FALSE));
RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTIONREF, reinterpret_cast<void*>(255));
RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTION, reinterpret_cast<void*>(rwALPHATESTFUNCTIONEQUAL));
atomic = AtomicDefaultRenderCallBack(atomic); atomic = AtomicDefaultRenderCallBack(atomic);
if ( atomic ) if ( atomic )
{ {
// 2nd pass // 2nd pass
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, reinterpret_cast<void*>(TRUE)); RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, reinterpret_cast<void*>(TRUE));
RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTION, reinterpret_cast<void*>(rwALPHATESTFUNCTIONGREATEREQUAL)); RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTION, reinterpret_cast<void*>(rwALPHATESTFUNCTIONLESS));
// RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, FALSE); RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, FALSE);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, reinterpret_cast<void*>(nZWrite));
AtomicDefaultRenderCallBack(atomic); AtomicDefaultRenderCallBack(atomic);
} }
// RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTIONREF, reinterpret_cast<void*>(nPushedAlpha)); RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTIONREF, reinterpret_cast<void*>(nPushedAlpha));
RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTION, reinterpret_cast<void*>(nAlphaFunction)); RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTION, reinterpret_cast<void*>(nAlphaFunction));
// RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, reinterpret_cast<void*>(nZWrite)); RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, reinterpret_cast<void*>(nZWrite));
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, reinterpret_cast<void*>(nAlphaBlending)); RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, reinterpret_cast<void*>(nAlphaBlending));
return atomic; return atomic;
@ -459,7 +497,7 @@ void SetRendererForAtomic(RpAtomic* pAtomic)
BOOL bHasAlpha = FALSE; BOOL bHasAlpha = FALSE;
RpGeometryForAllMaterials(RpAtomicGetGeometry(pAtomic), AlphaTest, &bHasAlpha); RpGeometryForAllMaterials(RpAtomicGetGeometry(pAtomic), AlphaTest, &bHasAlpha);
if ( bHasAlpha ) // if ( bHasAlpha )
RpAtomicSetRenderCallBack(pAtomic, renderer); RpAtomicSetRenderCallBack(pAtomic, renderer);
} }