1. Use the Polygon Frame Tool or the Pen Tool to create a selection around the window or opening through which the sun ray will supposedly pass.
2. Create a new layer and fill the selection with the color you want for your ambient light effect. I have used the color # fff6dc but you can use the one you like the most.
3. Use the Free Transform Tool by pressing Ctrl + T and then with the right click select Distort or go to the Edit menu> Transform> Distort and distort the form as shown below. You can also use Perspective to widen the end of the shape to create the effect that light expands.
4. Softens the light beam using blurring filters. For this type of effect I like to use the rectangle blur because it is not so linear and keeps the edges a little more focused. (Gaussian blur)
5.
Create a layer mask for your light beam using a linear gradient to attenuate the end of the out-of-focus shape. Reduce the opacity of the layer to the point where it seems realistic. I left it the same but you can lower the opacity to your liking.