I'm trying to use spotlight to project image on a plane, and hope to get blurred images with different defocus level in different position, just like a realistic projector. But actully the projected image is always clear no matter how I change the position of the plane. My node tree of the spotlight is shown below. Is there any way to solve it?
1 Answer
If you wish to use the light falloff node to control intensity, then you need to use the quadratic output, not the linear output. You also need to move the light much farther away from the projection screen to give the falloff a chance to work. If you do this, you do not need to manipulate the XYZ coordinates and you end up with a node tree along these lines:
However, I prefer to have more control over the falloff, so instead of the light falloff node, I use a spherical gradient node and a math node.
Here is my entire node tree for such a projector.
The top part of the tree, in the frame labeled Only project forward is cosmetic and not related to the falloff. It merely makes sure that the plane I'm using as a projector only projects in one direction.
The second part, labeled Image to Project is, of course, how you attach the image to the Emission node. In this case, since I imported the image using the Images as Planes add-on, I don't really need the Texture Coordinate or top mapping nodes.
The third part is the "fun" part.
- The bottom mapping node is needed to center the gradient. Without it, the sphere will be centered in the lower left corner of the lamp plane. By mapping with a (-.5, -.5) offset, I've moved the center of the sphere to the center of the image. So the gradient looks like this:
- The gradient node does the math to give the falloff. As you can see, the corners are darker than the edges.
- The math node controls how intense the light is. Multiplying by a number smaller than 1 gives a greater falloff. The smaller the number, the more pronounced the effect.
That's a multiply node, but I sometimes use a multiply/add node. The multiply controls the effect while the add sets the basic intensity of the light.
Here's an example setup. The smaller plane is the "spotlight". The larger plane is the projection screen.
Even so, the effect is very subtle unless you move the spotlight farther from the screen.
-
$\begingroup$ Thanks for your answer. It's very close to the effect I want. Can I focus on a object or adjust focus distance through this way? $\endgroup$– sthwrongJul 21, 2021 at 3:20
-
$\begingroup$ Other than changing the math node to a color ramp and hand tuning the color ramp to get the falloff pattern you want, I don't know of a way. It could probably be done with geometry nodes in 2.93, but I don't know enough to say how. $\endgroup$ Jul 21, 2021 at 14:52