Lighting Artifact from Strumpy Ramp Shader

Hi guys so I need a little help here I’m a 3D artist and don’t know much about programming shaders but I’ve been doing a lot of research here lately to try and fix this lighting issue with my ramp shader.

Basically when a light hits the geometry it makes this white square in the area on screen from where it is hitting. I’ve messed around and I can set the Build Settings > Player Settings > Rendering Path to Deferred Lighting will remove the white box artifact as well but deferred lighting also has it’s drawbacks such as for transparent shaders.

Any ideas on how I can fix this in my shader and be able to use Forward Lighting? What’s weird is I’ve done a ramp shader before in strumpy this was a good while back and I didn’t have this problem. Thanks in advance for your help.

Here’s the shader code:

Shader "Ramp/Diff Illum Detail"
{
	Properties 
	{
		_Color("_Color", Color) = (1,1,1,1)
		_MainTex("_MainTex", 2D) = "black" {}
		_Illum("_Illum", 2D) = "black" {}
		_Ramp("_Ramp", 2D) = "black" {}
		_Emission("_Emission", Range(0,1) ) = 1
		_Detail("_Detail", 2D) = "black" {}
		_Offset("_Offset", Float) = 0.05

	}
	
	SubShader 
	{
		Tags
		{
			"Queue"="Geometry"
			"IgnoreProjector"="True"
			"RenderType"="Opaque"
		}

			Cull Back
			ZWrite On
			ZTest LEqual
			ColorMask RGBA
			LOD 100
			Blend SrcAlpha OneMinusSrcAlpha


		CGPROGRAM
#pragma surface surf BlinnPhongEditor  vertex:vert
#pragma target 3.0


			float4 _Color;
			sampler2D _MainTex;
			sampler2D _Illum;
			sampler2D _Ramp;
			float _Emission;
			sampler2D _Detail;
			float _Offset;

			struct EditorSurfaceOutput {
				half3 Albedo;
				half3 Normal;
				half3 Emission;
				half3 Gloss;
				half Specular;
				half Alpha;
				half4 Custom;
			};
			
			inline half4 LightingBlinnPhongEditor_PrePass (EditorSurfaceOutput s, half4 light)
			{
				float4 Luminance0= Luminance( light.xyz ).xxxx;
				float4 Assemble0=float4(Luminance0.x, float4( 0.0, 0.0, 0.0, 0.0 ).y, float4( 0.0, 0.0, 0.0, 0.0 ).z, float4( 0.0, 0.0, 0.0, 0.0 ).w);
				float4 Tex2D0=tex2D(_Ramp,Assemble0.xy);
				float4 Multiply0=Tex2D0 * float4( s.Albedo.x, s.Albedo.y, s.Albedo.z, 1.0 );
				return Multiply0;

			}

			inline half4 LightingBlinnPhongEditor (EditorSurfaceOutput s, half3 lightDir, half3 viewDir, half atten)
			{
				half3 h = normalize (lightDir + viewDir);
				
				half diff = max (0, dot ( lightDir, s.Normal ));
				
				float nh = max (0, dot (s.Normal, h));
				float spec = pow (nh, s.Specular*128.0);
				
				half4 res;
				res.rgb = _LightColor0.rgb * diff;
				res.w = spec * Luminance (_LightColor0.rgb);
				res *= atten * 2.0;

				return LightingBlinnPhongEditor_PrePass( s, res );
			}
			
			struct Input {
				float2 uv_MainTex;
				float4 fullMeshUV1;
				float3 worldPos;
				float2 uv_Illum;

			};

			void vert (inout appdata_full v, out Input o) {
				float4 VertexOutputMaster0_0_NoInput = float4(0,0,0,0);
				float4 VertexOutputMaster0_1_NoInput = float4(0,0,0,0);
				float4 VertexOutputMaster0_2_NoInput = float4(0,0,0,0);
				float4 VertexOutputMaster0_3_NoInput = float4(0,0,0,0);
				
				o.fullMeshUV1 = v.texcoord;

			}
			

			void surf (Input IN, inout EditorSurfaceOutput o) {
				o.Normal = float3(0.0,0.0,1.0);
				o.Alpha = 1.0;
				o.Albedo = 0.0;
				o.Emission = 0.0;
				o.Gloss = 0.0;
				o.Specular = 0.0;
				o.Custom = 0.0;
				
				float4 Tex2D0=tex2D(_MainTex,(IN.uv_MainTex.xyxy).xy);
				float4 Mask0=float4(float4( IN.worldPos.x, IN.worldPos.y,IN.worldPos.z,1.0 ).x,float4( IN.worldPos.x, IN.worldPos.y,IN.worldPos.z,1.0 ).y,0.0,0.0);
				float4 Multiply4=Mask0 * _Offset.xxxx;
				float4 Add0=(IN.fullMeshUV1) + Multiply4;
				float4 Tex2D2=tex2D(_Detail,Add0.xy);
				float4 Multiply2=Tex2D0 * Tex2D2;
				float4 Tex2D1=tex2D(_Illum,(IN.uv_Illum.xyxy).xy);
				float4 Multiply0=Tex2D1 * _Emission.xxxx;
				float4 Multiply1=_Color * Multiply0;
				float4 Master0_1_NoInput = float4(0,0,1,1);
				float4 Master0_3_NoInput = float4(0,0,0,0);
				float4 Master0_4_NoInput = float4(0,0,0,0);
				float4 Master0_5_NoInput = float4(1,1,1,1);
				float4 Master0_7_NoInput = float4(0,0,0,0);
				float4 Master0_6_NoInput = float4(1,1,1,1);
				o.Albedo = Multiply2;
				o.Emission = Multiply1;

				o.Normal = normalize(o.Normal);
			}
		ENDCG
	}
	Fallback "Ramp/Basic"
}

I hate that particular issue. I’ve spent hours looking for solutions to it and the answer is so simple. I’m 99% sure that you haven’t set your ramp texture wrap mode to clamp. If the incoming light value is over one it will start wrapping around and sample from the wrong side of the texture.