OSVR / OSVR-Unity

Package for authoring OSVR experiences with Unity.
Apache License 2.0
98 stars 38 forks source link

Image Effects & Deferred Rendering black-out the HDK in DirectMode #165

Closed RedIronLabs closed 8 years ago

RedIronLabs commented 8 years ago

Tested on Unity 5.3.4f1 and 5.3.5f1 OS Name - Microsoft Windows 10 Pro Processor - AMD FX(tm)-9370 Eight-Core Processor, 4400 Mhz, 4 Core(s), 8 Logical Processor(s) Video Card - AMD Radeon (TM) R9 380 Series

Problem If the Camera attached to VRSurface is using Deferred rendering, and a Unity Image Effect is used (any script using OnRenderImage) such as Bloom or custom scripts, the HDK will not render to the display. Changing to Forward will show a normal image.
Changing back to Deferred will freeze the previous image.

Workaround Forward rendering or Extended Mode

Reproduction Steps Set your HDK to Direct Mode Open the default Samples, and open the FPS example. On the VRSurface (eye camera), change it to Deferred. Add a Bloom effect to the eye camera OR a simple test script such as:

    void OnRenderImage(RenderTexture src, RenderTexture dest)
    {
        Graphics.Blit(src, dest);
    }

Expected Camera renders to the eye with the applied effect.,

Actual On Direct Mode systems, rendering is frozen.

Additional Notes I tried to force Camera.Render() to the camera, and prevented it from being disabled (no change). Will update if I find anything useful

RedIronLabs commented 8 years ago

Items to mention...

When I open the actual RenderTexture that is created in forward, and the RenderTexture that is created in Deferred, both match identically in terms of properties (texture format etc). However, the render texture in deferred is not rendering anything but black or the last active forward frame it received.

Creating a simple Camera.targetTexture in deferred, the camera is not black, so I don't think its a Unity engine problem. But I could be wrong

DuFF14 commented 8 years ago

I can reproduce, but it also happens in extended mode for me. When you say "extended", do you mean with no rendermanager, or rendermanager in non-direct mode? Still testing possible solutions like changing when surfaces are rendered (moved render loop to EndOfFrame), but so far haven't seen my changes make any difference.

RedIronLabs commented 8 years ago
                                                                                  Hi GregThanks for checking and replying, I only use RenderManager while in DirectMode, so that might be why I didn't notice that part!I tried moving the camera render priorities as well as forcing rendering of cameras and just couldn't get it to budge. It isn't blocking me from anything currently though. But I have isolated it to that one image rendering command. I tried hard and just couldn't find a way past it...RegardsLloyd                                                                                                                                                                                                                                                                                                                                        Sent from my BlackBerry 10 smartphone.                                                                                                                                                                                                                From: Greg AringSent: Thursday, June 9, 2016 10:09 PMTo: OSVR/OSVR-UnityReply To: OSVR/OSVR-UnityCc: Lloyd Summers; AuthorSubject: Re: [OSVR/OSVR-Unity] Image Effects & Deferred Rendering black-out the HDK in DirectMode (#165)I can reproduce, but it also happens in extended mode for me. When you say "extended", do you mean with no rendermanager, or rendermanager in non-direct mode? Still testing possible solutions like changing when surfaces are rendered (moved render loop to EndOfFrame), but so far haven't seen my changes make any difference. 

—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or mute the thread.

DuFF14 commented 8 years ago

This looks like a bug in Unity, but the fix is to disable AA in quality settings. Built-in AA isn't used in deferred rendering anyway. I've tested that image effects with deferred rendering do work if AA is disabled. http://forum.unity3d.com/threads/5-1-2f1-deferred-rendering-and-image-effect-shows-black-screen.341448/