Hey, i searching for whiles now for an outline shader working with hdrp.. to be honest i have realy no knowledge with shader programing, and are very happy with the new shadergraph. i just read some Topics about Outline Shader and i think i got some Idea how it should work. This is my "simple" definition what i understand. Scale the Vertex of an object from actual view angle to get the Outline. In the Shadergraph i just found Vertex Color. i guess it is not implemented yet into the Graph. Then i looked into this Asset: https://assetstore.unity.com/packages/tools/particles-effects/quick-outline-115488 i Think it got all what i need but i guess the shader isnt compatible with the HDRP Pipeline here is the Code from the Fill and Mask Shader (due it is free i hope it is no problem to post it here): Code (CSharp): // // OutlineFill.shader // QuickOutline // // Created by Chris Nolet on 2/21/18. // Copyright © 2018 Chris Nolet. All rights reserved. // Shader "Custom/Outline Fill" { Properties { [Enum(UnityEngine.Rendering.CompareFunction)] _ZTest("ZTest", Float) = 0 _OutlineColor("Outline Color", Color) = (1, 1, 1, 1) _OutlineWidth("Outline Width", Range(0, 10)) = 2 } SubShader { Tags { "Queue" = "Transparent+110" "RenderType" = "Transparent" "DisableBatching" = "True" } Pass { Name "Fill" Cull Off ZTest [_ZTest] ZWrite Off Blend SrcAlpha OneMinusSrcAlpha ColorMask RGB Stencil { Ref 1 Comp NotEqual } CGPROGRAM #include "UnityCG.cginc" #pragma vertex vert #pragma fragment frag struct appdata { float4 vertex : POSITION; float3 normal : NORMAL; float3 smoothNormal : TEXCOORD3; UNITY_VERTEX_INPUT_INSTANCE_ID }; struct v2f { float4 position : SV_POSITION; fixed4 color : COLOR; UNITY_VERTEX_OUTPUT_STEREO }; uniform fixed4 _OutlineColor; uniform float _OutlineWidth; v2f vert(appdata input) { v2f output; UNITY_SETUP_INSTANCE_ID(input); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); float3 normal = any(input.smoothNormal) ? input.smoothNormal : input.normal; float3 viewPosition = UnityObjectToViewPos(input.vertex); float3 viewNormal = normalize(mul((float3x3)UNITY_MATRIX_IT_MV, normal)); output.position = UnityViewToClipPos(viewPosition + viewNormal * -viewPosition.z * _OutlineWidth / 1000.0); output.color = _OutlineColor; return output; } fixed4 frag(v2f input) : SV_Target { return input.color; } ENDCG } } } And the Mask Shader: Code (CSharp): // // OutlineMask.shader // QuickOutline // // Created by Chris Nolet on 2/21/18. // Copyright © 2018 Chris Nolet. All rights reserved. // Shader "Custom/Outline Mask" { Properties { [Enum(UnityEngine.Rendering.CompareFunction)] _ZTest("ZTest", Float) = 0 } SubShader { Tags { "Queue" = "Transparent+100" "RenderType" = "Transparent" } Pass { Name "Mask" Cull Off ZTest [_ZTest] ZWrite Off ColorMask 0 Stencil { Ref 1 Pass Replace } } } } Is there any way to get this two shaders working within the new pipeline (changing wording or implementing the right library) Does anybody have an Idea ? Or is there some way to get the vertex "displacement" into the Shader Graph Custom Node ?
Hi, i was able to creat a sort of Outline Shader in shadergraph: It is doing a bit what i want but the outline is not correct. It is like in this example like the custom one. It depends on the scale of the object and making lines thiner and bigger on not correct scaled Objects. https://github.com/Shrimpey/Outlined-Diffuse-Shader-Fixed Maybe there is some solution with the custom Node to interpolate it correctly ? Do someone know where the magic happen ^^?
I like your example. It just creates a bigger dark version of the object. How do you layer it properly? (How to make an outline instead of a black, bigger version?)