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 moosefetcher · Feb 25, 2016 at 07:34 PM · camerarenderingalphaskyboxsurface shader

Distant object won't render in 'distance camera'

I'm making a space exploration game which deals with huge distances, so to avoid that annoying render-flickering caused by not having enough world-space z-distance 'resolution', I've split my render between 2 cameras; one for objects 0.1 to 1000 units, the other for objects greater than 1000 units distant. This mostly works fine...

....Apart from the 'sun' in my game. I've written a custom surface shader for my sun object, which has white fade to 0 alpha at the edge of the sphere to simulate a glow. The problem is, when alpha is included in the shader, the sun fails to render in the 'distance camera'. As a test, I tried extending the 'close' camera's far plane to match the distance camera and the sun - with fading edges, as intended - rendered fine.

What is it about my near camera that lets it 'see' the sun, but my distance camera doesn't? I have not set up any layers in the game, so that isn't the problem. The only difference I can see is that the near camera's 'clear flags' parameter is set to 'Depth only' and the distance camera's is set to 'Skybox'. When I set the distance camera to 'Depth only' the sun renders alright, but nothing gets cleared each frame so the screen rapidly looks like the end of 2001: A Space Odyssey (very psychedelic).

So, is there some way of setting the distance camera so it displays the Skybox and renders the sun correctly?

Here's the shader for my sun. I have tried all manner of Tags and ZWrite, ZTest settings. If anyone has any ideas, I'd appreciate it.

 Shader "Unlit/sun shader"
 {
     Properties {
       _Color ("Color", Color) = (1,1,1,1)
     }
     SubShader {
 
       CGPROGRAM
       #pragma surface surf Lambert alpha
       struct Input {
         float3 viewDir;
       };
       float4 _Color;
       void surf (Input IN, inout SurfaceOutput o) {
           half rim = saturate(dot (normalize(IN.viewDir), o.Normal));
           rim = (rim * rim) * 2;
         o.Albedo = _Color.rgb;
         o.Alpha = rim;
         o.Emission = 1;
       }
       ENDCG
     } 
     Fallback "Diffuse"
   }
Comment
Add comment · Show 2
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 moosefetcher · Feb 25, 2016 at 07:41 PM 0
Share

On a side note, how the heck to you get the ' character to display correctly in question titles?

avatar image Glurth · Feb 26, 2016 at 04:06 AM 0
Share

I'd like to have a real answer to this also, but here is a workaround: Create yet another camera, as a child of your distant camera. Set your distant camera to "don't clear' and your new camera to "skybox". That allowed it to display and move normally, for me..

0 Replies

· Add your reply
  • Sort: 

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

48 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

Related Questions

Game screen and Camera Preview look fine, but only renders skybox 0 Answers

Cant seem to render alpha surface shader BEHIND geometry 1 Answer

Luminance to Alpha 0 Answers

Setting the camera projection matrix does nothing 0 Answers

need to hide areas of large particle system 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