fix new renderer

This commit is contained in:
aap 2021-02-28 19:07:32 +01:00 committed by Sergeanur
parent 77ca9c593f
commit c58d98a39e
7 changed files with 45 additions and 8 deletions

View File

@ -670,6 +670,7 @@ char *DoubleSidedNames[] = {
"sbwy_tunl_cstm3", "sbwy_tunl_cstm3",
"sbwy_tunl_cstm2", "sbwy_tunl_cstm2",
"sbwy_tunl_cstm1", "sbwy_tunl_cstm1",
"tenmnt6ad",
"" ""
}; };

View File

@ -1333,11 +1333,13 @@ void
RenderEffects_new(void) RenderEffects_new(void)
{ {
PUSH_RENDERGROUP("RenderEffects_new"); PUSH_RENDERGROUP("RenderEffects_new");
/* // stupid to do this before the whole world is drawn!
CShadows::RenderStaticShadows(); CShadows::RenderStaticShadows();
// CRenderer::GenerateEnvironmentMap // CRenderer::GenerateEnvironmentMap
CShadows::RenderStoredShadows(); CShadows::RenderStoredShadows();
CSkidmarks::Render(); CSkidmarks::Render();
CRubbish::Render(); CRubbish::Render();
*/
// these aren't really effects // these aren't really effects
DefinedState(); DefinedState();
@ -1360,6 +1362,13 @@ if(gbRenderFadingInEntities)
CRenderer::RenderFadingInEntities(); CRenderer::RenderFadingInEntities();
// actual effects here // actual effects here
// from above
CShadows::RenderStaticShadows();
CShadows::RenderStoredShadows();
CSkidmarks::Render();
CRubbish::Render();
CGlass::Render(); CGlass::Render();
// CMattRenderer::ResetRenderStates // CMattRenderer::ResetRenderStates
DefinedState(); DefinedState();

View File

@ -568,6 +568,7 @@ struct BuildingInst
{ {
rw::RawMatrix combinedMat; rw::RawMatrix combinedMat;
rw::d3d9::InstanceDataHeader *instHeader; rw::d3d9::InstanceDataHeader *instHeader;
uint32 cullMode;
uint8 fadeAlpha; uint8 fadeAlpha;
bool lighting; bool lighting;
}; };
@ -612,6 +613,7 @@ AtomicFirstPass(RpAtomic *atomic, int pass)
assert(building->instHeader->platform == PLATFORM_D3D9); assert(building->instHeader->platform == PLATFORM_D3D9);
building->fadeAlpha = 255; building->fadeAlpha = 255;
building->lighting = !!(atomic->geometry->flags & rw::Geometry::LIGHT); building->lighting = !!(atomic->geometry->flags & rw::Geometry::LIGHT);
building->cullMode = rw::GetRenderState(rw::CULLMODE);
rw::uint32 flags = atomic->geometry->flags; rw::uint32 flags = atomic->geometry->flags;
bool setupDone = false; bool setupDone = false;
@ -630,6 +632,7 @@ AtomicFirstPass(RpAtomic *atomic, int pass)
// alright we're rendering this atomic // alright we're rendering this atomic
if(!setupDone){ if(!setupDone){
rw::SetRenderState(rw::CULLMODE, building->cullMode);
setStreamSource(0, building->instHeader->vertexStream[0].vertexBuffer, 0, building->instHeader->vertexStream[0].stride); setStreamSource(0, building->instHeader->vertexStream[0].vertexBuffer, 0, building->instHeader->vertexStream[0].stride);
setIndices(building->instHeader->indexBuffer); setIndices(building->instHeader->indexBuffer);
setVertexDeclaration(building->instHeader->vertexDeclaration); setVertexDeclaration(building->instHeader->vertexDeclaration);
@ -671,6 +674,7 @@ AtomicFullyTransparent(RpAtomic *atomic, int pass, int fadeAlpha)
assert(building->instHeader->platform == PLATFORM_D3D9); assert(building->instHeader->platform == PLATFORM_D3D9);
building->fadeAlpha = fadeAlpha; building->fadeAlpha = fadeAlpha;
building->lighting = !!(atomic->geometry->flags & rw::Geometry::LIGHT); building->lighting = !!(atomic->geometry->flags & rw::Geometry::LIGHT);
building->cullMode = rw::GetRenderState(rw::CULLMODE);
SetMatrix(building, atomic->getFrame()->getLTM()); SetMatrix(building, atomic->getFrame()->getLTM());
numBlendInsts[pass]++; numBlendInsts[pass]++;
} }
@ -688,6 +692,7 @@ RenderBlendPass(int pass)
for(i = 0; i < numBlendInsts[pass]; i++){ for(i = 0; i < numBlendInsts[pass]; i++){
BuildingInst *building = &blendInsts[pass][i]; BuildingInst *building = &blendInsts[pass][i];
rw::SetRenderState(rw::CULLMODE, building->cullMode);
setStreamSource(0, building->instHeader->vertexStream[0].vertexBuffer, 0, building->instHeader->vertexStream[0].stride); setStreamSource(0, building->instHeader->vertexStream[0].vertexBuffer, 0, building->instHeader->vertexStream[0].stride);
setIndices(building->instHeader->indexBuffer); setIndices(building->instHeader->indexBuffer);
setVertexDeclaration(building->instHeader->vertexDeclaration); setVertexDeclaration(building->instHeader->vertexDeclaration);

View File

@ -595,6 +595,7 @@ struct BuildingInst
{ {
rw::Matrix matrix; rw::Matrix matrix;
rw::gl3::InstanceDataHeader *instHeader; rw::gl3::InstanceDataHeader *instHeader;
uint32 cullMode;
uint8 fadeAlpha; uint8 fadeAlpha;
bool lighting; bool lighting;
}; };
@ -627,6 +628,7 @@ AtomicFirstPass(RpAtomic *atomic, int pass)
assert(building->instHeader->platform == PLATFORM_GL3); assert(building->instHeader->platform == PLATFORM_GL3);
building->fadeAlpha = 255; building->fadeAlpha = 255;
building->lighting = !!(atomic->geometry->flags & rw::Geometry::LIGHT); building->lighting = !!(atomic->geometry->flags & rw::Geometry::LIGHT);
building->cullMode = rw::GetRenderState(rw::CULLMODE);
rw::uint32 flags = atomic->geometry->flags; rw::uint32 flags = atomic->geometry->flags;
WorldLights lights; WorldLights lights;
@ -654,6 +656,7 @@ AtomicFirstPass(RpAtomic *atomic, int pass)
// alright we're rendering this atomic // alright we're rendering this atomic
if(!setupDone){ if(!setupDone){
rw::SetRenderState(rw::CULLMODE, building->cullMode);
defaultShader->use(); defaultShader->use();
setWorldMatrix(&building->matrix); setWorldMatrix(&building->matrix);
setupVertexInput(building->instHeader); setupVertexInput(building->instHeader);
@ -686,6 +689,7 @@ AtomicFullyTransparent(RpAtomic *atomic, int pass, int fadeAlpha)
assert(building->instHeader->platform == PLATFORM_GL3); assert(building->instHeader->platform == PLATFORM_GL3);
building->fadeAlpha = fadeAlpha; building->fadeAlpha = fadeAlpha;
building->lighting = !!(atomic->geometry->flags & rw::Geometry::LIGHT); building->lighting = !!(atomic->geometry->flags & rw::Geometry::LIGHT);
building->cullMode = rw::GetRenderState(rw::CULLMODE);
building->matrix = *atomic->getFrame()->getLTM(); building->matrix = *atomic->getFrame()->getLTM();
numBlendInsts[pass]++; numBlendInsts[pass]++;
} }
@ -706,6 +710,7 @@ RenderBlendPass(int pass)
for(i = 0; i < numBlendInsts[pass]; i++){ for(i = 0; i < numBlendInsts[pass]; i++){
BuildingInst *building = &blendInsts[pass][i]; BuildingInst *building = &blendInsts[pass][i];
rw::SetRenderState(rw::CULLMODE, building->cullMode);
setupVertexInput(building->instHeader); setupVertexInput(building->instHeader);
setWorldMatrix(&building->matrix); setWorldMatrix(&building->matrix);
if(building->lighting) if(building->lighting)

View File

@ -82,14 +82,6 @@ CVehicle *CRenderer::m_pFirstPersonVehicle;
bool CRenderer::m_loadingPriority; bool CRenderer::m_loadingPriority;
float CRenderer::ms_lodDistScale = 1.2f; float CRenderer::ms_lodDistScale = 1.2f;
#ifdef EXTRA_MODEL_FLAGS
#define BACKFACE_CULLING_ON SetCullMode(rwCULLMODECULLBACK)
#define BACKFACE_CULLING_OFF SetCullMode(rwCULLMODECULLNONE)
#else
#define BACKFACE_CULLING_ON
#define BACKFACE_CULLING_OFF
#endif
// unused // unused
BlockedRange CRenderer::aBlockedRanges[16]; BlockedRange CRenderer::aBlockedRanges[16];
BlockedRange *CRenderer::pFullBlockedRanges; BlockedRange *CRenderer::pFullBlockedRanges;
@ -442,6 +434,14 @@ CRenderer::RenderOneBuilding(CEntity *ent, float camdist)
RpAtomic *atomic = (RpAtomic*)ent->m_rwObject; RpAtomic *atomic = (RpAtomic*)ent->m_rwObject;
CSimpleModelInfo *mi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(ent->GetModelIndex()); CSimpleModelInfo *mi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(ent->GetModelIndex());
#ifdef EXTRA_MODEL_FLAGS
bool resetCull = false;
if(!ent->IsBuilding() || mi->RenderDoubleSided()){
resetCull = true;
BACKFACE_CULLING_OFF;
}
#endif
int pass = PASS_BLEND; int pass = PASS_BLEND;
if(mi->m_additive) // very questionable if(mi->m_additive) // very questionable
pass = PASS_ADD; pass = PASS_ADD;
@ -471,6 +471,11 @@ CRenderer::RenderOneBuilding(CEntity *ent, float camdist)
}else }else
WorldRender::AtomicFirstPass(atomic, pass); WorldRender::AtomicFirstPass(atomic, pass);
#ifdef EXTRA_MODEL_FLAGS
if(resetCull)
BACKFACE_CULLING_ON;
#endif
ent->bImBeingRendered = false; // TODO: this seems wrong, but do we even need it? ent->bImBeingRendered = false; // TODO: this seems wrong, but do we even need it?
} }
@ -482,6 +487,7 @@ CRenderer::RenderWorld(int pass)
CLink<CVisibilityPlugins::AlphaObjectInfo> *node; CLink<CVisibilityPlugins::AlphaObjectInfo> *node;
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)TRUE); RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)TRUE);
BACKFACE_CULLING_ON;
DeActivateDirectional(); DeActivateDirectional();
SetAmbientColours(); SetAmbientColours();

View File

@ -10,6 +10,14 @@ class CEntity;
#define FADE_DISTANCE 20.0f #define FADE_DISTANCE 20.0f
#define STREAM_DISTANCE 30.0f #define STREAM_DISTANCE 30.0f
#ifdef EXTRA_MODEL_FLAGS
#define BACKFACE_CULLING_ON SetCullMode(rwCULLMODECULLBACK)
#define BACKFACE_CULLING_OFF SetCullMode(rwCULLMODECULLNONE)
#else
#define BACKFACE_CULLING_ON
#define BACKFACE_CULLING_OFF
#endif
extern bool gbShowPedRoadGroups; extern bool gbShowPedRoadGroups;
extern bool gbShowCarRoadGroups; extern bool gbShowCarRoadGroups;
extern bool gbShowCollisionPolys; extern bool gbShowCollisionPolys;

View File

@ -303,6 +303,8 @@ CVisibilityPlugins::RenderFadingEntities(void)
#ifdef EXTRA_MODEL_FLAGS #ifdef EXTRA_MODEL_FLAGS
else if(mi->m_bIsTree) else if(mi->m_bIsTree)
SetAlphaRef(128); SetAlphaRef(128);
if(!e->IsBuilding() || mi->RenderDoubleSided())
BACKFACE_CULLING_OFF;
#endif #endif
if(e->bDistanceFade){ if(e->bDistanceFade){
@ -319,6 +321,7 @@ CVisibilityPlugins::RenderFadingEntities(void)
#ifdef EXTRA_MODEL_FLAGS #ifdef EXTRA_MODEL_FLAGS
if(mi->m_bIsTree) if(mi->m_bIsTree)
SetAlphaRef(2); SetAlphaRef(2);
BACKFACE_CULLING_ON;
#endif #endif
#ifdef FIX_BUGS #ifdef FIX_BUGS
if(mi->GetModelType() == MITYPE_SIMPLE && mi->m_noZwrite) if(mi->GetModelType() == MITYPE_SIMPLE && mi->m_noZwrite)