Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by Waz · May 05, 2010 at 12:20 AM · lightingshadersshadowslinerenderer

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
5
Best Answer

Answer by Eric5h5 · May 05, 2010 at 01:40 AM

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

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Waz · May 05, 2010 at 06:33 AM 0
Share

Other objects to which I apply Diffuse have shadows, but not LineRenderer. Indeed, the LineRenderer appears not to even get light from lights (it looks just ambient lit).

avatar image Waz · May 05, 2010 at 06:36 AM 0
Share

Come to think of it, the always-face-the-camera would also make the lighting terrible. Okay, I think that pretty well covers it!

avatar image Eric5h5 · May 05, 2010 at 08:03 AM 0
Share

@Warwick Allison: I edited my answer to add a pic. Line renderers definitely cast shadows and have lighting if you use a diffuse shader, but it's kind of bizarre shadows and lighting so it's not very useful. Rather a moot point but anyway. ;)

avatar image
0

Answer by qJake · May 05, 2010 at 12:32 AM

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Twinklier · Sep 06, 2019 at 03:41 PM

Apply material, (make sure it supports lighting!) to 'em and choose "Two sided" in the "Cast Shadow section" That shouldda work alt text


yay.png (10.5 kB)
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

How to add shadows to surface shader? 1 Answer

2D Shadow Help 0 Answers

Doom Classic Effect - Realtime Pixelated Shadows 1 Answer

Any way to get rid of squares (artifacts) in a semi transparent shadow of a fade shader? 0 Answers

Shadow sprite rotation regardless of the light source 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges