I have a friend/client who wishes to paint a single graphic mural on their garage/shed rooftop, but they want it to appear in “proper” perspective when viewed standing on neighbor’s lawn.

First, what information would I need from client to even begin to work on this (best guesses = rooftop width, height/rise & run, and slope angles; maybe distance between shed and viewing neighbor, etc.) and second, then how do I use all this info to warp the artwork appropriately?

My expectation would be that the graphic should appear a bit unnaturally top-heavy when viewed flat, but it would look right with it angled away from you, is that correct?

I have Adobe Photoshop/Illustrator CC at my disposal & I’ve dabbled with warping in both but I don’t know how accurate my results are.

Truthfully I wouldn’t even attempt if this wasn’t for a friend since it isn’t exactly in my wheelhouse, but figured I’d give it my best attempt … help? (Happy to learn more on my own too if you have recommended resources rather than personal knowledge/tips & tricks.)

**Answer**

If I understood the problem right, the neighbour watches the decorated roof of the garage from his garden. The roof has quite heavily distorted painting (here only a square, a circle + some random characters)

The painting on the roof is distorted so that the apparent image doesn’t seem distorted. He should see it like this:

All shapes and the letters of the text should look perfectly straight and have right proportions. The distortion of the painting compensates the effects of the tilted viewing angle and distance differences. Straight on the face the painting would be this:

Everything is stretched and the top side is stretched more than the bottom. This compensates the longer distance to the roof ridge.

In the beginning you should notice that a normal flat 2D painting can be constructed exactly right for only one place of the observer’s eye. Some complex 3D structures could create the right illusion for larger watching area. This subject will be skipped in this answer, we stick with 2D images.

The case needs a kind of inverse perspective transformation:

Let observer’s eye be in point S. The apparent image should be on the red plane. Every point (P) in the apparent image should be presented with a real painted point (Q) on the roof. I guess the artist has already an idea what should be on the red plane. Maybe there’s a ready drawing, it only must be stretched and scaled properly onto the roof.

The red plane is here incidentally vertical. For best results it naturally must be perpendicular with the sight line when the observer watches towards the midpoint of the roof.

The math for this has been found in the first half of the 17th century by philosopher Descartes. He didn’t use it in practical constructions. He presented it as a tool for objective description of the world. He somehow succeeded to avoid Vatican’s Police Dept. and we got the analytical geometry.

Descartes found that every plane can be presented as the set of points (x,y,z) which satisfy plane’s equation which has form Jx+Ky+Lz+M=0 where J…M are numbers. If we set the origin x=y=z=0 of our xyz coordinates to S, the xyz coordinates of point Q can be calculated by multiplying P’s coordinates with the same number. This comes from the fact that S, P and Q are on the same line.

Let P have coordinates x=P1, y=P2, and z=P3. We can solve the needed multiplier v by substituting the multiplied coordinates to the equation of the roof plane. The equation is now JvP1+KvP2+LvP3+M=0. From it v=-M/(JP1+KP2+LP3). After calculating v with this we have the coordinates of Q.

That was simple. In practice we must do much more. In the beginning we need the xyz coordinates of three points of both planes to determine the equations for the planes. Images have in practice their own internal coordinates. In graphic programs P would have coordinates A,B and Q would have coordinates C,D. We need rotation and translation formulas to convert image coordinates A and B to xyz coordinates and xyz coordinates on the roof to image coordinates C and D. The coordinate transformations need matrix calculations, which is possible for ex. with Excel. The image on the roof could be painted if the artist had enough well selected and calculated point pairs (A,B) <-> (C,D).

I guess this starts to sound off-topic or at least extremely tiresome, so we do not continue it. Anyone who has studied seriously engineering math few months should be able to work the details after reading the preceding story. We construct an approximation in a practical way with nearly zero math.

Start the practical work by measuring the sides W and H of the roof plate:

As a numerical example we let W=486 cm and H=400 cm.

To capture the effect of the placement of the observation point S take a photo. Put the camera to the real observation point and shoot towards the midpoint of the roof. You get something like this:

It’s a screenshot of a rendered perspective front view of my 3D model, because I haven’t a garage. If I had one, it would be possible that I wouldn’t paint its roof to test my theory.

You must have a good lens or you must be able to compensate the lens distortion with software. The straight lines should be straight also in the photo. Any visible curvature spoils the result. Have as long focal length as possible to get as big image in pixels as possible. Cropping the wall doesn’t harm, the roof is important. It’s ideal to have the observation point in the middle of the garage width, but that’s not obligatory. Keep the camera straight to get a horizontal image.

Goto Photoshop. Crop your image so that the roof fills it as completely as possible:

The roof happens in my case fit to 1077 x 325 pixels. The artwork in the wanted apparent perspective should fit inside the roof. 1077 x 325 probably is too low resolution for outdoor paintings, so it can be useful to scale the photo size upwards proportionally, for ex. to 500%. For our example 1077 x 325 is fine.

Let’s place the artwork into a new layer. Here it fills the roof area of the photo:

The canvas must be stretched to have the proportions of the real roof. The photo width tells that there should be 1077 pixels per 486 cm. The new canvas height should be (1077/486)400 pixels = 886 pixels.

The original photo layer is now closed because the arwork fills the roof area.

The next step is not mathematically exact. We do not know how Photoshop’s transforms do their jobs in details. All documentation is only qualitative. But we stretch the artwork with Edit > Transform > Distort to fill the full image area exactly. Make a selection by Ctrl+Clicking the Artwork layer icon in the layers panel before applying Edit > Transform > Distort. Be sure nothing is cropped when you drag the top edge and corners!

The result should be the wanted painting as scaled to the image size.

As I said, I haven’t a garage to test this, but we can place the result onto the 3D model:

After rendering the model as seen with perspective from the original observation point, the result is this:

It’s not 100% perfect, but maybe it’s good enough.

Done.

**Attribution***Source : Link , Question Author : streetable , Answer Author : user287001*