struct v2f_vertex_lit { vec2 uv; vec4 diff; vec4 spec; }; struct v2f_img { vec4 pos; vec2 uv; }; struct appdata_img { vec4 vertex; vec2 texcoord; }; struct SurfaceOutput { vec3 Albedo; vec3 Normal; vec3 Emission; float Specular; float Gloss; float Alpha; }; struct appdata_full { vec4 vertex; vec4 tangent; vec3 normal; vec4 texcoord; vec4 texcoord1; vec4 color; }; struct Input { vec2 uv_MainTex; vec4 color; }; struct v2f_surf { vec4 pos; vec2 hip_pack0; vec4 lop_color; }; uniform vec4 _CameraPosition; uniform vec3 _CameraRight; uniform vec3 _CameraUp; uniform vec4 _MainTex_ST; uniform vec4 _WaveAndDistance; uniform vec4 _WavingTint; uniform vec4 unity_LightShadowBias; void FastSinCos( in vec4 val, out vec4 s, out vec4 c ); void TerrainWaveGrass( inout vec4 vertex, in float waveAmount, in vec3 color, out vec4 outColor ); void TerrainBillboardGrass( inout vec4 pos, in vec2 offset ); void vert( inout appdata_full v ); v2f_surf vert_surf( in appdata_full v ); void FastSinCos( in vec4 val, out vec4 s, out vec4 c ) { vec4 r5; vec4 r6; vec4 r7; vec4 r8; vec4 r1; vec4 r2; vec4 r3; vec4 sin7 = vec4( 1.00000, -0.161616, 0.00833330, -0.000198410); vec4 cos8 = vec4( -0.500000, 0.0416667, -0.00138889, 2.48016e-005); val = ((val * 6.40885) - 3.14159); r5 = (val * val); r6 = (r5 * r5); r7 = (r6 * r5); r8 = (r6 * r5); r1 = (r5 * val); r2 = (r1 * r5); r3 = (r2 * r5); s = (((val + (r1 * sin7.y )) + (r2 * sin7.z )) + (r3 * sin7.w )); c = ((((1.00000 + (r5 * cos8.x )) + (r6 * cos8.y )) + (r7 * cos8.z )) + (r8 * cos8.w )); } void TerrainWaveGrass( inout vec4 vertex, in float waveAmount, in vec3 color, out vec4 outColor ) { vec4 _waveXSize; vec4 _waveZSize; vec4 waveSpeed = vec4( 1.20000, 2.00000, 1.60000, 4.80000); vec4 _waveXmove = vec4( 0.0240000, 0.0400000, -0.120000, 0.0960000); vec4 _waveZmove = vec4( 0.00600000, 0.0200000, -0.0200000, 0.100000); vec4 waves; vec4 s; vec4 c; float lighting; vec3 waveMove = vec3( 0.000000, 0.000000, 0.000000); vec3 waveColor; _waveXSize = (vec4( 0.0120000, 0.0200000, 0.0600000, 0.0240000) * _WaveAndDistance.y ); _waveZSize = (vec4( 0.00600000, 0.0200000, 0.0200000, 0.0500000) * _WaveAndDistance.y ); waves = (vertex.x * _waveXSize); waves += (vertex.z * _waveZSize); waves += (_WaveAndDistance.x * waveSpeed); waves = fract( waves ); FastSinCos( waves, s, c); s = (s * s); s = (s * s); lighting = (dot( s, normalize( vec4( 1.00000, 1.00000, 0.400000, 0.200000) )) * 0.700000); s = (s * waveAmount); waveMove.x = dot( s, _waveXmove); waveMove.z = dot( s, _waveZmove); vertex.xz -= (waveMove.xz * _WaveAndDistance.z ); waveColor = mix( vec3( 0.500000, 0.500000, 0.500000), _WavingTint.xyz , vec3( lighting)); outColor.xyz = ((color * waveColor) * 2.00000); outColor.w = 1.00000; } void TerrainBillboardGrass( inout vec4 pos, in vec2 offset ) { vec3 grasspos; grasspos = (pos.xyz - _CameraPosition.xyz ); if ( (dot( grasspos, grasspos) > _WaveAndDistance.w ) ){ offset = vec2( 0.000000); } pos.xyz += (offset.x * _CameraRight.xyz ); pos.xyz += (offset.y * _CameraUp.xyz ); } void vert( inout appdata_full v ) { float waveAmount; vec4 color; TerrainBillboardGrass( v.vertex, v.tangent.xy ); waveAmount = v.tangent.y ; TerrainWaveGrass( v.vertex, waveAmount, v.color.xyz , color); v.color = color; } v2f_surf vert_surf( in appdata_full v ) { v2f_surf o; vert( v); o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); o.lop_color = v.color; o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); o.pos.z += unity_LightShadowBias.x ; if ( (o.pos.z < ( -o.pos.w )) ){ o.pos.z = ( -o.pos.w ); } return o; } attribute vec4 TANGENT; void main() { v2f_surf xl_retval; appdata_full xlt_v; xlt_v.vertex = vec4( gl_Vertex); xlt_v.tangent = vec4( TANGENT); xlt_v.normal = vec3( gl_Normal); xlt_v.texcoord = vec4( gl_MultiTexCoord0); xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); xlt_v.color = vec4( gl_Color); xl_retval = vert_surf( xlt_v); gl_Position = vec4( xl_retval.pos); gl_TexCoord[1] = vec4( xl_retval.hip_pack0, 0.0, 0.0); gl_FrontColor = vec4( xl_retval.lop_color); }