Using lights for projection effect

I’m trying to create a projector effect in 4.27 using lights rather than use an asset from the store and i’m having some issues.

Using a popular tutorial on YouTube i’ve created the Spot Light version which works but obviously it’s a cone shape instead of a rectangle shape which isn’t what I want.

I’ve also tried lighting it on a plane but that doesn’t actually cast the materials as a light so that also doesn’t work.

3rd attempt is using a Rect Light but the texture doesn’t display correctly and seems to wrap/stretch itself as well as the texture being centered from the top left corner, i’ve tried fiddiling with the settings but I can’t find any way to change how it’s displayed by the light.

I’m still a novice at UE, is there a better way to do this? Any advice appreciated.

1 Like

If the spot light works so far, then it is probably easier to shrink your film material, so that it becomes a rectangle within your round spot light. The outside of your film would be black or covered with a black mask, so that it does not send out any light in those areas.

Thanks for the response, is it possible to do this via a script? The goals is to make it into an asset that a level designer could essentially drop and drag into a scene and have to do minimal config.

Not sure about the “via script” part, but you can do all the calculations within a Material, which you then use as a light function for the spotlights. Spotlights, because lightfunctions only work as black and white mask, so to recreate acolor picture, you need one lightfunction for each color, and also one spotlight for each color.

You should be able to pack those required lights into a Blueprint actor, which then should be very configurable.

Here is a project with the materials/light functions, i just had not packed everything into an actor.

Please do not wonder, why there are 4 instances, and not just 3.
One instance acts as main instance, where you should change your texture for the projector, and adjust the texture size to get the proper aspect ratio for the beamer.

The other 3 instances with R,G,B at the end, those have the main instance as a parent, NOT the master material. With that, those 3 instances get every change, that you do within the main instance (like changing color texture and adjusting texture size), while masking out the colors, that the 3 spotlitghts need to work properly.
There may be a better way, but for a test showcase, its good enough ^.^

Video:

Project (4.26):

Beamer_LightFunction.zip (1.6 MB)

Have fun

4 Likes

Not sure if it’d would work well, have you tried with decals?

That’s exactly the effect I wanted, going to have a play around with it and see if I can add to it. Thanks so much!

Hey Suthriel,

thank you very much for this explanation.

I wanted to ask about the light function mask ? I didn’t understand why did you choose 8x8 as Light-Function-Mask ?

Your method did work for me and i made my light function fit the spot light but i wanted to understand the idea that i can make further changes.

Thanks.

… uuhhh… can´t remember anymore :sweat_smile: But it was probably a size, which worked perfect with the required math for scaling and the different texture ratios (for squared textures as well as for rectangular textures like 16:9 textures), and one that was easily drawable in Windows Paint :upside_down_face:

Could have been a different size, as long as the math works out for the scaling of the white part, which at the end of all the calculations has to fit perfectly into a circle, that has the diameter of the whole mask texture, and can be stretched to different texture ratios (if that makes any sense).
Because the light function can only use a circular part of the mask for the point light, and the biggest circle has the diameter of your mask texture lenght or wide. But to fit the projected texture completely into that circle you have to scale it down, so that your projected texture can fit into that circle while keeping its ratio.

grafik

1 Like

Thank you for the explanation.

which at the end of all the calculations has to fit perfectly into a circle, that has the diameter of the whole mask texture

Is there any relationship between the cone angle of the spot light source and the pixels of the mask/texture ? I couldn’t figure that out… but your statement validate this.

Thanks in advance.

Only that the white part is half the size of the whole mask, if i remember correct, just to make the math a lot easier.

Its about the diameter and/or radius of the circle, that the cone have - no matter, what the cone angle will be, the diameter of the circle, that would be at it´s bottom or end will always determine the texture size, that UE will use to project the texture into the world.
Then you can throw in the theorem of Pythagoras (this c² = a² + b² formula), because the circles radius equals the height of the triangle, that forms one half of a square, that fits into this circle (and the diameter its diagonal). So by calculating the two missing sides of this triangle via Pythagoras theorem, you get your wanted lenght of your white square.

Maybe this picture helps visualizing it, if you rotate the projected texture (here as a square or 1:1 ratio), all the relations become hopefully more clear:

The rest is just scaling the lenght and height from that white square from a 1:1 ratio to f.e. a 16:9 ratio, if you use a texture or video in f.e. HD resolution (1920x1080 is just 16:9).

1 Like

@Suthriel Thank you very much for your help. Much appreciated. Now i can figure out what you’ve meant.

This is really helpful, and useful. I’d built a basic projector setup, but you provided the solution to scale and proportion.
Thank you!

1 Like