summaryrefslogtreecommitdiff
path: root/shaders/unity/99-Water.shader_test
blob: eacd20498d35c6bfe00044f00a2e88623ddd49df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# Built-in shader from Unity 5.0.0b19:
# FX/Water4
# internal variant: WATER_EDGEBLEND_ON WATER_REFLECTIVE WATER_VERTEX_DISPLACEMENT_ON
# This shader GLSL dump is put under MIT license
[require]
GLSL >= 1.10

[vertex shader]
uniform vec4 _Time;
uniform vec3 _WorldSpaceCameraPos;
uniform vec4 _ProjectionParams;

uniform mat4 _Object2World;
uniform float _GerstnerIntensity;
uniform vec4 _BumpTiling;
uniform vec4 _BumpDirection;
uniform vec4 _GAmplitude;
uniform vec4 _GFrequency;
uniform vec4 _GSteepness;
uniform vec4 _GSpeed;
uniform vec4 _GDirectionAB;
uniform vec4 _GDirectionCD;
varying vec4 xlv_TEXCOORD0;
varying vec4 xlv_TEXCOORD1;
varying vec4 xlv_TEXCOORD2;
varying vec4 xlv_TEXCOORD3;
varying vec4 xlv_TEXCOORD4;
void main ()
{
  vec4 tmpvar_1;
  tmpvar_1.w = gl_Vertex.w;
  vec4 tmpvar_2;
  vec4 tmpvar_3;
  vec3 tmpvar_4;
  tmpvar_4 = (_Object2World * gl_Vertex).xyz;
  vec3 offsets_5;
  vec4 tmpvar_6;
  tmpvar_6 = ((_GSteepness.xxyy * _GAmplitude.xxyy) * _GDirectionAB);
  vec4 tmpvar_7;
  tmpvar_7 = ((_GSteepness.zzww * _GAmplitude.zzww) * _GDirectionCD);
  vec4 tmpvar_8;
  tmpvar_8.x = dot (_GDirectionAB.xy, tmpvar_4.xz);
  tmpvar_8.y = dot (_GDirectionAB.zw, tmpvar_4.xz);
  tmpvar_8.z = dot (_GDirectionCD.xy, tmpvar_4.xz);
  tmpvar_8.w = dot (_GDirectionCD.zw, tmpvar_4.xz);
  vec4 tmpvar_9;
  tmpvar_9 = (_GFrequency * tmpvar_8);
  vec4 cse_10;
  cse_10 = (_Time.yyyy * _GSpeed);
  vec4 tmpvar_11;
  tmpvar_11 = cos((tmpvar_9 + cse_10));
  vec4 tmpvar_12;
  tmpvar_12.xy = tmpvar_6.xz;
  tmpvar_12.zw = tmpvar_7.xz;
  offsets_5.x = dot (tmpvar_11, tmpvar_12);
  vec4 tmpvar_13;
  tmpvar_13.xy = tmpvar_6.yw;
  tmpvar_13.zw = tmpvar_7.yw;
  offsets_5.z = dot (tmpvar_11, tmpvar_13);
  offsets_5.y = dot (sin((tmpvar_9 + cse_10)), _GAmplitude);
  vec2 xzVtx_14;
  xzVtx_14 = (tmpvar_4.xz + offsets_5.xz);
  vec3 nrml_15;
  nrml_15.y = 2.0;
  vec4 tmpvar_16;
  tmpvar_16 = ((_GFrequency.xxyy * _GAmplitude.xxyy) * _GDirectionAB);
  vec4 tmpvar_17;
  tmpvar_17 = ((_GFrequency.zzww * _GAmplitude.zzww) * _GDirectionCD);
  vec4 tmpvar_18;
  tmpvar_18.x = dot (_GDirectionAB.xy, xzVtx_14);
  tmpvar_18.y = dot (_GDirectionAB.zw, xzVtx_14);
  tmpvar_18.z = dot (_GDirectionCD.xy, xzVtx_14);
  tmpvar_18.w = dot (_GDirectionCD.zw, xzVtx_14);
  vec4 tmpvar_19;
  tmpvar_19 = cos(((_GFrequency * tmpvar_18) + cse_10));
  vec4 tmpvar_20;
  tmpvar_20.xy = tmpvar_16.xz;
  tmpvar_20.zw = tmpvar_17.xz;
  nrml_15.x = -(dot (tmpvar_19, tmpvar_20));
  vec4 tmpvar_21;
  tmpvar_21.xy = tmpvar_16.yw;
  tmpvar_21.zw = tmpvar_17.yw;
  nrml_15.z = -(dot (tmpvar_19, tmpvar_21));
  nrml_15.xz = (nrml_15.xz * _GerstnerIntensity);
  vec3 tmpvar_22;
  tmpvar_22 = normalize(nrml_15);
  nrml_15 = tmpvar_22;
  tmpvar_1.xyz = (gl_Vertex.xyz + offsets_5);
  tmpvar_3.xyz = (tmpvar_4 - _WorldSpaceCameraPos);
  vec4 tmpvar_23;
  tmpvar_23 = (gl_ModelViewProjectionMatrix * tmpvar_1);
  vec4 grabPassPos_24;
  vec4 o_25;
  vec4 tmpvar_26;
  tmpvar_26 = (tmpvar_23 * 0.5);
  vec2 tmpvar_27;
  tmpvar_27.x = tmpvar_26.x;
  tmpvar_27.y = (tmpvar_26.y * _ProjectionParams.x);
  o_25.xy = (tmpvar_27 + tmpvar_26.w);
  o_25.zw = tmpvar_23.zw;
  grabPassPos_24.xy = ((tmpvar_23.xy + tmpvar_23.w) * 0.5);
  grabPassPos_24.zw = tmpvar_23.zw;
  tmpvar_2.xyz = tmpvar_22;
  tmpvar_3.w = clamp (offsets_5.y, 0.0, 1.0);
  tmpvar_2.w = 1.0;
  gl_Position = tmpvar_23;
  xlv_TEXCOORD0 = tmpvar_2;
  xlv_TEXCOORD1 = tmpvar_3;
  xlv_TEXCOORD2 = (((_Object2World * tmpvar_1).xzxz + (_Time.xxxx * _BumpDirection)) * _BumpTiling);
  xlv_TEXCOORD3 = o_25;
  xlv_TEXCOORD4 = grabPassPos_24;
}

[fragment shader]
uniform vec4 _ZBufferParams;
uniform sampler2D _BumpMap;
uniform sampler2D _ReflectionTex;
uniform sampler2D _RefractionTex;
uniform sampler2D _ShoreTex;
uniform sampler2D _CameraDepthTexture;
uniform vec4 _SpecularColor;
uniform vec4 _BaseColor;
uniform vec4 _ReflectionColor;
uniform vec4 _InvFadeParemeter;
uniform float _Shininess;
uniform vec4 _WorldLightDir;
uniform vec4 _DistortParams;
uniform float _FresnelScale;
uniform vec4 _Foam;
varying vec4 xlv_TEXCOORD0;
varying vec4 xlv_TEXCOORD1;
varying vec4 xlv_TEXCOORD2;
varying vec4 xlv_TEXCOORD3;
varying vec4 xlv_TEXCOORD4;
void main ()
{
  vec4 baseColor_1;
  vec4 edgeBlendFactors_2;
  vec4 rtRefractions_3;
  vec3 worldNormal_4;
  vec3 normal_5;
  normal_5.xy = ((texture2D (_BumpMap, xlv_TEXCOORD2.xy).wy * 2.0) - 1.0);
  normal_5.z = sqrt((1.0 - clamp (
    dot (normal_5.xy, normal_5.xy)
  , 0.0, 1.0)));
  vec3 normal_6;
  normal_6.xy = ((texture2D (_BumpMap, xlv_TEXCOORD2.zw).wy * 2.0) - 1.0);
  normal_6.z = sqrt((1.0 - clamp (
    dot (normal_6.xy, normal_6.xy)
  , 0.0, 1.0)));
  vec3 tmpvar_7;
  tmpvar_7 = normalize((xlv_TEXCOORD0.xyz + (
    (((normal_5 + normal_6) * 0.5).xxy * _DistortParams.x)
   * vec3(1.0, 0.0, 1.0))));
  worldNormal_4 = tmpvar_7;
  vec3 tmpvar_8;
  tmpvar_8 = normalize(xlv_TEXCOORD1.xyz);
  vec4 tmpvar_9;
  tmpvar_9.zw = vec2(0.0, 0.0);
  tmpvar_9.xy = ((tmpvar_7.xz * _DistortParams.y) * 10.0);
  vec4 tmpvar_10;
  tmpvar_10 = (xlv_TEXCOORD4 + tmpvar_9);
  vec4 tmpvar_11;
  tmpvar_11 = texture2DProj (_RefractionTex, xlv_TEXCOORD4);
  rtRefractions_3 = texture2DProj (_RefractionTex, tmpvar_10);
  vec4 tmpvar_12;
  tmpvar_12 = texture2DProj (_ReflectionTex, (xlv_TEXCOORD3 + tmpvar_9));
  float tmpvar_13;
  tmpvar_13 = (1.0/(((_ZBufferParams.z * texture2DProj (_CameraDepthTexture, tmpvar_10).x) + _ZBufferParams.w)));
  if ((tmpvar_13 < xlv_TEXCOORD3.z)) {
    rtRefractions_3 = tmpvar_11;
  };
  vec4 tmpvar_14;
  tmpvar_14 = clamp ((_InvFadeParemeter * (
    (1.0/(((_ZBufferParams.z * texture2DProj (_CameraDepthTexture, xlv_TEXCOORD3).x) + _ZBufferParams.w)))
   - xlv_TEXCOORD3.w)), 0.0, 1.0);
  edgeBlendFactors_2.xzw = tmpvar_14.xzw;
  edgeBlendFactors_2.y = (1.0 - tmpvar_14.y);
  worldNormal_4.xz = (tmpvar_7.xz * _FresnelScale);
  vec4 tmpvar_15;
  tmpvar_15 = (_BaseColor - ((xlv_TEXCOORD1.w * _InvFadeParemeter.w) * vec4(0.15, 0.03, 0.01, 0.0)));
  vec4 coords_16;
  coords_16 = (xlv_TEXCOORD2 * 2.0);
  baseColor_1.xyz = ((mix (
    mix (rtRefractions_3, tmpvar_15, tmpvar_15.wwww)
  , 
    mix (tmpvar_12, _ReflectionColor, _ReflectionColor.wwww)
  , vec4(
    clamp ((_DistortParams.w + ((1.0 - _DistortParams.w) * pow (
      clamp ((1.0 - max (dot (
        -(tmpvar_8)
      , worldNormal_4), 0.0)), 0.0, 1.0)
    , _DistortParams.z))), 0.0, 1.0)
  )) + (
    max (0.0, pow (max (0.0, dot (tmpvar_7, 
      -(normalize((_WorldLightDir.xyz + tmpvar_8)))
    )), _Shininess))
   * _SpecularColor)).xyz + ((
    ((texture2D (_ShoreTex, coords_16.xy) * texture2D (_ShoreTex, coords_16.zw)) - 0.125)
  .xyz * _Foam.x) * (edgeBlendFactors_2.y + 
    clamp ((xlv_TEXCOORD1.w - _Foam.y), 0.0, 1.0)
  )));
  baseColor_1.w = edgeBlendFactors_2.x;
  gl_FragData[0] = baseColor_1;
}