Custom Shaders with StereoDisplayRegion

Hello! I’m creating a simulation using a device that requires side-by-side stereo, so I’m using a StereoDisplayRegion to do that. I have a StereoDisplayRegion that holds two DisplayRegions, and each DisplayRegion has a camera corresponding to the eye it represents. When I apply a FilterManager to each camera, weird things happen.

I apply a shader using a FilterManager to each eye, passing in the left camera with the intent of only shading what the left eye sees. The shader is applied, but the positioning of the camera seems to be changed somehow, as if it has been returned to the position of the base camera it is parented to. What is shown does not match up to what the camera shows when no FilterManager is applied at all. Does anyone know what is going on?

For the record, I’m applying a FilterManager to each DisplayRegion inside of the StereoDisplayRegion.

Thanks!

I figured it out, in case anyone else needs to figure this out. I’m using a toe-in approach, so each camera (the left and right eyes) gets a FilterManager. The problem with FilterManager is that it does not keep information about whether the DisplayRegion it finds is designated as a left or right stereo channel.

The solution, while a rough one, is to create two copies of FilterManager, or one for each eye. I called these leftFilterManager and rightFilterManager. You only need to add one line of code inside of the renderSceneInto method:

dr = buffer.getDisplayRegion(0)#Already exists
dr.setStereoChannel(Lens.SCLeft) # Add this line
self.setStackedClears(dr, self.rclears, self.wclears) #Already exists

Of course, Lens.SCLeft is for your leftFilterManager, and Lens.SCRight is for your rightFilterManager.