Shader "Simple/VertexLit Reflective"
{

Properties

{

_Reflected

("Reflection",

Color) = (0.15,

0.15,

0.15,

1)
_MainTex ("Base (RGB) RefStrength (A)", 2D) = "white" {}

_BumpTex ("Normal", 2D) = "white" {}

_Cube ("Reflection Cubemap", Cube) = "_Skybox" { TexGen CubeReflect }

_WindDirection("Wind Direction",Vector) = (0,0,0,0)

}

SubShader

{

Pass

{

Tags {"LightMode"="Vertex" }

GLSLPROGRAM

// Varyings

varying mediump vec2 uv;

varying mediump vec2

uv2;

varying lowp vec3 reflectedDirection;

varying lowp float c;

varying mediump vec3 viewDirection;

varying mediump vec3 lightDir;

uniform mediump vec3 unity_LightPosition[1];

uniform mediump vec3 unity_LightColor[1];

uniform mat4 _Object2World; // model matrix

uniform mat4 _World2Object; // inverse model matrix

uniform lowp vec4 _WindDirection;

uniform mediump vec4 _Reflected;

#ifdef VERTEX

uniform mediump vec4 _MainTex_ST;

uniform mediump vec4 _BumpTex_ST;

uniform lowp vec3 _WorldSpaceLightPos0, _LightColor0, _WorldSpaceCameraPos;

{

vec4 wind;

wind.xyz = mat3(_WindDirection, _WindDirection, _WindDirection) * _WindDirection.xyz;

wind.w = 0.0;

uv = gl_MultiTexCoord0.xy * _MainTex_ST.xy + _MainTex_ST.zw;

uv2 = gl_MultiTexCoord1.

xy * _BumpTex_ST.

xy + _BumpTex_ST.

zw;

viewDirection = vec3(_Object2World * gl_Vertex - vec4(_WorldSpaceCameraPos, 1.0));

normal = normalize

(gl_NormalMatrix

* gl_Normal

);

lightDir = normalize(vec3(unity_LightPosition[0].xyz));

lighting = max

(dot

(normal, lightDir

),

0.

) * unity_LightColor

[0] + gl_LightModel.

ambient.

rgb;

c = (1.0-gl_Color.g) * 1.5;

reflectedDirection

= reflect

(viewDirection,

normal);

vec4 pos = gl_Vertex;

pos.xyz += wind.xyz + (_WindDirection.xyz * (1.0-gl_Color.r)) ;

gl_Position = gl_ModelViewProjectionMatrix * pos;

}

#endif

#ifdef FRAGMENT

uniform lowp sampler2D _MainTex;

uniform lowp sampler2D _BumpTex;

uniform lowp samplerCube _Cube;

{

lowp vec4 u = texture2D(_MainTex, uv);

lowp vec4 u2

= texture2D

(_BumpTex,

uv2);

gl_FragColor = (u - (u2.g * u) * c) + (textureCube(_Cube, reflectedDirection) * _Reflected);

}

#endif

ENDGLSL

}

}

Fallback "Mobile/VertexLit"

}