# Correcting perspective distortion for an angeld projector (Keystone effect)

My goal is to create a realistic reproduction of a projector mounted on the ceiling. So far I can reproduce a projector that is projecting straight. But I cannot wrap my head around how to correct perspective distortion when the projector is tilted down.

Edit: The Solution shoud work like you woud expect from a real world projector. With the light beam originating from the lamp position spreading out onto the surface and interacting with objects in between.

For a prjector taht points 90° to the wall evything works fine.

As soon as i tilt the Projector i introduce Perspective distortion

Node tree to get the lamp to project a texture without barrel distorion like here or here

This example file:

• It would also be nice if we could calculate the Scale and settings direcly from the projector position relative to the wall. – J.Doe Apr 6 at 14:33

I made a node group. It isn't perfect but works just fine for non-extreme cases. Hope this helps This node group can be further condensed, but it is better this way for better clarity.

To know what Horizontal and Vertical inputs mean see: Keystone Correction

• this helps already a lot! Now all thats left is to get rid of the distorion :) – J.Doe Apr 3 at 15:30

I don't know whether this suits, you might be wanting more of a simulation of real lenses. But we have an unusual advantage here in CG-world .. the projector can know how far away it is from the points it's projecting onto, via a Ray Length output of a Light Path node.

By similar triangles, (multiplying the normal by the ray-length) the spherical look-up, using the lamp's normal direction, can be corrected back to an orthogonal look-up into the texture, correcting the keystone.

Assuming the lamp is rotating around its X axis, that angle can be used in a driver to correct the aspect ratio of the resulting rectangle.A sine is taken only because the wall is at 90 degrees. If the lamp was projecting onto the floor, or the lamp was parented to a screen with its Z pointing towards it, that would be a cosine.

I've also set the lamp's falloff to 'Constant', so the image is evenly bright. You may want to switch that out.

• Hmm actualy now after trying to work with this solution i realized it dosnt work the way you would expect form a projector. When i put Objects in the Path of the Light not in the plane which its projecting onto.. the Light beam compes from a totaly unexpected angle and not the Position of the Projecting Lamp. – J.Doe Apr 22 at 16:16

I found another method to correct keystone distortion thanks to this paper. It too has its limitations. I guess if you take an average of this and my previous setup, you would get the best result.

Thanks, I had the same query. But to avoid the non linear distorsion of the edges I've found this node setup.

I couldn't explain why it works though.

• what did you change? – J.Doe Oct 20 at 12:20