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 HJ05 · Aug 22, 2013 at 05:43 PM · shaderoutlineedge

Blueprint Shader

I have a camera that I'm using to generate a top down orthographic view of the world to use as an overview map. What I would like it to look like is just black outlines of all the objects on a white background. I would prefer clean lines as opposed to blured lines found in most outline shaders. I came across this: http://wiki.unity3d.com/index.php?title=Silhouette-Outlined_Diffuse which mostly does what I need, but I wanted to apply the effect "globaly" through the camera and not have to put the shader on each object and I don't know how I would toggle the effect by camera either. Probably somthing along the of this http://www.thecrosshouse.org/Page%208%20-%20Blueprints/Blueprint-First%20Floor.jpg but without the labels and such.

I am using Unity Pro.

Thanks in advance.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Paulius-Liekis · Aug 22, 2013 at 07:17 PM

Note that some outlines shaders work on geometry (like your one) which means it has to be applied to every object, others work on screen-space, which means they are automatically applied on every object. So you might want to look for screen-space effect.

Otherwise you can look into replacement shaders (camera property) which allows to replace shader on all objects.

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
avatar image
0

Answer by HJ05 · Aug 22, 2013 at 10:33 PM

While not a perfect solution it produces an effect close enough to what I was looking for. Using the edge detect effect on the map camera and a modified shader from here: http://answers.unity3d.com/questions/301904/edge-highlighting-shader-with-custom-highlight-col.html I came up with this:

 Shader "Custom/Edge Highlight" {
 Properties {
     _MainTex ("Base (RGB)", 2D) = "white" {}
     _Treshold ("Treshold", Float) = 0.2
 }
 
 SubShader {
     Pass {
         ZTest Always Cull Off ZWrite Off
         Fog { Mode off }
 
 CGPROGRAM
 #pragma vertex vert
 #pragma fragment frag
 #pragma fragmentoption ARB_precision_hint_fastest 
 #include "UnityCG.cginc"
 
 uniform sampler2D _MainTex;
 uniform float4 _MainTex_TexelSize;
 uniform float _Treshold;
 
 struct v2f {
     float4 pos : POSITION;
     float2 uv[3] : TEXCOORD0;
 };
 
 v2f vert( appdata_img v )
 {
     v2f o;
     o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
     float2 uv = MultiplyUV( UNITY_MATRIX_TEXTURE0, v.texcoord );
     o.uv[0] = uv;
     o.uv[1] = uv + float2(-_MainTex_TexelSize.x, -_MainTex_TexelSize.y);
     o.uv[2] = uv + float2(+_MainTex_TexelSize.x, -_MainTex_TexelSize.y);
     return o;
 }
 
 
 half4 frag (v2f i) : COLOR
 {
     half4 original = tex2D(_MainTex, i.uv[0]);
 
     // a very simple cross gradient filter
     half3 p1 = original.rgb;
     half3 p2 = tex2D( _MainTex, i.uv[1] ).rgb;
     half3 p3 = tex2D( _MainTex, i.uv[2] ).rgb;
     
     half3 diff = p1 * 2 - p2 - p3;
     half len = dot(diff,diff);
     if( len >= _Treshold )
         original.xyzw = half4(0f,0f,0f,1.0f);
     else
         original = half4(1f,1f,1f,1.0f);
         
     return original;
 }
 ENDCG
     }
 }
 
 Fallback off
 
 }

The background is either white, or if it is above the threshold then the pixel is black.

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

17 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

Related Questions

Is there a shader to only add an outline? 7 Answers

How to render outline differently 0 Answers

How to determine shader center? 0 Answers

QuickOutline: how can I change the shader to work with objects with two materials? 3 Answers

Edge outline & 2D shadow Shader for planar mesh 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