Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by Gohu · Jan 07, 2013 at 01:08 PM · cameralighthideonpostrender

Hide a light for a camera

Hi everyone!

I wanted to know if it is possible to hide a light for a camera?

I tried to use layers: I assign a layer for my light, and in my camera inspector, I cull the mask linked to my light, but I can still see my light through my camera. The idea is to see the world though camera 1 with the light, but through camera 2 without this light.

So I wonder if I misused the layers, or if there is another method.

Thanks in advance!

Comment
Add comment · Show 3
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 robertbu · Jan 11, 2013 at 11:18 AM 0
Share

I did a quick setup, and what you describe works fine for me. $$anonymous$$ake sure the Culling $$anonymous$$ask property is correctly set for the light. $$anonymous$$ake sure the object you want to light are on the correct layers also.

avatar image Gohu robertbu · Jan 11, 2013 at 01:33 PM 0
Share

Hi, There is a problem with this solution: if my object has no longer the light, the second camera won't see it, will it? (Or I haven't understood your solution?)

The solution I have, which is quiet costly and annoying, is to duplicate my whole world and to move both cameras at the same time in the 2 worlds. One world has the light and the other world hasn't the light.

avatar image robertbu robertbu · Jan 11, 2013 at 10:09 PM 0
Share

I did not understand your question, so yes you need duplicate geometry. If you have Unity Pro you might be able to use RenderTexture to solve the issue. You can set a new RenderTexture, turn the light on, render to the texture and disply it, then return the camera to normal view. $$anonymous$$y guess it that it would be too expensive to do evry frame, but I don't know. Apparently folks have managed to save RenderTextures quick enough to capture video:

http://answers.unity3d.com/questions/61581/rendertexture-to-create-a-movie-very-fast.html

2 Replies

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

Answer by Wolfram · Jan 11, 2013 at 10:34 PM

Hm, you should be able to do this with OnPreRender and OnPostRender. Attach a script with these functions to Camera2, and in OnPreRender disable the light, and in OnPostRender re-enable it.

Comment
Add comment · Show 1 · 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 Gohu · Jan 14, 2013 at 08:39 AM 0
Share

Thank you, it's exactly what I wanted!

avatar image
5

Answer by LoungeKatt · Sep 30, 2014 at 06:08 AM

I am not sure if Wolfram's answer was working by itself in previous versions of Unity, but 4.6 seems to require a slightly different setup. For anyone that stumbles across this like I did, this is what was needed in the script attached to the camera that does NOT see the light. It did not work until OnPreCull was added, but OnPreRender has been left as a precaution.

 function OnPreCull () {
     if (limelight != null)
         limelight.enabled = false;
 }
 
 function OnPreRender() {
     if (limelight != null)
         limelight.enabled = false;
 }

 function OnPostRender() {
     if (limelight != null)
         limelight.enabled = true;
 }


Comment
Add comment · Show 4 · 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 CommunistKitten · Oct 28, 2015 at 01:51 PM 0
Share

That works perfectly, thank you

avatar image KarlKarl2000 · Dec 16, 2017 at 05:06 AM 0
Share

Works! 2017.1

avatar image Jezzer21 · Jul 23, 2018 at 09:39 PM 0
Share

Hi. Can you tell me what is limelight? i searched it but i can't find that word in unity. i tried copying your code to my C# script and just changed the "function" to "void".. limelight is colored red and says the word doesn't exist in the current context. I am making a $$anonymous$$imap with my horror game and it has flashlight in it but yeah my $$anonymous$$imap cam still can see the light x_x

avatar image LoungeKatt Jezzer21 · Aug 01, 2018 at 03:27 PM 0
Share

@Jezzer21 It is your flashlight. If you trying to resolve your flashlight being visible on the map, it should have been relatively obvious that it would have to be referenced in there somewhere.

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

14 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

Related Questions

How can i turn on/off the camera light of my phone? 1 Answer

Best way to access RenderTexture immediately after camera render 0 Answers

How do I reset camera and light to default positions?,How do I reset camera and light to default? 0 Answers

Doesn't rendering plane 0 Answers

Light glitch when not in camera's view 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