- Home /
CommandBuffer.DrawRenderer in SinglePass Stereo
Hello,
[Edit: This is still being observed as of 5.6.0f3]
I'm attempting to render objects to a special RenderTexture via CommandBuffer, for later use in an Image Effect.
I create my RenderTexture like this: (NOTE: Simplified for readability)
renderTexture = new RenderTexture(
VRSettings.eyeTextureWidth * 2,
VRSettings.eyeTextureHeight,
0,
RenderTextureFormat.Default,
RenderTextureReadWrite.Default);
My CommandBuffer snippet is as follows: (NOTE: Simplified for readability)
CommandBuffer commandBuffer = new CommandBuffer();
commandBuffer.SetRenderTarget(renderTextureID);
commandBuffer.ClearRenderTarget(true, true, Color.clear, 1f);
for (int i = 0; i < renderers.Length; i++)
{
commandBuffer.DrawRenderer(renderers[i], effectMaterial, 0, 0);
}
camera.AddCommandBuffer(cameraEvent, commandBuffer);
The Shader of effectMaterial simply outputs a solid color to the fragment.
When in Multi-Pass Stereo or disabling VR entirely the effect works as intended, but in Single-Pass the Offscreen RenderTexture looks as if it is only rendering in the Left Eye and is distorted.
This could be (and hopefully is) an error on my part, but I had a similar system working in Unity 5.4.x where the stereo rendering worked correctly in Single-Pass, using CommandBuffers.
Any help would be greatly appreciated!
Thanks in advance.
==
Answer by equalsequals · Jun 13, 2017 at 02:15 AM
This is, unfortunately, a bug.
For posterity, if you use a later CameraEvent, such as BeforeForwardOpaque, Single-Pass works as intended.