Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bug / Crash  Actors do not render when manually rendering camera
#1
Actors do not render when manually using Camera.Render() and rendering to a texture. Steps to reproduce: 

1. Create actor in scene and place camera.
2. Add RawImage to scene to show camera output
3. Disable camera component.
4. Create script
Code:
public class ObiTester : MonoBehaviour
{
    public Camera Camera;
    public RawImage Screen;
    public RenderTexture SourceTexture;

    private void Awake()
    {
        SourceTexture = new RenderTexture(1920, 1080, 1);
        Camera.targetTexture = SourceTexture;
        Screen.texture = SourceTexture;
    }
    private void Update()
    {
        Camera.Render();
    }
}
Reply
#2
Hi,

This is regular Unity behavior: Camera.Render() renders the camera immediately, so any draw calls that haven't been enqueued before the call to Camera.Render() will have no effect. If you want to manually render a camera, make sure to do so after all scripts have had a chance to issue graphics commands for the current frame.

Obi enqueues its drawcalls during the solver's LateUpdate(), in order to minimize the amount of time the main thread spends waiting for worker threads. Attempting to render a camera during Update() before solvers have had time to request any drawing will result in them not being rendered. Instead call Camera.Render() during LateUpdate(), from a script that is set to execute after ObiSolver.

kind regards,
Reply
#3
(09-09-2024, 10:31 PM)josemendez Wrote: Hi,

This is regular Unity behavior: Camera.Render() renders the camera immediately, so any draw calls that haven't been enqueued before the call to Camera.Render() will have no effect. If you want to manually render a camera, make sure to do so after all scripts have had a chance to issue graphics commands for the current frame.

Obi enqueues its drawcalls during the solver's LateUpdate(), in order to minimize the amount of time the main thread spends waiting for worker threads. Attempting to render a camera during Update() before solvers have had time to request any drawing will result in them not being rendered. Instead call Camera.Render() during LateUpdate(), from a script that is set to execute after ObiSolver.

kind regards,

This fixes it. Thanks!
Reply