Screwy directional lighting with PerspectiveLookAtRect


I am usinge PerspectiveLookAtRect to render on to multiple screens from a common camera point. The issue I am seeing is that when objects span rectangles, the lighting does not match in a terribly obvious way:

Since the cameras are identical in all the cases, shouldn’t the lighting be identical too? Seems like a bug to me, but am I missing something? It looks like it is using two different viewpoints, like the center of the rectangles, although the camera is in the same place.

As you can see in the helper window the camera frustums all look correct. Thanks!

PLARTest.v4p (19.4 KB)


And as a sanity check, when I use a Camera node instead of PLAR, the lighting looks correct. Unfortunately I can’t simply use Camera in my actual application because the projections are not so regularly arranged.

PLARTestCamera.v4p (21.3 KB)


Camera example:


while checking the patch for more sanity, i found that changing the Z scaling of the PLAR affects the shading, if you set it to the same value as X it just works, don’t ask me why, might have something to do with the frustrum:


You sir, @tonfilm, are a most righteous dude. I fooled with everything but that. Thank you!

As a user, I still think this is a bug, either in fact or in documentation, as the help patch hard-wires Z to 1. Is there any reason the Z should not just always be set internally to the X value?

Thanks again, this explains SO much weirdness I have seen with PLAR lighting over the years. My old VR CAVE patches will look much better now!


Yaaaarrrrg! Turns out that does NOT work if the quads are not the same, and of course my application has different sized screens. Somehow aspect ratio must figure in this. See attached.

PLARTest3.v4p (23.3 KB)


I’ve found this previously, you have to manually send the view transform to the shader.


That does not work either, if I understand it properly. See attached - somehow I think sending the four cameras into the shader does not seem right. Since I have four different cameras, will I need four instances of the shader, or can I spread them in this way? (5.1 KB)


there you go you had a mess in the variables tLAV, was used to calc normal, so you did’t had an overwritten view on light calculation
also tVW should be calculated inside shader because it’s mul (tV, tW) bad idea to take that from semantics. (8.9 KB)


That is a MASSIVE improvement, thank you! The shading is consistent across corners of dissimilar sized screens, so that will fix my glaring VR CAVE problem.

However, I still don’t think that lighting is “correct” yet, as you can see with the teapot on the left how the lighting changes on it as that “screen” gets wider and thinner. Since this is a fixed view of a fixed object with fixed lighting, the width of the screen should be having no effect on the lighting, correct?

But this does now make the really noticeable problem go away as I am using fixed screen sizes, so thanks to all once again!


And I do have to wonder, is this really the proper fix, to have to modify every shader used with PLAR, or is PLAR just not doing something correctly?


The view needs to come from the viewer position, via an input and not the renderers view as that is distorted by the perspective transform. I’ll have to dig out my patch if I can find it.


Well since you provide your own VIEW you have to modify code in that case… i do render array in that case.
Also you will have incortect highlights if you move your camerra so you have to remove everything that depends on view angle like reflections