Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by cgeorge2 · Mar 01, 2017 at 06:11 AM · lightingdirectional light

How to Hide Directional Light on One Side of an Axis/Object

Okay, so I'm working on a project that I want to have functional spotlights in (not the lighting), and I want these spotlight models to have cylindrical, volumetric lighting. I've got the cylindrical part done (directional light with a circular cookie) and a friend is working on the volumetric stuff.

My issue is that once we put everything together, the directional light, being infinite, will be visible behind the spotlight models as well as in front of them, and this brings me to my question:

Is there any way to make a directional spotlight simply not produce light until it passes a certain physical location? Alternatively, is there a way to make its directional "origin" (I'm aware it has no actual origin) the light object itself, so if the light shines downwards (towards -Y), no light will shine/be produced above (+Y of) the light object's XZ plane?

Screenshot attached to hopefully illustrate this a bit better; as you can see, the light originates from behind the entire spotlight model, but I only want it to originate from the actual light object/front of the spotlight model (or at least be hidden until it crosses the light's XY plane), making it look like the spotlight model is the source of the light. alt text

lightproblem.png (137.8 kB)
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

1 Reply

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

Answer by cgeorge2 · Mar 16, 2017 at 01:32 AM

Took me awhile, but I finally figured out a solution. If you can use Blender or another modeling program to put together a cylinder with a hole through it (think like a pipe), you can import it to Unity and set its mesh renderer to be shadows only, that way it's invisible but will still cast shadows. After that, you have to take a second model (or a derivative of the first) which is a hollowed-out cylinder with one end knocked off (think of a barrel). You put a point or spotlight inside of it, crank up the intensity and range (to counter the attenuation drop off, unless you're fine with that), and put the pipe-cylinder model on the end of the barrel. The barrel acts as a hood, directing the light, and the pipe works to secretly keep the light in a beam shape.

The downside to this is that if you're using more than one beam light, the pipes can block other lights, so you'll have to mess around with tags a whole lot so that each light source ignores ALL pipes except for the one used with the light source.

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 fariazz · Mar 16, 2017 at 01:57 AM 0
Share

That is very clever thanks for sharing the answer!

avatar image cgeorge2 fariazz · Mar 16, 2017 at 02:04 AM 0
Share

No problem, only took me nearly 2 weeks to figure it out... ha ha...

That being said, an orthographic projector mostly worked, except it didn't cast shadows from the "light," and it also projected the light spot onto the backs of objects it was shining through.

A light/barrel assembly as described above still projects light much too widely without the pipe to limit it, unless the barrel is ridiculously long, and that just looks stupid.

Trying to modify light attentuation through Unity's built-in shaders either doesn't work or the solutions online just don't have all the information (I also know nothing about shaders, so that could have something to do with it).

Cookies give the spotlight the proper shape, but still scale with distance/angle, and therefore don't give the beam effect.

I think that's about all I tried wrangling with, in case someone wants to try doing it a different way.

avatar image mr_blahblah · Jan 12, 2020 at 10:18 AM 0
Share

Great work. I have NFI why Unity doesn't support something this simple out of the box though. Frustrating.

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

107 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

ProBuilder - Light leaking through seams on internal scenes 1 Answer

Directional light scene is too dark 1 Answer

What's the difference between Lightning (TAB) and Directional Light (gameobject) 1 Answer

How do I fix the directional light so the 2 sides aren't black? This happens everytime I make a new project 1 Answer

How i can fix the directional light?,My directional light don't work After I build the game 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