Is it possible to adjust 'stroke' of Edge Detection post image effect?

Hi Unity Community,

I was curious to know if it is possible to reduce the ‘stroke’/ thickness of the lines drawn when using the post image effect Edge Detection.

I’d assume I would have to do this somewhere in the Edge Detection shader. I’ve been messing around with it for a while now but I am not a shader guru and even the syntax of the shader language still confuses me a bit. Although ever minute spent testing if this or that works I start to understand more of the shader language and syntax.

Any help is much appreciated!!

-Ethan

Ok, so I did some digging and I figured something out…

In the edge detection script there are different modes of edge detection. I am using Roberts Cross Depth Normals b/c it gives the best result and matches the 3D model in MAX the best. Now before I really didn’t look at the modes different names but I now noticed there is a Sobel Depth Thin mode. So I went into the shader and look at the differences between Roberts and Sobels Thin. The return variable is calculated differently which makes sense b/c one calculates a thinner edge and one calculates a thicker edge. So all I did was change the calculation in the roberts method to the calculation of the Sobels thin method and it worked the stroke of my edges were halved. Here are the two original methods and my method.

Roberts original vert method:

	v2f vertRobert( appdata_img v ) 
	{
		v2f o;
		o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
		
		float2 uv = v.texcoord.xy;
		o.uv[0] = uv;
		
		#if UNITY_UV_STARTS_AT_TOP
		if (_MainTex_TexelSize.y < 0)
			uv.y = 1-uv.y;
		#endif
				
		// calc coord for the X pattern
		// maybe nicer TODO for the future: 'rotated triangles'
//thick
		o.uv[1] = uv + _MainTex_TexelSize.xy * half2(1,1) * _SampleDistance;
		o.uv[2] = uv + _MainTex_TexelSize.xy * half2(-1,-1) * _SampleDistance;
		o.uv[3] = uv + _MainTex_TexelSize.xy * half2(-1,1) * _SampleDistance;
		o.uv[4] = uv + _MainTex_TexelSize.xy * half2(1,-1) * _SampleDistance;
		return o;
	}

Here is sobels thin original vert method:

	v2f vertThin( appdata_img v )
	{
		v2f o;
		o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
		
		float2 uv = v.texcoord.xy;
		o.uv[0] = uv;
		
		#if UNITY_UV_STARTS_AT_TOP
		if (_MainTex_TexelSize.y < 0)
			uv.y = 1-uv.y;
		#endif
		
		o.uv[1] = uv;
		o.uv[4] = uv;
				
		// offsets for two additional samples
		o.uv[2] = uv + float2(-_MainTex_TexelSize.x, -_MainTex_TexelSize.y) * _SampleDistance;
		o.uv[3] = uv + float2(+_MainTex_TexelSize.x, -_MainTex_TexelSize.y) * _SampleDistance;
		
		return o;
	}

And now here is my mixed method(which is basically the above method):

	v2f vertRobert( appdata_img v ) 
	{
		v2f o;
		o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
		
		float2 uv = v.texcoord.xy;
		o.uv[0] = uv;
		
		#if UNITY_UV_STARTS_AT_TOP
		if (_MainTex_TexelSize.y < 0)
			uv.y = 1-uv.y;
		#endif
				
		// calc coord for the X pattern
		// maybe nicer TODO for the future: 'rotated triangles'
//thick
//		o.uv[1] = uv + _MainTex_TexelSize.xy * half2(1,1) * _SampleDistance;
//		o.uv[2] = uv + _MainTex_TexelSize.xy * half2(-1,-1) * _SampleDistance;
//		o.uv[3] = uv + _MainTex_TexelSize.xy * half2(-1,1) * _SampleDistance;
//		o.uv[4] = uv + _MainTex_TexelSize.xy * half2(1,-1) * _SampleDistance;
//thin		
		o.uv[1] = uv;
		o.uv[4] = uv;
				
		// offsets for two additional samples
		o.uv[2] = uv + float2(-_MainTex_TexelSize.x, -_MainTex_TexelSize.y) * _SampleDistance;
		o.uv[3] = uv + float2(+_MainTex_TexelSize.x, -_MainTex_TexelSize.y) * _SampleDistance;
		return o;
	} 

Now as great as this is I’m not satisfied. It would be sweet if on the shader there could be a sliderbar that dictates the stroke thickness. So I will not accept this as an answer but in the end it does achieve what I originally asked.