- Home /
Exclude outline only, from fog, in custom toon shader.
So I have a shader which i will post. And I was wondering if its possible. Just to negate the fog Only on the Rim outline... NOT the whole shader. If it is possible could any one point me in the right direction. And if not possible any idea how I could achieve a similar effect?
Shader "Custom/My ToonShader Test1" {
Properties {
_Lookup ("BRDF Color Ramp", 2D) = "gray" {}
_MainTex ("Texture", 2D) = "white" {}
_Detail ("Texture", 2D) = "white" {}
_Blend ( "Blend", Range ( 0, 1 ) ) = 0.5
_RimPower ("Rim Power", Float) = 1.4
_RimColor ("Rim Color (RGB) + Intensity (A)", Color) = (0.0,0.0,0.0,1.0)
_SColor ("Shadow Color", Color) = (0.0,0.0,0.0,1)
_LColor ("Highlight Color", Color) = (0.5,0.5,0.5,1)
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
Pass
{
SetTexture[_MainTex]
SetTexture[_Detail]
{
ConstantColor ( 0, 0, 0, [_Blend] )
Combine texture Lerp( constant ) previous
}
}
CGPROGRAM
#pragma surface surf Lookup
sampler2D _MainTex;
sampler2D _Lookup;
float _Blend;
sampler2D _Detail;
float4 _LColor;
float4 _SColor;
float _RimPower;
float4 _RimColor;
struct Input
{
float2 uv_MainTex;
float4 screenPos;
float2 uv_Detail;
float3 pos : POSITION0;
float3 viewDir;
};
half4 LightingLookup (SurfaceOutput s, half3 lightDir, half3 viewDir, half atten)
{
float NdotL = dot(s.Normal, lightDir);
float NdotV = dot(s.Normal, viewDir);
float2 lookupUV = float2(NdotV*.8, NdotL * 0.5 + 0.5);
float3 exitRadiance = tex2D(_Lookup, lookupUV).rgb;
float4 c;
c.a = s.Alpha;
#ifndef USING_DIRECTIONAL_LIGHT
lightDir = normalize(lightDir);
#endif
half d = dot (s.Normal, lightDir)*0.5 + 0.5;
half3 ramp = tex2D(_Lookup, float2(d,d)).rgb;
ramp = lerp(_SColor, _LColor, ramp);
c.rgb = s.Albedo * _LightColor0.rgb * ramp * (exitRadiance * (atten * 2));
return c;
}
void surf (Input IN, inout SurfaceOutput o)
{
float2 screenUV = IN.screenPos.xy / IN.screenPos.w;
screenUV *= float2(1,1);
half4 mainTex = tex2D (_MainTex, IN.uv_MainTex);
o.Albedo = mainTex.rgb;
o.Alpha = mainTex.a;
fixed4 t1 = tex2D( _MainTex, IN.uv_MainTex);
fixed4 t2 = tex2D( _Detail, screenUV)*2;
o.Albedo = lerp( t1, t2, _Blend);
//Rim Outline
half rim = saturate( dot(normalize(IN.viewDir), o.Normal) );
o.Albedo *= 1.0f - (step(rim, _RimPower) * (1.0f-_RimColor) * _RimColor.a);
}
ENDCG
}
Fallback "Diffuse"
}
Answer by taxvi · Dec 15, 2014 at 10:45 AM
I have no clue of shader programming but if you can make the object transparent and the edge visible than you could totally use a second camera that is basically a duplicate of the main camera and is its child. then put your toon shaded object in a separate layer. make the depth of the new camera 1, set Clear Flags to depth only, culling mask to the layer of the toon shaded stuff... and this should work... I guess?
Your answer
Follow this Question
Related Questions
Outlines Defined by Shading Groups? 0 Answers
"double" outline shader? 0 Answers
Set Color not working on Outline 0 Answers
Shader Assitance: Sprite Outline Color, Hidden Object -1 Answers
Modified Toon Shader: scaled instead of projected (how to?) 0 Answers