Correcting perspective distortion for an angled 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 projector that 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:
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.