onnoj / DeusExEchelonRenderer

Fixed-Function Pipeline renderer for Deus Ex (2000), for use with Nvidia's RTX Remix
MIT License
82 stars 2 forks source link

🪧 [QUESTBOARD-FEATURE] Investigate how to implement UE Portal rendering for picture-in-picture (for drone aug) or skybox. #5

Open onnoj opened 3 months ago

onnoj commented 3 months ago

Render portals are currently not supported.

In the renderer as it works today, during the occlusion pass, the full level geometry is emitted when the 'main' frame is processed and cached. For child frames (such as the skybox or the drone view), the original occlusion pass is used instead. In the original render path, software rasterization is done for each camera to determine which part of the BSP tree is rendered, and it is during this occlusion pass that the final triangles are generated (ie, after transform and clipping) to be rendered in the subsequent draw pass.

During the draw pass, this renderer only renders the main frame, all child frames are ignored. The reason is that otherwise RTX Remix gets confused, and renders with the wrong camera view and projection matrix.

The 'problem' is that since RTX Remix is a pathtracing renderer and not a rasterisation renderer, classic masking and scissor tricks don't really work.

The naive way of solving this would be to render two separate frames, back-to-front, and then composite them. For that to work, scissor-rect would need to be honored by RTX-Remix, and we would need to be able to draw a frame without clearing the backbuffer first (haven't tested this).

The fancy way would be to somehow leverage RTX Remix's portal rendering (Used to render the portals in, well, Portal. For that to work we would need to somehow: A) Somehow emit the portal surface as a material of type RtSurfaceMaterialType::RayPortal B) Somehow have RTX Remix identify a 2nd camera pass as the portal camera. both steps require a bit of experimentation and code sleuthing, and maybe some help from the fine folks at NVidia to get going.