• 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 /
  • Help Room /
avatar image
Question by pervyTHEshadow · Feb 03, 2018 at 07:13 PM · unity 5shadermaterialmaterialscg

Problem with fresnel materials

Working on a material and I've almost finished it but I'm having issues with one last bit. I'm trying to give part of it an inverted fresnel effect, where the outer side is invisible with the middle being filled in, according to camera view. But instead of being gone it has a purple-pinkish color to it alt text But If I hide the camera it looks correct in the scene view. alt text I don't know where to go from here. This is the material I've made.

 Shader "Custom/RimMiscellaneous"
 {
     Properties {
         [Enum(Off,0,Front,1,Back,2)] _CullMode ("Culling Mode", int) = 2
         _MainTex ("Base (RGB)", 2D) = "white" {}
         _BumpMap ("Normal Map", 2D) = "bump" {}
         _ColorTex ("Color (RGB)", 2D) = "white" {}
         _EmissionMap ("Emission Map", 2D) = "white" {}  
         _Opacity ("Opacity", Range(0, 1)) = 1
         _Emission ("Emission", Range(0, 5)) = 1
         _RimPower ("Rim Power", Range(0, 20)) = 0.5
         _RimSwitch ("Rim Switch", Range(0, 1)) = 1
         _AnimationDirPower ("Dir Anim value", Vector) = (0.1,0.1,0.0,0.0)
         _RimOuter ("Rim Outer", Range(0, 20)) = 0.5
 
     }
     SubShader {
         Tags { "RenderType"="Transparent" "Queue"="Transparent" }
 
  Cull[_CullMode] 
 
         CGPROGRAM
         #pragma surface surf Lambert alpha
  
         sampler2D _MainTex;
         sampler2D _BumpMap;
         sampler2D _ColorTex; 
         sampler2D _EmissionMap;
         uniform half _Opacity;
         fixed _Emission;
         fixed _RimPower;
         fixed _RimOuter;
         uniform half _RimSwitch;
         fixed2 _AnimationDirPower;
  
         struct Input {
             float2 uv_MainTex;
             float2 uv_BumpMap;
             float2 uv_EmissionMap;
             float3 viewDir;
             float3 worldNormal;
             INTERNAL_DATA
 
         };
  
         void surf (Input IN, inout SurfaceOutput o) {
             half4 c1 = tex2D (_MainTex, IN.uv_MainTex + _Time.y * _AnimationDirPower.rg);
             half4 c2 = tex2D (_ColorTex, IN.uv_MainTex + _Time.y * _AnimationDirPower.rg);
             half4 c3 = tex2D (_BumpMap, IN.uv_BumpMap + _Time.y * _AnimationDirPower.rg);
             half4 c4 = tex2D (_EmissionMap, IN.uv_EmissionMap + _Time.y * _AnimationDirPower.rg);
             o.Albedo = c1.rgb * c2.rgb * c3.rgb;
 
             float3 normal = normalize(IN.worldNormal);
             float3 dir = normalize(IN.viewDir);
             float val = 1 - (abs(dot(dir, normal)));
             float rim = val * val * _RimPower;
             float power = 1 - rim * _RimOuter;
             o.Alpha = c1.a * _Opacity * power * lerp(1.0, rim, _RimSwitch);
             o.Emission = c4.rgb * _Emission * o.Albedo;
 
         }
         ENDCG
     }
     FallBack "Diffuse"
 }


example-2.png (333.2 kB)
example-1.png (442.4 kB)
Comment

People who like this

0 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 pervyTHEshadow · Feb 03, 2018 at 07:14 PM 0
Share

Another Example of the problem. The purple shouldn't be showing. alt text

example-3.png (328.9 kB)

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

244 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 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 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

Standard Shader Emissive Warning? 2 Answers

stop materal instancing 1 Answer

Outline Shader working in editor but not in-game 0 Answers

Storing data from previous shader pass 0 Answers

PBR Shader Graph problem with material(s) 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