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

Image effects don't work when manually rendering camera

Discussion in 'Image Effects' started by Skittlebrau, Jun 21, 2016.

  1. Skittlebrau

    Skittlebrau

    Joined:
    Jan 8, 2013
    Posts:
    34
    Despite the docs implying that Camera.Render will trigger image effects, this does not seem to actaully work. The OnRenderImage method is never called for the attached image effects. I tried doing my effect with CommandBuffers, but those do not seem to work when manually rendering a camera either. Is there a way to fix/work around this?
     
  2. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,221
    seems weird. we do this a lot in our test suits and example projects. can you paste your code so I can see how you are doing this?
     
  3. Skittlebrau

    Skittlebrau

    Joined:
    Jan 8, 2013
    Posts:
    34
    The relevant code is just creating a camera, adding an image effect, disabling the gameobject, then later calling Render on it manually. The OnRenderImage on the image effect will not get called. If the camera is enabled, it does of course get called, but not at the right time since it's not longer being manually rendered. Just to see what happened, I added an OnPostRender call to the image effect and that DOES get called.
     
  4. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,221
    can you raise a bug with a reproduction project so I can test your scenario?
     
  5. Skittlebrau

    Skittlebrau

    Joined:
    Jan 8, 2013
    Posts:
    34
    Here's a contrived sample. I will submit a bug report with it as well. Initially it wasn't 100% clear if this was supposed to work or not.
     

    Attached Files:

  6. Skittlebrau

    Skittlebrau

    Joined:
    Jan 8, 2013
    Posts:
    34
    Bug #808740
     
  7. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,539
    I get this same issue with Application.CaptureScreenshot(), the screenshot ends up being much darker and lacking most of the effects. (and I'll even see the jitter from the TAA)
     
  8. VsionOnnevan

    VsionOnnevan

    Joined:
    Feb 16, 2017
    Posts:
    2
    We're having the same issue, any fix or workaround out there?
     
  9. gonself

    gonself

    Joined:
    Mar 19, 2015
    Posts:
    4
    hi guys!

    i have the same issue... in our game we have a UI button and if you click on it, we launch a Camera.Render() of a inactive camera. This inactive camera has lot of image effects and a render texture, but the texture dont show the image effects, only the view of the camera...

    Its necesary to do something more or is a bug??

    thanks in advance!
     
  10. superjayman

    superjayman

    Joined:
    May 31, 2013
    Posts:
    185
    What is going on with this BUG!! no post effects are being rendered on manual call to Camera.Render()
     
  11. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Same issue here... Really weird.
     
  12. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    By the way, calling camera.Render() always generates a single BlitCopy after the camera is done. Is it possible to get ride of that when we are rendering to a RenderTexture?
     
  13. tomweiland

    tomweiland

    Joined:
    Dec 15, 2017
    Posts:
    19
    Sorry to necro this thread, but I'm having exactly this problem in Unity 2019.3 with URP.

    I have this incredibly useful bit of code that allows me to save the camera output to an image file at a desired resolution. This is great, especially when I want to take screenshots with a higher resolution than what my monitor has, except that when I added some post processing effects the other day, I noticed that they aren't included in the render.

    I've been manually calling the
    Camera.Render
    method, but this only renders the scene—no UI (which was fine, since I didn't really want that in there anyways) and no post processing, which is problematic because screenshots no longer match what the game actually looks like.

    I've tried various other methods, including:
    ScreenCapture.CaptureScreenshot

    ScreenCapture.CaptureScreenshotAsTexture

    ScreenCapture.CaptureScreenshotIntoRenderTexture

    and while those all give me a screenshot that includes the post processing effects, I can't find a way to have them produce a screenshot of a custom resolution (a resolution other than what the game is currently rendering at, whether in-editor or fullscreen).

    Using
    Graphics.Blit
    to make the screenshot match my desired resolution only stretches the image as needed, which is not what I want, and
    Screen.SetResolution()
    doesn't seem to have any effect on the Render method.

    I haven't been able to find the bug report through Google, and I can't find a way to search by issue ID on Unity's issue tracker, so I have no idea if this is intentional or if any workarounds were ever provided (since it obviously wasn't fixed). I also can't find a way of manually rendering image effects, so I'm assuming that calling the Render method is supposed to include that.

    I've already spent a lot more time on this than I would have liked, and I can't believe that pulling this off would be this difficult. Any insight/pointers/suggestions would be hugely appreciated!