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 But If I hide the camera it looks correct in the scene view. 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"
}
Your answer
Follow this Question
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