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 07, 2016 at 02:07 PM · transparencyalpha5.3#pragmasurfaceshader

Alpha surface shader no longer working in updated 5.3.2

Hello again. I've been searching for the last few days, but there don't seem to be questions about the latest version (5.3.2 at time of writing) so....

I had the makings of an alpha surface shader underway in the previous version. It had some problems (as noted in a previous question of mine), but it was close to working. I updated to 5.3.2 a few days ago and if I include 'alpha' in the #pragma line of the shader it now does not render at all. The planets in my space game are made of two spheres: One is the surface, the other (slightly larger radius) depicts the horizon 'glow'. Ideally I'm trying to get this rendering 'behind' the front-facing surface of the planet. Here's the sphere 'glow' shader code:

 Shader "Custom/planet glow" {
     Properties {
         _glowTint ("Glow Tint", Color) = (0.5,0.8,1,1)
         _atmosphereMix ("Atmosphere Mix", float) = 0
         _sunDirection ("Sun Direction", Vector) = (0, 0, 0, 0)
     }
     SubShader {
         Tags { "RenderType" = "Opaque" "Queue" = "Transparent" }
         Cull Front // I want only the far faces to render (behind the actual planet surface). This is why I've inverted the normals later
         //Offset 10000, 10000
         //ZWrite On
         //ZTest LEqual 
         
         CGPROGRAM
         #pragma surface surf Lambert alpha
         #pragma target 4.0
 
         struct Input {
             float3 viewDir;
         };
 
         fixed4 _glowTint;
         float _atmosphereMix;
         float4 _sunDirection;    
 
         void surf (Input IN, inout SurfaceOutput o) {
             _sunDirection = normalize(_sunDirection);
             o.Albedo = _glowTint;
             float cameraNormalDP = saturate(dot( normalize(IN.viewDir), -o.Normal ) * 4.5);
             float sunNormalDP = saturate(dot( normalize(-_sunDirection), -o.Normal ) * 2);
             o.Alpha = _atmosphereMix * sunNormalDP * (cameraNormalDP * cameraNormalDP * cameraNormalDP); // makes the edge fade 'faster'            
             o.Emission = _glowTint;
         }
 
         ENDCG
     } 
     FallBack "Diffuse"
 }

I have tried this shader with all of the Tags, ZTest and ZWrite settings I've been able to find, as well as keepalpha and alpha:fade in the #pragma line. I've also tried Offset.

Has there been some change in 5.3.2 that I'm not aware of to make alpha work in Unity. I have been trying to get this to work flawlessly for the last couple weeks and it's starting to seem insurmountable. Does anyone have the specific knowledge to make this happen or do I need to use the paid version to get the info?

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 moosefetcher · Feb 07, 2016 at 06:12 PM

OK, I think I figured out the problem. For some reason the 'glow' sphere wasn't rendering in my 'distance camera'. I've moved the far clipping plane of my NEAR camera out to 20000 units and the horizon glow is now rendering - still with the 2 problems I mentioned in a previous question:

1) The glow sphere vanishes at a few thousand units' distance and...

2) There's still z-fighting between the surface sphere and the glow sphere. This I don't understand at all, because the near faces of the glow sphere are culled.

If anyone has some pointers, that would be swell...

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

33 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

Related Questions

Strumpy Shader Editor: Transparency Issues 0 Answers

Alpha not working in GUITex 0 Answers

Transparent / Vertex Lit Ignore Sides 1 Answer

Make a complex object semi transparent without changing it 2 Answers

What happens when the alpha value is outside the 0..1 range in surface shader lighting models? 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