Using a shader to oscillate plant

Hi everyone.

I’m new in Unity and I trying to develop my first mini video game for Android.

I imported the BananaPlant prefab and its texture and its shader (its name is Nature/Tree Soft Occlusion Leaves) provide from the Island Demo projet and I use them in my game.

Now, I try to make a shader to oscillate the BananaPlant in my game. But unfortunly, my shader doesn’t work.

I know I have to use the initial shader to keep the texture and its renders and make a vertex program using the sine finction to oscillate the plants. But I have no idea the correct way to do this.

currently, my shader looks like that :

Shader "Custom/MovePlants" {
Properties {
}
SubShader {

	UsePass "Nature/Tree Soft Occlusion Leaves"
	Pass {
	
		CGPROGRAM
		#pragma vertex vert
		#pragma fragment frag
		#include "UnityCG.cginc"

		struct v2f {
    		float4 pos : SV_POSITION;
    		float3 color : COLOR0;
		};

		v2f vert (appdata_base v){
    		v2f o;
    		o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
    		v.vertex.y += sin(_Time * 2.2 + v.vertex.y);
    		return o;
		}
		
		half4 frag (v2f i) : COLOR {
			return half4 (i.color, 1);
		}
			
		ENDCG
	}
} 
FallBack "Diffuse"

}

I using a fragment program because apparently I must a both of vertex and fragment program for a OpenGL ES 2.0 target but I really don’t know what I can put in the body of this program.

Please Have anybody got a solution for my trouble ?

Thanks for your help.

v.vertex.y += sin(_Time * 2.2 + v.vertex.y);

should probably be

o.pos.y += sin(_Time * 2.2 + v.vertex.y);

Also it doesn’t work for me unless I comment UsePass away. Maybe it has something to do with the properties that Tree Soft Occlusion Leaves uses aren’t available and that you didn’t specify a pass in the shader that you want to use.

You can get the shader sources from here and mod them to suit your needs if you want to.