Fragment and Vertex Shader Lighting Issue.

So I got this shader off of AngryBots and it’s doing exactly what I expected, but the problem is that no lights are affecting it. Directional lights, point lights and spot lights. I can modify some shader code but I have no shader knowledge of making lighting work with this. Can anyone help me? It would be much appreciated :slight_smile:

By the way, I’m a C# programmer, not a shader programmer, so I don’t know any of these complicated stuff.

Shader "Darkraze/FX/Wet Surface" {
	Properties {
		_MainColor ("Main Color", Color) = (1, 1, 1, 1)
		_ReflColor ("Reflection Color", Color) = (1, 1, 1, 1)
		_MainTex ("Base Texture", 2D) = "white" {}
		_Normal ("Normal-map", 2D) = "bump" {}
		_ReflectionTex ("Reflection Texture", 2D) = "black" {}
		_ReflectionMask ("Reflection Mask", 2D) = "black" {}
		_DirectionUv("Wave Direction/Speed", Vector) = (1, 1, -0.2, -0.2)
		_BumpMapTiling("Wave Tiling", Vector) = (8, 8, 4, 4)
		_WaveStrength("Wave Strength", Range(0.05, 0.5)) = 0.05
	}
	
	CGINCLUDE
	
	struct v2f_full {
		half4 pos : SV_POSITION;
		half2 uv : TEXCOORD0;
		half4 normalScrollUv : TEXCOORD1;
		half4 screen : TEXCOORD2;
		half2 fakeRefl : TEXCOORD3;
	};
	
	#include "Darkraze.cginc"
	
	half4 _MainColor;
	half4 _ReflColor;
	half4 _DirectionUv;
	half4 _BumpMapTiling;
	half _WaveStrength;
	
	sampler2D _MainTex;
	sampler2D _Normal;
	sampler2D _ReflectionTex;
	sampler2D _ReflectionMask;
	
	ENDCG
	
	SubShader {
		Tags {"RenderType" = "Opaque"}
		LOD 300
	
		Pass {
			CGPROGRAM
			#pragma vertex vert
			#pragma fragment frag
			#pragma fragmentoption ARB_precision_hint_fastest
			
			float4 _MainTex_ST;
			
			v2f_full vert(appdata_full v) {
				v2f_full o;
				o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
				o.uv.xy = TRANSFORM_TEX(v.texcoord, _MainTex);
				
				o.normalScrollUv.xyzw = v.texcoord.xyxy * _BumpMapTiling + _Time.xxxx * _DirectionUv;
				
				o.fakeRefl = EthansFakeReflection(v.vertex);
				
				return o;
			}
						
			fixed4 frag(v2f_full i) : COLOR0 {
				half3 nrml = UnpackNormal(tex2D(_Normal, i.normalScrollUv.xy));
				nrml += UnpackNormal(tex2D(_Normal, i.normalScrollUv.zw));
				
				nrml.xy *= 0.025;
																
				fixed4 rtRefl = tex2D(_ReflectionTex, nrml.xy);
				rtRefl += tex2D(_ReflectionMask, i.fakeRefl + nrml.xy * 2.0);
			
				fixed4 tex = tex2D(_MainTex, i.uv.xy + nrml.xy * _WaveStrength);
				
				tex = (tex * _MainColor) + (tex.a * rtRefl * _ReflColor);
				
				return tex;
			}
						
			ENDCG
		}
	}
	
	Fallback "VertexLit"
}

As far as I can tell, it’s not supposed to have lights work with it? It’s a shader built to give reflections.

Here is a shader with lighting working at a per-pixel level in vert/frag shaders, you should be able to combine the two.
http://forum.unity3d.com/threads/198141-Lighting-using-tangent-vector-and-also-using-surface-shaders?p=1344367&viewfull=1#post1344367

Ah, many thanks for providing that link. I will look into it and see what I can do. And yes, I know that lighting doesnt work with the shader, that’s why I asked for help. Thanks once again

It works! But then I figured out it only works for directional lights. Any more ideas on where to get those two? Point light is more important than spotlight. Thanks for your help

Nevermind, I found another shader that looks better and actually works with lighting 100%. Thanks for your help anyway.

Are those in surface shader or vertex fragment?