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 Zaffer · Jan 24, 2012 at 07:30 PM · terrainfog

possible to make a fog zone?

Hi,

I have a "near" terrain which is 300x300 regular terrain object and a "far" terrain which is about 10 times bigger. I would like to have fog affect mainly my near terrain with very little getting to the far terrain. Is there a way to do this? I have already tried linear fog but I can't seem to get it to have enough fog in the nearby trees without too much fog in the distance. Thanks.

Zaffer

Comment
Add comment · Show 1
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 Zaffer · Jan 24, 2012 at 09:43 PM 0
Share

Hi, I found some info on how to make a fogless version of a built-in shader which sounds like it might be the answer to my problem: http://answers.unity3d.com/questions/11422/creating-a-fogless-version-of-a-built-in-shader.html

But I have never worked with shaders before and got stuck. I got as far as making and na$$anonymous$$g my custom shader and I copied in the code from the built-in Unity Diffuse shader. I also found 2 lines of code that reference fog, Pass {Fog {$$anonymous$$ode Off}} under SubShader and Pass(ZWrite Off Blend One One Fog {Color (0,0,0,0)} But I am not sure what to do with these lines to disable the fog. Also, I am not sure I am working in the right area. I get 2 different sets of code, shader and compliled shader. Can someone help me with this? Thanks.

1 Reply

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

Answer by Zaffer · Jan 25, 2012 at 03:40 PM

Hi,

I have at least a working answer to my question. With help from Farfarer in the Shader Lab forum and Ehren here in Unity Answers, I was able to make a custom shader for the "far" terrain that disabled fog, and this gave me the effect I wanted.

Here's how I made the fogless shader: First I followed the directions from Ehren in his post using the built-in shader Normal-Diffuse.shader. But being new to shaders, I got confused as to where to make the code changes -- not in the compiled shader that opens from the shader itself. Make the change in the code you get when you press the Edit button next to the shader name in the material inspector. Here's the code I got from Normal-Diffuse:

Shader "Diffuse" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _MainTex ("Base (RGB)", 2D) = "white" {} } SubShader { Tags { "RenderType"="Opaque" } LOD 200

CGPROGRAM #pragma surface surf Lambert

sampler2D _MainTex; fixed4 _Color;

struct Input { float2 uv_MainTex; };

void surf (Input IN, inout SurfaceOutput o) { fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color; o.Albedo = c.rgb; o.Alpha = c.a; } ENDCG }

Fallback "VertexLit" }

And here is the change that makes it into a fogless shader:

Put the line Fog {Mode Off} after the "SubShader {" line.
Above/below/between the "Tags" and "LOD" lines.
And also change the first line of code to "Custom/Diffuse_noFog"
or to whatever you named your custom shader.

Zaffer

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Terrain is blue but fog is off 0 Answers

I need ALOT of help with my snow scene. 1 Answer

Create Fog in Unity 2020 1 Answer

Color changes at distance in procedural terrain 0 Answers

No fog on far away terrain? 1 Answer


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