Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 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
0
Question by D4rt · Jul 07, 2013 at 02:29 PM · shaderterrainfog

Adding a static fog in the bottom of a terrain

Hi ho, another question.

I'm trying to achieve the effect of a static fog in the bottom of my rocky terrain. It's used mainly for atmosphere and obscuring some ugly details no one needs to know about. ;)

Here is the effect I want, done with Unity's internal fog settings:

![alt text](/storage/temp/12882-fog+example.png)

And here is the problem that can't be fixed with the internal fog.

![alt text](/storage/temp/12883-fog+example2.png)

The fog retracts as it should. Unfortunately it's not the effect I want.

I reckon custom shader is the way to do it but unfortunately I don't have a good grasp on them. Any help (on alternative solutions also) would be much appreciated.

fog example.png (342.8 kB)
fog example2.png (173.2 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
0
Best Answer

Answer by D4rt · Jul 07, 2013 at 03:34 PM

I did a little hack that doesn't work flawlessly and haunts me in my dreams, but hey, as long as others think it works, eh? I added this to my main camera's script.

     private float startY = 0;
     private float fogStart = 0;
     private float fogEnd = 0;
 
     void Awake()
     {
         startY = transform.position.y;
         fogStart = RenderSettings.fogStartDistance;
         fogEnd = RenderSettings.fogEndDistance;
     }
 
     void Update()
     {
         RenderSettings.fogStartDistance = fogStart + transform.position.y - startY;
         RenderSettings.fogEndDistance = fogEnd + transform.position.y - startY;
     }

I'm still thinking about other possibilities and any further ideas would be much welcome.

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 D4rt · Jul 07, 2013 at 11:41 PM 0
Share

With properly constraining the x and y movement I've managed to make this look quite nice and robust. I guess I'll have to go with this until I have access to Unity Pro and the Global Fog.

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

Color changes at distance in procedural terrain 0 Answers

Adding BRDF lighting to custom Terrain Shader. 0 Answers

Billboard trees glow white in dark scene. 2 Answers

Build in standard terrain shader not working properly 1 Answer

How to enable Fog in vertex bending shader? 2 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