[2.2+] What's the best way to do mult-viewport rendering
Posted: Mon Jun 29, 2020 11:32 am
Hi!
We need to do multiple rendering from different cameras into different parts of the screen. There are also parts of the screen only occupied by UI controls. Note that there is only one "native window", and all UIs are drawn in a seprate custom pass. I'm thinking about the following solution:
1. Compositor script: A "single viewport" workspace definition and a "UI only" workspace definition
2. C++ code: create one workspace for each viewport, and one workspace from the "UI only" workspacedef. All these workspace renders to the screen
3. When viewport location/sizes changed, change the viewport workspace's parameter so that they render into desired part of the screen
4. Write some viewport management codes to convert coordinates and inject mouse events and ensure only the focused viewport gets keyboard input. So the logic code can still think it's in "fullscreen" mode.
However, I'm not sure how to render (and clear) only part of the screen. And it looks quite easy to mess things up. Any suggestions or sample codes? Thanks!
We need to do multiple rendering from different cameras into different parts of the screen. There are also parts of the screen only occupied by UI controls. Note that there is only one "native window", and all UIs are drawn in a seprate custom pass. I'm thinking about the following solution:
1. Compositor script: A "single viewport" workspace definition and a "UI only" workspace definition
2. C++ code: create one workspace for each viewport, and one workspace from the "UI only" workspacedef. All these workspace renders to the screen
3. When viewport location/sizes changed, change the viewport workspace's parameter so that they render into desired part of the screen
4. Write some viewport management codes to convert coordinates and inject mouse events and ensure only the focused viewport gets keyboard input. So the logic code can still think it's in "fullscreen" mode.
However, I'm not sure how to render (and clear) only part of the screen. And it looks quite easy to mess things up. Any suggestions or sample codes? Thanks!