Back in 2019 we published some high-level guidance on integrating our SilverLining and Triton libraries with virtual reality applications.
Since then, VR has only grown in its prominence in the simulation and training industry, and many of our customers come to use for tips on optimizing performance and visual quality in VR headsets. With SilverLining, it’s a bit tricky because our most popular cloud representations (such as cumulus congestus) are based on 2D billboards, and 2D billboards are notoriously hard to get looking right in VR. The problem is that each eye has a slightly different view angle that the billboard is trying to align with, and this can result in things looking blurry when you get too close to the clouds.
There are a couple of workarounds for this.
- Set the cumulus-billboards-per-cloud setting in your Resources/SilverLining.config file to yes. This causes the billboard matrix to be computed per-cloud, instead of per-billboard, which helps keep things consistent across both eyes’ views.
- Also try setting sort-by-screen-depth to “no”. This can help reduce distracting artifacts from clouds that intersect each other popping in and out of the foreground as the view angle changes, and their sort order changes as a result.
Also, be sure your near clip plane isn’t too far out – this can result in clipping of the clouds as you fly through them, which looks a lot more noticeable in VR for some reason.
The most robust solution, however, it to use the volumetric clouds offered by our STRATOCUMULUS cloud type instead of cumulus congestus. As these are rendered as true 3D ray-casted objects, they are immune to the problems of billboards in VR. When properly configured, they can look very similar to a cumulus congestus layer – but they do come at a higher performance cost.
The other problem you face in VR is simultaneously rendering to two viewports at once. Be sure to refer to the appropriate sample app for guidance on how to do this efficiently. If you are building on top of OpenSceneGraph, there is an OpenSceneGraph Multi-Window sample app in the sample code folder of the SDK you should refer to. If you are directly on top of OpenGL, the OpenGL multi-threaded sample is what you want. For Vulkan, the Vulkan example app provided has the ability to render multiple windows simultaneously as well. In each case, using the ThreadCameraStreamData class to associate SilverLining calls with individual cameras is the key to unlocking SilverLining’s ability to handle these cameras concurrently, or at least in the most efficient manner your framework allows.
There’s an even faster approach that we mentioned before, but it bears repeating: there are extensions for OpenGL, and now for Vulkan as well, that allows rendering two views at once for VR applications. By using SilverLining’s extensible shader framework, it’s possible to inject this into all of SilverLining’s drawing fairly easily. See the OVR_multivew extension for OpenGL, or VK_KHR_multiview for Vulkan.