mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2024-11-22 13:32:36 +01:00
Improved twopass renderer
This commit is contained in:
parent
62052759e1
commit
4e0d6f592d
@ -196,8 +196,7 @@ RpMaterial* AlphaTest(RpMaterial* pMaterial, void* pData)
|
|||||||
{
|
{
|
||||||
if ( RpMaterialGetTexture(pMaterial) )
|
if ( RpMaterialGetTexture(pMaterial) )
|
||||||
{
|
{
|
||||||
BOOL bHasAlpha = ((BOOL(*)(RwTexture*))0x4C9EA0)(RpMaterialGetTexture(pMaterial));
|
if ( ((BOOL(*)(RwTexture*))0x4C9EA0)(RpMaterialGetTexture(pMaterial)) )
|
||||||
if ( bHasAlpha )
|
|
||||||
{
|
{
|
||||||
*static_cast<BOOL*>(pData) = TRUE;
|
*static_cast<BOOL*>(pData) = TRUE;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -212,6 +211,27 @@ RpMaterial* AlphaTest(RpMaterial* pMaterial, void* pData)
|
|||||||
return pMaterial;
|
return pMaterial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RpMaterial* AlphaTestAndPush(RpMaterial* pMaterial, void* pData)
|
||||||
|
{
|
||||||
|
if ( RpMaterialGetTexture(pMaterial) )
|
||||||
|
{
|
||||||
|
if ( !((BOOL(*)(RwTexture*))0x4C9EA0)(RpMaterialGetTexture(pMaterial)) )
|
||||||
|
{
|
||||||
|
auto pStack = static_cast<std::pair<void*,int>**>(pData);
|
||||||
|
*((*pStack)++) = std::make_pair(&pMaterial->color, *reinterpret_cast<int*>(&pMaterial->color));
|
||||||
|
pMaterial->color.alpha = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( RpMaterialGetColor(pMaterial)->alpha == 255 )
|
||||||
|
{
|
||||||
|
auto pStack = static_cast<std::pair<void*,int>**>(pData);
|
||||||
|
*((*pStack)++) = std::make_pair(&pMaterial->color, *reinterpret_cast<int*>(&pMaterial->color));
|
||||||
|
pMaterial->color.alpha = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
RpAtomic* TwoPassAlphaRender(RpAtomic* atomic)
|
RpAtomic* TwoPassAlphaRender(RpAtomic* atomic)
|
||||||
{
|
{
|
||||||
int nPushedAlpha, nAlphaFunction;
|
int nPushedAlpha, nAlphaFunction;
|
||||||
@ -232,15 +252,20 @@ RpAtomic* TwoPassAlphaRender(RpAtomic* atomic)
|
|||||||
|
|
||||||
// 2nd pass
|
// 2nd pass
|
||||||
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, reinterpret_cast<void*>(TRUE));
|
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, reinterpret_cast<void*>(TRUE));
|
||||||
RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTIONREF, reinterpret_cast<void*>(0));
|
|
||||||
RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTION, reinterpret_cast<void*>(rwALPHATESTFUNCTIONLESS));
|
RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTION, reinterpret_cast<void*>(rwALPHATESTFUNCTIONLESS));
|
||||||
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, FALSE);
|
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, FALSE);
|
||||||
|
|
||||||
AtomicDefaultRenderCallBack(atomic);
|
// Push materials
|
||||||
|
std::pair<void*,int> MatsCache[16];
|
||||||
|
auto* pMats = MatsCache;
|
||||||
|
|
||||||
|
RpGeometryForAllMaterials(RpAtomicGetGeometry(atomic), AlphaTestAndPush, &pMats);
|
||||||
|
AtomicDefaultRenderCallBack(atomic);
|
||||||
|
pMats->first = nullptr;
|
||||||
|
|
||||||
|
for ( auto i = MatsCache; i->first; i++ )
|
||||||
|
*static_cast<int*>(i->first) = i->second;
|
||||||
|
|
||||||
/*RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTIONREF, 0);
|
|
||||||
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, FALSE);
|
|
||||||
auto* pAtomic = 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));
|
||||||
|
Loading…
Reference in New Issue
Block a user