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
0
Question by cjacobwade · Jul 02, 2014 at 05:26 AM · shadertransparencyblending

Transparent Fresnel Shader Sometimes Obscuring Objects

I'm working to make a transparent shader with a glowing rim around the outside. The goal is to be able to see everything behind my transparent object. As can be seen in my attachments, objects behind my capsule are sometimes obscured in odd ways.

alt text alt text

I started with the rim lighting shader from here: http://docs.unity3d.com/Manual/SL-SurfaceShaderExamples.html

Here's where I'm at now:

 Shader "Custom/TransparentFresnel" 
 {
     Properties 
     {
       _InnerColor ("Inner Color", Color) = (1.0, 1.0, 1.0, 1.0)
       _RimColor ("Rim Color", Color) = (0.26,0.19,0.16,0.0)
       _RimPower ("Rim Power", Range(0.5,8.0)) = 3.0
     }
     SubShader 
     {
       Tags { "Queue" = "Transparent" }
       
       Cull Back
       Blend One One
       
       CGPROGRAM
       #pragma surface surf Lambert
       
       struct Input 
       {
           float3 viewDir;
       };
       
       float4 _InnerColor;
       float4 _RimColor;
       float _RimPower;
       
       void surf (Input IN, inout SurfaceOutput o) 
       {
           o.Albedo = _InnerColor.rgb;
           half rim = 1.0 - saturate(dot (normalize(IN.viewDir), o.Normal));
           o.Emission = _RimColor.rgb * pow (rim, _RimPower);
       }
       ENDCG
     } 
     Fallback "Diffuse"
   }

I've tried fiddling with different culling, using Blend SrcAlpha OneMinusSrcAlpha, using ZTest with just about every setting but none of that has worked so far. I'm no expert at shaders, but I've read through most of Unity's documentation and used Strumpy Shader Editor a lot so I'm familiar with the language and concepts. Any pointers would be greatly appreciated.

fresnelcullingproblem.png (99.0 kB)
fresnelcullingproblem2.png (97.7 kB)
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 njg · Oct 08, 2016 at 07:32 AM 0
Share

I tried using this shader but there's no glow. Are you achieving that through some fullscreen effect? @cjacobwade

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by tanoshimi · Jul 02, 2014 at 05:44 AM

Assuming you want objects further away to be drawn behind objects in the foreground, try adding:

 ZWrite Off
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 cjacobwade · Jul 02, 2014 at 05:52 AM 0
Share

This improves my situation a bit, thanks! Now I'm having a problem where the object is obscured by the floor plane.

alt text

fresnelcullingproblem3.png (116.1 kB)

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

Transparency and blending issues with custom-made shader 1 Answer

Change blend mode from outside shader? 3 Answers

Silhouette overlay shader 0 Answers

GameObject not receiving shadows 0 Answers

Transparent shader for Android 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