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 /
avatar image
0
Question by Jamiex304 · Jul 19, 2018 at 08:13 PM · skyboxfogblendingedgeterrian

Unity - Hide the Edge Of The Level

Hi,

Currently I am building a level in Unity and I have run into a problem the player (Me) can see well past the edge of the level. I am looking for a way to say place a ton of fog in a circle around the edge of my level (Like this attached image where the fog hides the edge)

alt text

But I have no been able to find a guide on how to do this.

Things I have tried so please dont suggest - Lowering the view distance on the camera didn't work just had things popping in and out very ugly - Placing objects in the distance still didnt work because the edge of the skybox is still seen

Does anyone know who to replicate the above image or have any other suggestions ??

Thank you

picture-1-614.png (164.4 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

Answer by Dray · Jul 19, 2018 at 08:23 PM

I think you could solve this writing a simple surface shader, look at this page where they got some examples:

https://docs.unity3d.com/Manual/SL-SurfaceShaderExamples.html

You could try writing a shader that only renders your terrain within a certain distance from the camera, that should give you a nice circular edge and then the mesh just needs to be bigger than the range you define. Just as an example, you can refine this to match your skybox in many ways I think like decreasing the alpha over a certain range to let the terrain fade out (you can really do a lot with surface shaders).


EDIT: I think what you see in the image you uploaded is just a circular mesh though


EDIT2: Here is a very basic example so you can comprehend what I mean:

 Shader "Custom/Horizon" {
     Properties {
         _MainTex ("Albedo (RGB)", 2D) = "white" {}
         _HorizonRange ("Horizon Range", Range(1,1000)) = 100
     }
     SubShader {
         Tags {"Queue"="Transparent" "RenderType"="Transparent" } // <- this is needed if you want transparency on your mesh
         LOD 200
 
         Blend SrcAlpha OneMinusSrcAlpha
 
         CGPROGRAM
         #pragma surface surf Standard fullforwardshadows alpha // <- added "alpha" here for transprency
         #pragma target 3.0
 
         sampler2D _MainTex;
 
         struct Input {
             float2 uv_MainTex;
             float3 worldPos; // Unity will fill this for you
         };
 
         half _HorizonRange;
 
         void surf (Input IN, inout SurfaceOutputStandard o) {
             float cameraDistance = length(IN.worldPos.xyz - _WorldSpaceCameraPos.xyz);
 
             if (cameraDistance < _HorizonRange) {
                 // within the Horizon Range, render everything normal
                 fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
                 o.Albedo = c.rgb;
                 o.Alpha = c.a;
             } else {
                 // Outside of the Horizon Range, don't render the mesh.
                 o.Albedo = float3(0, 0, 0);
                 o.Alpha = 0;
             }
         }
         ENDCG
     }
     FallBack "Diffuse"
 }
 
  • Go to Create->Shader->SurfaceShader (that will give you a skeleton for your surface shader that allready works)

  • Paste the content I posted above

  • Go to Create->Material

  • Select the Shader Custom/Horizon for the Material

  • Apply the Material to your Mesh

Now the problem is, if your terrain uses a custom shader, yours has to fit the terrain shaders functionality. Anyhow I think this can give you a good starting point to develop something like that, look at the code and try to adapt. :) Hope this helps

Comment
Add comment · Show 2 · 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 Jamiex304 · Jul 19, 2018 at 09:18 PM 0
Share

Hi

Thanks for the suggestion, but I have never done shaders and I would have a clue where to begin order to create the effect you described?

Dont suppose you have anything other than the unity docs to go off (something closer to what I need)

avatar image Dray Jamiex304 · Jul 20, 2018 at 10:06 AM 0
Share

I added a snippet, lmk if that helped ;)

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

87 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

Related Questions

How do i make the sky box a solid color or make fog affect it... 1 Answer

See skybox through fog? 0 Answers

Global fog problem 3 Answers

Underwater - Fog and Skybox 1 Answer

Exclude skybox from Bloom Effect 4 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