Hey there,
how can I get the settings of the screen buffer? For optimization I want to render the screen to a RenderTexture, and then show this RenderTexture in a fullscreen RawImage until the user changes something. Therefore, 3D objects are rerendered only when needed and the UI can still be rerendered (compared to OnDemandRendering).
Right now I use the following to create the RenderTexture:
private void StartBuffering()
{
_renderTextureBefore = camera.targetTexture;
if (_staticBuffer == null)
{
_staticBuffer = new RenderTexture(Screen.width, Screen.height, 24);
}
camera.targetTexture = _staticBuffer;
StartCoroutine(WaitForEndOfFrame());
}
private IEnumerator WaitForEndOfFrame()
{
yield return new WaitForEndOfFrame();
camera.targetTexture = _renderTextureBefore;
staticRawImage.gameObject.SetActive(true);
staticRawImage.texture = _staticBuffer;
yield return null;
camera.cullingMask = 0;
}
However, after the rendering the RenderTexture is not the same a the ScreenBuffer. Thin and transparent objects become less visible. You can see the problem in the attached image (left you can see the RenderTexture and on the right the ScreenBuffer).
Thank you for your help!