Lighting and shadows for LineRenderer

Is it possible for a LineRenderer to cast or receive shadows or lighting? In my testing they are always dark with any lit shader (like Diffuse), and never cast shadows (in Pro).

The docs for LineRenderer say that Particles shaders are recommended, which suggests that shadows and lighting are not possible.

If not, how expensive would it be to construct an "equivalent" mesh every frame (eg. pentagonal cross section) compared to a LineRenderer? If it's only 5 times as expensive, that's probably bearable in my use-case.

You can use shadows with line renderers by using a shader that supports shadows. If the shader you want to use doesn't, then you can make a custom shader that properly incorporates shadow code. However, the "always face camera" thing that a line renderer does makes its shadow weird and glitchy. It would be better to construct a mesh yourself that doesn't have that behavior.

Here's a pic of a line renderer casting a shadow...it looks OK here, but gets weird when the camera moves or zooms. It does have lighting, but it's not really useful since the light has to be pointing in unexpected directions to have any effect.

alt text

Line renderers are not expensive to create. It's quite literally 2 triangles per segment. If you can't get the desired effect using the existing LineRenderer component, it may be best to create your own.

The only thing that may be tricky to handle is, the faces of the LineRenderer segments always "face" the camera. I'm not sure if that's going to be a problem for you or not, but I thought I'd mention it.

If you create your own, each segment would act basically like a plane, to which you could apply whatever material you like onto it. I'm pretty sure the planes would cast shadows, as well, though I'm not 100% sure as I only use Unity's free version.

Apply material, (make sure it supports lighting!) to 'em and choose “Two sided” in the “Cast Shadow section” That shouldda work 145814-yay.png