VRWorks Single Pass Stereo shadows offset

I have been toying around with the new VRWorks plugin from NVIDIA and I have come across an issue that I could use a little help with. I am getting a bit of an offset on the shadows being rendered to the right eye when using Single Pass Stereo and the standard shader. It seems that the shadow pass for the standard shader is using the vertex positions of the left eye when rendering both eyes. (I could be wrong about this though). This is when using a single directional light.

While digging through the unity standard cginc files I found UnityStandardShadow.cginc but I am having a bit of trouble discerning where the position is being set for the shadow cast.

If anyone can point me in the right direction it would be greatly appreciated. I essentially need to modify the standard shader so that the shadows appear in the correct position in the right eye.

To clarify, the shadows on other objects look fine, but the shadows on the objects themselves look offset.

For anyone else looking into this, the shadow caster position is being set in UnityCG.cginc. Specifically in the function UnityClipSpaceShadowCasterPos(float4 vertex, float3 normal).

I haven’t yet figured out what is going on but it appears the vertex position that is going into that function is incorrect for the purposes of NVIDIA VRWorks when using SPS. You could probably add a manual offset to the vertex position but that seems a bit hacky. I will report back when I have more information.

Ok, for those of you who are following along, in order to fix the rendering issue and use VRWorks Single Pass Stereo you have to set the engine stereo rendering mode to Instancing. I will spare you the details of how I journeyed to that conclusion unless you really want to know.

I could not find a drop down selection for Instancing mode and you cannot access PlayerSettings at run-time so I had to create an editor script that set the rendering mode on playersettings. Once I had set PlayerSettings.stereoRenderingPath = StereoRenderingPath.Instancing the weird shadow offset went away.

Currently this is only a fix for VRWorks SPS. The ouput for SPS LMS is more than a little wacky due to how Lens Matched Shading handles things. I will let you know when I figure that one out though.

I haven’t done a thorough test on all the things that this could possibly effect, this is just my initial findings.

Good luck, and Keep Moving Forward!

With SPS, we are also seeing an issue where some shaders (for example, the Default-Sprite material shader) only shows up as rendered in one eye.

Multi-Resolution is pretty much the only mode I’ve been able to get to work thus far that actually seems to function as intended, although I’m not really seeing much performance boost from it.

I don’t know that the default sprite material was ever meant to be stereoscopic since sprites are primarily are used in 2d applications. I would have to look at the shader to see if the stereo macros are implemented.

Did you try your project with the proposed changed I mentioned? Setting the rendering mode to Instancing?

Also, what hardware are you using? I have heard the AMD hardware doesn’t seem to be working well with the NVidia package. That sorta makes sense as NVidia would want to support their hardware first.

From what I have seen, MRS only really gives you a performance boost when your application is pixel bound. If your application is geometry bound then you won’t see much of an improvement.

Any luck getting SPS+LMS to work with unity?

1 Like

No luck so far. I see in the new beta that Instanced stereo render mode is now selectable as preview so it may just be an issue of that mode not being completely ready for prime time. I will check out it out in the beta to see if it is working later on today.

Hey, I know it’s been a while, but any luck getting LMS to work with single pass instanced? I had a similar issue to yours with shadows that was fixed by switching to single pass instanced, but now the left eye looks all wonky in single pass instanced