Surface shader with vertex program for OpenGL ES 2.0

Hi there. I tried to put the least ammount of effort and code into reaching my goal (which is simply custom surface shader with some vertex manipulation), because I like unity’s automagical approach to lighting.
Here’s shader code:

Shader "Tau/Glitcher" {
	Properties {
		_Color ("Main Color", Color) = (1,1,1,1)
		_SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
		_Shininess ("Shininess", Range (0.03, 1)) = 0.078125
		_MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}
		_BumpMap ("Normalmap", 2D) = "bump" {}
		
		_RoundFactor( "Round Factor", Float ) = 100
		_GlitchFactor( "Glitch Factor", Range( 0, 2 ) ) = 0
		_zz( "ZZ", Float ) = 100
	}
	SubShader {
		Tags { "RenderType" = "Opaque" }
		CGPROGRAM
		
		// Upgrade NOTE: excluded shader from OpenGL ES 2.0 because it does not contain a surface program or both vertex and fragment programs.
		#pragma exclude_renderers gles
		
		#pragma vertex vert
		#pragma surface surf BlinnPhong
		
		sampler2D _MainTex;
		sampler2D _BumpMap;
		fixed4 _Color;
		half _Shininess;
		
		float _RoundFactor;
		float _GlitchFactor;
		float _zz;
		
		struct Input {
			float2 uv_MainTex;
			float2 uv_BumpMap;
		};
		
		void vert( inout appdata_full v ){
			v.vertex.x += _GlitchFactor *cos( v.vertex.x *_zz );
			v.vertex.y += _GlitchFactor *cos( v.vertex.y *_zz );
			v.vertex.z += _GlitchFactor *sin( v.vertex.z *_zz );
		}
		
		void surf( Input IN, inout SurfaceOutput o ){
			float2 newUV = IN.uv_MainTex;
			newUV = newUV - fmod( newUV*_RoundFactor, 1 ) /_RoundFactor;
			fixed4 tex = tex2D( _MainTex, newUV );
			
			o.Albedo = tex.rgb *_Color.rgb;
			o.Gloss = tex.a;
			o.Alpha = tex.a * _Color.a;
			o.Specular = _Shininess;
			o.Normal = UnpackNormal( tex2D( _BumpMap, IN.uv_BumpMap ) );
		}
		
		ENDCG
	}
	Fallback "Diffuse"
}

Basically, it “glitches out” model’s vertices and pixelates its texture.
As you have probably noted:

		// Upgrade NOTE: excluded shader from OpenGL ES 2.0 because it does not contain a surface program or both vertex and fragment programs.
		#pragma exclude_renderers gles

Soooo… How do I walk around that? Clearly it doesn’t like the fact of mixing stuff, so I tried to look up working with autolighting, but it prooved to be force to be reconed with, as I couldn’t get it work with Unity’s shiny pretty GI lightmaps.

Ideally, what I need shader to have (I can deal with just this being done):

  1. vertex modification;
  2. _MainColor property;
  3. Unity’s lighting applied, including GI lightmapping + realtime shadows (nothing fancy, just 1 directional light);
  4. Run with OpenGL ES 2.0

Instead of:

#pragma vertex vert
#pragma surface surf BlinnPhong

I generally use:

#pragma surface surf BlinnPhong vertex:vert

I seems to me this could be why the compiler is complaining you are mixing things. You either have vertex and fragment shaders or a surface shader with an optional vertex shader.

Thank you, this helped :slight_smile: