Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by ohlin · Dec 15, 2014 at 09:41 AM · shaderoutlinetoon

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"
       }


Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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?

Comment
Add comment · Share
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

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

3 People are following this question.

avatar image avatar image avatar image

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


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