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
0
Question by FPSworrior · Oct 28, 2013 at 10:48 PM · camerarenderinglayers

Camera rendering help.

I'm not sure if this is possible without pro for maybe some kind of camera effect, but I want it where I can see through the camera at a far distance but I can only see certain layers at closer distances for better fps. For example if I wanted to make it where a certain layer could be seen so far and then a different layer be seen at a different distance So I choose the layer and higher or lower the float value for the distance rendering. I know it has to be done through a script, but I only know some basic stuff. Can somebody please help me? And if you guys can provide me with a script on how to do this than can you guys put like five different layer variables, that way I can choose how many different things I can see. Please help me I really need this.

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 Cains · Nov 05, 2013 at 04:41 PM

You'll want to use the cullingMask variable of the camera and adjust it to include certain layers depending on their distance from the camera, which you can calculate through the distance formula where you can compare the position of the camera and some position variable that represents where the layer is. I'd run this calculation for all layers in a Coroutine that runs every few seconds or so since doing it every frame is kind of overkill.

If point to point distance doesn't work for you, you might want to look up distance between a point and a plane which would probably work better for this case.

If you need me to write up an example I can but I recommend you try it out yourself first.

Comment
Add comment · Show 8 · 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 FPSworrior · Nov 05, 2013 at 05:54 PM 0
Share

could you provide a example script for what to do. I'm only know a little bit of scripting nothing this advanced. The way I wanted it though is where in the script there would be layers I could choose and then below the layer I chose there would be a float value that I could change. And when I change that the gameobjects in that layer would fade. I hope you know what I'm trying to say. But if you could provide a example that would be great.

avatar image Cains · Nov 05, 2013 at 11:30 PM 0
Share

It actually sounds like you're trying to create fog, which Unity can do for you. If you read that link it'll also tell you that though a GameObject may be hidden through fog it will still be rendered.

To stop the rendering for better performance you can edit your camera'a clipping plane in its inspector which controls the distance from the camera where GameObjects are no longer rendered. This distance should be set according to the distance when you can no longer see an object due to fog.

avatar image FPSworrior · Nov 06, 2013 at 07:56 PM 0
Share

no it's not fog that I want. It's like in most games where some objects such as the terrain can be seen at a very far distance but with no fog. But yet other objects such as buildings or light poles etc... can only be seen at shorter distances. Do you know what I'm trying to say now?

avatar image Cains · Nov 08, 2013 at 08:14 AM 0
Share

If you could find a game with this effect, it'd be clearer, but to do what I think you want you can set the shaders for your objects to Transparent/Diffuse. Then you could measure the distance from your camera/player to every GameObject and adjust its alpha accordingly.

This will make objects more see through the further they are from you, until they're so far they're invisible, except for things you don't want to do this such as terrain. If this is what you want I can script something for you pretty easily.

avatar image FPSworrior · Nov 08, 2013 at 05:42 PM 0
Share

Yes please do that. That would be helpfull, and thank you.

Show more comments

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

16 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

Related Questions

Network restrictive rendering 1 Answer

Stop rendering scene when GUI window is active. 2 Answers

Dynamically render/hide object individually for each camera in scene 0 Answers

How to vertically stretch camera view 2 Answers

How do I have multiple cameras that have a black and white view in one while the other shows a color at a certain time on a certain object? 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