Object Outlines at Steam VR with Unity 5

Outlines in a VR Environment is pretty useful to give user some visual feedback about intractable objects. In Unity outline effect is not supported, because of that we have to implement it.  I have found this amazing tutorial to create this effect. It works like a charm in a Unity 5 project, where there is only one camera. But in our case, Steam VR uses multiple cameras to render for both eyes. It was confusing for me to figure out how to run this code with Steam VR SDK, since I am new to Postprocessing effects. I would like to share what I have learned during the integration process.

The first thing I have learned is, even though I expected a more complicated structure with cameras, you can treat the  Camera(eye) as main camera. The image filter components on this camera affects both right and left eye images.

Background Information

The outline tutorial that I have mentioned above uses the rendered texture coming from the main camera and post processes it. This is established by OnRenderImage call. Camera renders the image and passes the rendered image texture to the first image filter component on the camera. If there are multiple filters, Unity does image processing sequentially. It determines the order according to scripts position on the inspector and starts from top and goes to the bottom. Therefore where you attach the post processing script is really important.  I have attached the script to the Camera(eye) at the very possible bottom of it. The result was actually funny. The image was flipped.


I tried a lot of complicated solutions, that I have found from the internet but the solution was incredibly simple. There is a SteamVR_CameraFlip script attached on the camera. If we put just under it another SteamVR_CameraFlip script, then everything goes back to normal.

Leave a Reply

Your email address will not be published. Required fields are marked *