Simple cartoon water shader shoreline

I’m currently attempting to create a cartoon-ish water shader with a shoreline.
After looking around trying to find out how other games do it i figured out it has something to do with getting the distance from the depth map (which doesn’t include the water when it’s render queue is set to transparent) and the and the world position of the current pixel.

From certain angles i’m actually getting very close to the desired result as show here:

The topmost island almost has the desired result, but as you can tell, the closer it gets to the camera, the more out of place the effect becomes.

here’s a zoomed out top down view illustrating the problem

and of course, here is my shader code:

Shader "Custom/CartoonWater" {
	Properties {
		_Color ("Color", Color) = (1,1,1,1)
		_Glossiness("Smoothness", Range(0,1)) = 0.5
		_ShoreFade("Shoreline Distance", Float) = 1
	SubShader {
			Tags{ "Queue" = "Transparent" "RenderType" = "Transparent" }
		LOD 200
		// Physically based Standard lighting model, and enable shadows on all light types
		#pragma surface surf StandardSpecular	 

		// Use shader model 3.0 target, to get nicer looking lighting
		#pragma target 3.0

		sampler2D _CameraDepthTexture;
		struct Input {
			float3 worldPos;
			float4 screenPos;

		half _Glossiness;
		fixed4 _Color;
		float _ShoreFade;

		void surf (Input IN, inout SurfaceOutputStandardSpecular o) {

			o.Albedo = _Color.rgb;
			o.Smoothness = _Glossiness;
			fixed4 depth = tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(IN.screenPos));
			o.Albedo = _Color;
			if (distance(LinearEyeDepth(depth), distance(_WorldSpaceCameraPos, IN.worldPos)) < _ShoreFade) {
				o.Albedo = fixed4(1, 1, 1, 1);
	FallBack "Diffuse"

any help is greatly appreciated :slight_smile:
thanks in advance.

@moviemastersdk try this, I quickly scrapped it together from some research, but it seems to work for me with a shoreline that dips.

half depth = SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(IN.screenPos));
depth = LinearEyeDepth(depth * _Threshold);
half4 edgeBlend = abs(1.0 - clamp((depth - IN.screenPos.w), 0.0, 1.0)) * 1;
o.Albedo += edgeBlend;