void FGLRenderer::DrawScene(int drawmode) { static int recursion=0; if (camera != nullptr) { ActorRenderFlags savedflags = camera->renderflags; if (drawmode != DM_PORTAL && !r_showviewer) { camera->renderflags |= RF_INVISIBLE; } CreateScene(); camera->renderflags = savedflags; } else { CreateScene(); } GLRenderer->mClipPortal = NULL; // this must be reset before any portal recursion takes place. RenderScene(recursion); // Handle all portals after rendering the opaque objects but before // doing all translucent stuff recursion++; GLPortal::EndFrame(); recursion--; RenderTranslucent(); }
void RenderPolyScene::Render(PolyPortalViewpoint *viewpoint) { PolyPortalViewpoint *oldviewpoint = CurrentViewpoint; CurrentViewpoint = viewpoint; PolyRenderThread *thread = PolyRenderer::Instance()->Threads.MainThread(); CurrentViewpoint->ObjectsStart = thread->TranslucentObjects.size(); CurrentViewpoint->SectorPortalsStart = thread->SectorPortals.size(); CurrentViewpoint->LinePortalsStart = thread->LinePortals.size(); PolyCullCycles.Clock(); Cull.CullScene(CurrentViewpoint->PortalEnterSector, CurrentViewpoint->PortalEnterLine); PolyCullCycles.Unclock(); RenderSectors(); PolyMaskedCycles.Clock(); const auto &rviewpoint = PolyRenderer::Instance()->Viewpoint; for (uint32_t sectorIndex : Cull.SeenSectors) { sector_t *sector = &PolyRenderer::Instance()->Level->sectors[sectorIndex]; for (AActor *thing = sector->thinglist; thing != nullptr; thing = thing->snext) { if (!RenderPolySprite::IsThingCulled(thing)) { int spritenum = thing->sprite; bool isPicnumOverride = thing->picnum.isValid(); FSpriteModelFrame *modelframe = isPicnumOverride ? nullptr : FindModelFrame(thing->GetClass(), spritenum, thing->frame, !!(thing->flags & MF_DROPPED)); double distanceSquared = (thing->Pos() - rviewpoint.Pos).LengthSquared(); if (r_modelscene && modelframe && distanceSquared < model_distance_cull) { AddModel(thread, thing, distanceSquared, thing->Pos()); } else { DVector2 left, right; if (!RenderPolySprite::GetLine(thing, left, right)) continue; AddSprite(thread, thing, distanceSquared, left, right); } } } } PolyMaskedCycles.Unclock(); CurrentViewpoint->ObjectsEnd = thread->TranslucentObjects.size(); CurrentViewpoint->SectorPortalsEnd = thread->SectorPortals.size(); CurrentViewpoint->LinePortalsEnd = thread->LinePortals.size(); Skydome.Render(thread, CurrentViewpoint->WorldToView, CurrentViewpoint->WorldToClip); RenderPortals(); RenderTranslucent(); CurrentViewpoint = oldviewpoint; }
void FGLRenderer::DrawScene(int drawmode) { static int recursion=0; static int ssao_portals_available = 0; bool applySSAO = false; if (drawmode == DM_MAINVIEW) { ssao_portals_available = gl_ssao_portals; applySSAO = true; } else if (drawmode == DM_OFFSCREEN) { ssao_portals_available = 0; } else if (ssao_portals_available > 0) { applySSAO = true; ssao_portals_available--; } if (camera != nullptr) { ActorRenderFlags savedflags = camera->renderflags; CreateScene(); camera->renderflags = savedflags; } else { CreateScene(); } GLRenderer->mClipPortal = NULL; // this must be reset before any portal recursion takes place. RenderScene(recursion); if (applySSAO && gl_RenderState.GetPassType() == GBUFFER_PASS) { gl_RenderState.EnableDrawBuffers(1); AmbientOccludeScene(); mBuffers->BindSceneFB(true); gl_RenderState.EnableDrawBuffers(gl_RenderState.GetPassDrawBufferCount()); gl_RenderState.Apply(); gl_RenderState.ApplyMatrices(); } // Handle all portals after rendering the opaque objects but before // doing all translucent stuff recursion++; GLPortal::EndFrame(); recursion--; RenderTranslucent(); }