# How to create a light cone or shaft of light?

I’ve been experimenting with this and haven’t figured out how to do this yet. Any suggestions? What I’m trying to re-create is the “shaft” of light you can see when looking perpendicular to a flashlight. I tried using “self illuminated” cylinders and cones, but I’m not getting the effect I’m looking for.

Here’s an example of what I’m talking about: http://www.smugmug.com/gallery/167709/7/6279882

1 Like

Yes, thanks for that. “Volumetric light” is exactly what I’m looking for.

1 Like

Something like this maybe? You can walk around and it holds up from pretty much any angle, except from inside the beams. That’s done with 4 spotlights for the lighting on the floor, though it actually doesn’t look that much worse without them.

–Eric

3 Likes

Eric, thank you for sharing the example It is excellent, even I can understand it. Everything else has been stripped out so it is easy to focus on the important parts.

I hope non-Unity users pick up on the impressive fact that you can ask a question here, and quickly get not just an answer but a working example!

Leaving aside how helpful the community is… How often is that rapid turnaround for custom issues even possible in other engines I wonder?

1 Like

It also helps that I was thinking about this issue myself just recently. The main drawback with that example is that the light beams have to be pointing straight down, since they always rotate to face the camera. I’m not really sure how you’d do it if you wanted them at an angle.

–Eric

You could still get a normal that pointed at the camera, I would think. You’d just have to accept that the beam went through the floor, but you wouldn’t actually see any effect from that anyway.

The other common solutions is just to do a model of cone-like shape, with many layers (i.e. decreasing radius cones inside). Then map a bit of noise-like texture on it, maybe even scroll it at runtime, all with transparency. I did whatever thing is here this way once.

[quote=“”]
Something like this maybe?
[/quote]Looks perfect Eric, thanks very much!

It’s still not the effect I’m looking for, but at least it’s a start. I used the cone from Eric’s package, rescaled it and changed the texture so it fades in the distance. I also used two cones similar to Aras suggestion. I’m not sure why it’s brighter at the edges than in the center. It must be due to the vertex lighting, but I haven’t figured that out yet. I’d also like to make the effect relatively invisible when viewed from the vehicle (first image).

My technique definitely won’t work for that sort of thing. I was trying to avoid the nesting objects to get a perfectly soft edge with a texture instead, but that only works if you can rotate the object about the Y axis to always face the player. (Not to mention, it only works with a cone and not any other shape.)

So I’d say you want something more like this instead…nesting objects seems to be the only way (you need a bunch for something like a soft edge), but it would probably look better with some noise in the texture as Aras said. Also you’d want to use an actual spot light in addition to the objects, with a cookie for non-round shapes.

As for making it less visible from inside the vehicle, just decrease the opacity of the material in that case.

–Eric

Thanks Eric, I’ll give that a try.

I also thought I’d try playing with the “Halo” effect also. I wonder if I could stack several Halo’s of increasing size and decreasing intensity as it moves away from the source of light and in the path of the light. I’m afraid that where the Halos overlap the intensity will be higher, but I’ll test it to find out for sure.

The other thought I had was whether the Halo effect could be edited (easily hopefully) so it is in the shape of a cone instead of a sphere. Anyone know if this is possible?

Thanks again!

I think the halos are technically flat discs, not 3D spheres–which is OK for circular effects, but wouldn’t be the same for cones.

Thanks Morgan. I ended up using something similar to Eric’s last illustration, except I set the opacity to 1% and added 5 scaled cones. The effect is “acceptable”, but not nearly as nice as I’ve seen in other engines.

Next task is to get “lens flare” working. I think I’ve set everything correctly, but I’m just not seeing any flares. Off to search the forum posts…

Halos are basically textured disks (you can set which texture to use in the RenderSettings), - they are, however, stretched towards the camera at the center to give a better impression of a volume.

they are not good for spotlight cones, though…

Thanks for that clarification Nicholas.

Thanks, Eric and Aras, for your excellent ideas, downloads and illustrations. Like Morgan said, I’m also impressed with the great people in this community and at OTEE. Every day I learn much more than I ever expected.

There’s a bit of a “gotcha” with flares…they are blocked by any colliders at all, whether there’s transparency or not, or even a mesh renderer or not. Anything you want flares to show through, put on the TransparentFX layer.

As for the volumetric lighting, if you use a nicer texture than mine, it will look nicer.

–Eric

Would it be possible to add some noise to the gradient texture for a more realistic effect?