Screwy directional lighting with PerspectiveLookAtRect


#1

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)


#2

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)


#3

Camera example:


#4

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:


#5

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!


#6

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)


#7

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


#8

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?

PLARBug4.zip (5.1 KB)


#10

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.

PRLR.zip (8.9 KB)


#11

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!


#12

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?


#13

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.


#14

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