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 /
  • Help Room /
avatar image
0
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
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 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.

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

Tint a UI sprite with a gradient 0 Answers

Why is this point light square? 1 Answer

Is it possible to use an Int64 data type in CG? 0 Answers

Unity shaders/materials outside unity enviroment,Unity object export with shaders from shadergraph 0 Answers

Does adding more material properties slow down a shader? 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