Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

OnRenderImage() possibly didn't write anything to the destination texture!

Discussion in 'General Graphics' started by BlackPete, Dec 28, 2016.

  1. BlackPete

    BlackPete

    Joined:
    Nov 16, 2016
    Posts:
    970
    So lately I've been getting this "OnRenderImage() possibly didn't write anything to the destination texture!" warning every time I start up my app. It's a one time warning (thankfully) so it doesn't spam me or anything, but I hate seeing warnings for any reason though.

    What exactly triggers this warning? What are the conditions that would cause this warning to appear?

    It first appeared when I decided to do a hack to work around the VR showDeviceView limitation described in a thread I posted earlier: https://forum.unity3d.com/threads/a...eview-to-render-into-a-render-texture.444554/

    The code sorta looks like this:

    Code (csharp):
    1.  
    2.   public class VRCamera : MonoBehaviour
    3.    {
    4.      private Camera _camera;
    5.      private int _frameCount;
    6.  
    7.      public RenderTexture MirrorTexture { get; private set; }
    8.  
    9.      void Awake()
    10.      {
    11.        _camera = GetComponent<Camera>();
    12.        MirrorTexture = new RenderTexture(_camera.pixelWidth, _camera.pixelHeight, 0);
    13.      }
    14.  
    15.      private void OnRenderImage(RenderTexture source, RenderTexture destination)
    16.      {
    17.        Graphics.Blit(source, destination);
    18.  
    19.        if (++_frameCount % 2 == 0)
    20.        {
    21.          Graphics.Blit(source, MirrorTexture);
    22.        }
    23.      }
    24.    }
    25.  
    If I take out the second Blit, the warning goes away. Otherwise I still get the warning even if I do the blit every frame, every other frame (for left eye only), or whatever.
     
    Last edited: Dec 29, 2016
    FranzP3 and drhmiri like this.
  2. mgunbono

    mgunbono

    Joined:
    Mar 31, 2015
    Posts:
    1
    Vinochithra likes this.
  3. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    330
    I somewhat followed this suggestion on a related script. The error disappeared alright but the effect I wanted initially did not also work. This may be a bug in Unity's engine itself as reported here.
     
    Abishekh_Parivel likes this.
  4. redwyre

    redwyre

    Joined:
    Oct 14, 2018
    Posts:
    29
  5. joshmccready

    joshmccready

    Joined:
    Oct 12, 2013
    Posts:
    2
    if for whatever reason it's inconvenient to have the destination texture be the target of the final blit, simply calling

    Graphics.SetRenderTarget(destination);


    seems to fix it