Hey everyone,
I'm trying to create a shader which has a fresnel element that is controlled by a texture. In other words, I want to be able to prevent the fresnel effect from showing up in certain directions (the bottom of the model, since having bright fresnel coming from below a model tends to look strange). I almost had it working, but whatever I did, made the fresnel stop responding to the viewDIR, and the texture which is meant to control the fresnel is not working correctly.
This is the texture I want to use to control the fresnel.
And this is what it looks like, right now (broken).

See code below.
Thanks a ton for any help.
Shader "WMS/FresnelTex" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_SpecColor ("Specular Color", Color) = (1, 1, 1, 1)
_RimColor ("Rim Color", Color) = (0.26,0.19,0.16,0.0)
_RimPower ("FresnelTex", 2D) = "white" {}
_MainTex ("Diffuse", 2D) = "white" {}
_BumpMap ("Normal", 2D) = "bump" {}
_SpecMap ("Specular (R) Polish (G)", 2D) = "black" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 400
CGPROGRAM
#pragma surface surf BlinnPhong
sampler2D _MainTex;
sampler2D _BumpMap;
sampler2D _SpecMap;
sampler2D _RimPower;
fixed4 _Color;
half _Shininess;
float4 _RimColor;
struct Input {
float2 uv_MainTex;
float2 uv_BumpMap;
float2 uv_SpecMap;
float2 uv_RimPower;
float3 viewDir;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
fixed4 specTex = tex2D(_SpecMap, IN.uv_SpecMap);
fixed4 rimTex = tex2D(_RimPower, IN.uv_RimPower);
o.Albedo = tex.rgb * _Color.rgb;
o.Gloss = specTex.r;
o.Specular = specTex.g;
o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
half rim = 1.0 - saturate(dot (normalize(IN.viewDir), o.Normal));
o.Emission = _RimColor.rgb * rimTex.rgb;
}
ENDCG
}
FallBack "Specular"
asked
Aug 27 '12 at 07:37 PM
avoorhees
3
●
2
●
3
●
5
I should mention, I don't know much at all about coding.