summaryrefslogtreecommitdiff
path: root/shaders/unity/39.shader_test
blob: ee9c71522bad50ffeebebc969a434b98f9732f84 (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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
# Built-in shader from Unity 5.0.0b19:
# Standard
# internal variant: DIRECTIONAL DIRLIGHTMAP_OFF DYNAMICLIGHTMAP_OFF LIGHTMAP_OFF SHADOWS_SCREEN _METALLICGLOSSMAP _NORMALMAP
# This shader GLSL dump is put under MIT license
[require]
GLSL >= 1.10

[vertex shader]
uniform vec3 _WorldSpaceCameraPos;
uniform vec4 _ProjectionParams;
uniform vec4 unity_SHBr;
uniform vec4 unity_SHBg;
uniform vec4 unity_SHBb;
uniform vec4 unity_SHC;

uniform mat4 _Object2World;
uniform mat4 _World2Object;
uniform vec4 _MainTex_ST;
uniform vec4 _DetailAlbedoMap_ST;
uniform float _UVSec;
attribute vec4 TANGENT;
varying vec4 xlv_TEXCOORD0;
varying vec3 xlv_TEXCOORD1;
varying vec4 xlv_TEXCOORD2;
varying vec4 xlv_TEXCOORD2_1;
varying vec4 xlv_TEXCOORD2_2;
varying vec4 xlv_TEXCOORD5;
varying vec4 xlv_TEXCOORD6;
varying vec3 xlv_TEXCOORD8;
void main ()
{
  vec2 tmpvar_1;
  tmpvar_1 = gl_MultiTexCoord0.xy;
  vec2 tmpvar_2;
  tmpvar_2 = gl_MultiTexCoord1.xy;
  vec4 tmpvar_3;
  vec4 tmpvar_4;
  vec4 tmpvar_5;
  vec4 tmpvar_6;
  vec4 tmpvar_7;
  tmpvar_7 = (_Object2World * gl_Vertex);
  vec3 tmpvar_8;
  tmpvar_8 = tmpvar_7.xyz;
  vec4 tmpvar_9;
  tmpvar_9 = (gl_ModelViewProjectionMatrix * gl_Vertex);
  vec4 texcoord_10;
  texcoord_10.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw);
  vec2 tmpvar_11;
  if ((_UVSec == 0.0)) {
    tmpvar_11 = tmpvar_1;
  } else {
    tmpvar_11 = tmpvar_2;
  };
  texcoord_10.zw = ((tmpvar_11 * _DetailAlbedoMap_ST.xy) + _DetailAlbedoMap_ST.zw);
  vec4 v_12;
  v_12.x = _World2Object[0].x;
  v_12.y = _World2Object[1].x;
  v_12.z = _World2Object[2].x;
  v_12.w = _World2Object[3].x;
  vec4 v_13;
  v_13.x = _World2Object[0].y;
  v_13.y = _World2Object[1].y;
  v_13.z = _World2Object[2].y;
  v_13.w = _World2Object[3].y;
  vec4 v_14;
  v_14.x = _World2Object[0].z;
  v_14.y = _World2Object[1].z;
  v_14.z = _World2Object[2].z;
  v_14.w = _World2Object[3].z;
  vec3 tmpvar_15;
  tmpvar_15 = normalize(((
    (v_12.xyz * gl_Normal.x)
   + 
    (v_13.xyz * gl_Normal.y)
  ) + (v_14.xyz * gl_Normal.z)));
  mat3 tmpvar_16;
  tmpvar_16[0] = _Object2World[0].xyz;
  tmpvar_16[1] = _Object2World[1].xyz;
  tmpvar_16[2] = _Object2World[2].xyz;
  vec4 tmpvar_17;
  tmpvar_17.xyz = normalize((tmpvar_16 * TANGENT.xyz));
  tmpvar_17.w = TANGENT.w;
  vec3 tmpvar_18;
  vec3 tmpvar_19;
  tmpvar_18 = tmpvar_17.xyz;
  tmpvar_19 = (((tmpvar_15.yzx * tmpvar_17.zxy) - (tmpvar_15.zxy * tmpvar_17.yzx)) * TANGENT.www);
  vec3 tmpvar_20;
  vec3 tmpvar_21;
  vec3 tmpvar_22;
  tmpvar_20.x = tmpvar_18.x;
  tmpvar_20.y = tmpvar_19.x;
  tmpvar_20.z = tmpvar_15.x;
  tmpvar_21.x = tmpvar_18.y;
  tmpvar_21.y = tmpvar_19.y;
  tmpvar_21.z = tmpvar_15.y;
  tmpvar_22.x = tmpvar_18.z;
  tmpvar_22.y = tmpvar_19.z;
  tmpvar_22.z = tmpvar_15.z;
  vec3 v_23;
  v_23.x = tmpvar_20.x;
  v_23.y = tmpvar_21.x;
  v_23.z = tmpvar_22.x;
  tmpvar_3.xyz = v_23;
  vec3 v_24;
  v_24.x = tmpvar_20.y;
  v_24.y = tmpvar_21.y;
  v_24.z = tmpvar_22.y;
  tmpvar_4.xyz = v_24;
  vec3 v_25;
  v_25.x = tmpvar_20.z;
  v_25.y = tmpvar_21.z;
  v_25.z = tmpvar_22.z;
  tmpvar_5.xyz = v_25;
  vec4 o_26;
  vec4 tmpvar_27;
  tmpvar_27 = (tmpvar_9 * 0.5);
  vec2 tmpvar_28;
  tmpvar_28.x = tmpvar_27.x;
  tmpvar_28.y = (tmpvar_27.y * _ProjectionParams.x);
  o_26.xy = (tmpvar_28 + tmpvar_27.w);
  o_26.zw = tmpvar_9.zw;
  vec3 x2_29;
  vec4 tmpvar_30;
  tmpvar_30 = (tmpvar_15.xyzz * tmpvar_15.yzzx);
  x2_29.x = dot (unity_SHBr, tmpvar_30);
  x2_29.y = dot (unity_SHBg, tmpvar_30);
  x2_29.z = dot (unity_SHBb, tmpvar_30);
  tmpvar_6.xyz = (x2_29 + (unity_SHC.xyz * (
    (tmpvar_15.x * tmpvar_15.x)
   - 
    (tmpvar_15.y * tmpvar_15.y)
  )));
  gl_Position = tmpvar_9;
  xlv_TEXCOORD0 = texcoord_10;
  xlv_TEXCOORD1 = (tmpvar_7.xyz - _WorldSpaceCameraPos);
  xlv_TEXCOORD2 = tmpvar_3;
  xlv_TEXCOORD2_1 = tmpvar_4;
  xlv_TEXCOORD2_2 = tmpvar_5;
  xlv_TEXCOORD5 = tmpvar_6;
  xlv_TEXCOORD6 = o_26;
  xlv_TEXCOORD8 = tmpvar_8;
}

[fragment shader]
#extension GL_ARB_shader_texture_lod : enable
uniform vec4 _WorldSpaceLightPos0;
uniform vec4 unity_SHAr;
uniform vec4 unity_SHAg;
uniform vec4 unity_SHAb;
uniform vec4 unity_ColorSpaceDielectricSpec;
uniform samplerCube unity_SpecCube;
uniform samplerCube unity_SpecCube1;
uniform vec4 _LightColor0;
uniform vec4 _Color;
uniform sampler2D _MainTex;
uniform sampler2D _BumpMap;
uniform float _BumpScale;
uniform sampler2D _MetallicGlossMap;
uniform sampler2D _OcclusionMap;
uniform float _OcclusionStrength;
uniform sampler2D _ShadowMapTexture;
uniform vec4 unity_SpecCube_BoxMax;
uniform vec4 unity_SpecCube_BoxMin;
uniform vec4 unity_SpecCube_ProbePosition;
uniform vec4 unity_SpecCube_HDR;
uniform vec4 unity_SpecCube_BoxMax1;
uniform vec4 unity_SpecCube_BoxMin1;
uniform vec4 unity_SpecCube_ProbePosition1;
uniform vec4 unity_SpecCube_HDR1;
varying vec4 xlv_TEXCOORD0;
varying vec3 xlv_TEXCOORD1;
varying vec4 xlv_TEXCOORD2;
varying vec4 xlv_TEXCOORD2_1;
varying vec4 xlv_TEXCOORD2_2;
varying vec4 xlv_TEXCOORD5;
varying vec4 xlv_TEXCOORD6;
varying vec3 xlv_TEXCOORD8;
void main ()
{
  vec4 c_1;
  vec3 tmpvar_2;
  vec3 tmpvar_3;
  vec3 tmpvar_4;
  tmpvar_2 = xlv_TEXCOORD2.xyz;
  tmpvar_3 = xlv_TEXCOORD2_1.xyz;
  tmpvar_4 = normalize(xlv_TEXCOORD2_2.xyz);
  mat3 tmpvar_5;
  tmpvar_5[0].x = tmpvar_2.x;
  tmpvar_5[0].y = tmpvar_3.x;
  tmpvar_5[0].z = tmpvar_4.x;
  tmpvar_5[1].x = tmpvar_2.y;
  tmpvar_5[1].y = tmpvar_3.y;
  tmpvar_5[1].z = tmpvar_4.y;
  tmpvar_5[2].x = tmpvar_2.z;
  tmpvar_5[2].y = tmpvar_3.z;
  tmpvar_5[2].z = tmpvar_4.z;
  vec3 normal_6;
  normal_6.xy = ((texture2D (_BumpMap, xlv_TEXCOORD0.xy).wy * 2.0) - 1.0);
  normal_6.xy = (normal_6.xy * _BumpScale);
  normal_6.z = sqrt((1.0 - clamp (
    dot (normal_6.xy, normal_6.xy)
  , 0.0, 1.0)));
  vec3 tmpvar_7;
  tmpvar_7 = normalize((normal_6 * tmpvar_5));
  vec3 tmpvar_8;
  tmpvar_8 = normalize(xlv_TEXCOORD1);
  vec2 tmpvar_9;
  tmpvar_9 = texture2D (_MetallicGlossMap, xlv_TEXCOORD0.xy).xw;
  vec3 tmpvar_10;
  tmpvar_10 = (_Color.xyz * texture2D (_MainTex, xlv_TEXCOORD0.xy).xyz);
  vec3 tmpvar_11;
  vec3 tmpvar_12;
  tmpvar_12 = mix (unity_ColorSpaceDielectricSpec.xyz, tmpvar_10, tmpvar_9.xxx);
  float tmpvar_13;
  tmpvar_13 = (unity_ColorSpaceDielectricSpec.w - (tmpvar_9.x * unity_ColorSpaceDielectricSpec.w));
  tmpvar_11 = (tmpvar_10 * tmpvar_13);
  float tmpvar_14;
  tmpvar_14 = ((1.0 - _OcclusionStrength) + (texture2D (_OcclusionMap, xlv_TEXCOORD0.xy).y * _OcclusionStrength));
  float tmpvar_15;
  tmpvar_15 = max (0.0, dot (tmpvar_7, _WorldSpaceLightPos0.xyz));
  vec3 tmpvar_16;
  vec3 tmpvar_17;
  vec3 tmpvar_18;
  tmpvar_18 = vec3(0.0, 0.0, 0.0);
  vec4 tmpvar_19;
  tmpvar_19.w = 1.0;
  tmpvar_19.xyz = tmpvar_7;
  vec3 x1_20;
  x1_20.x = dot (unity_SHAr, tmpvar_19);
  x1_20.y = dot (unity_SHAg, tmpvar_19);
  x1_20.z = dot (unity_SHAb, tmpvar_19);
  tmpvar_17 = (xlv_TEXCOORD5.xyz + x1_20);
  tmpvar_16 = ((_LightColor0.xyz + _LightColor0.xyz) * texture2DProj (_ShadowMapTexture, xlv_TEXCOORD6).x);
  tmpvar_17 = (tmpvar_17 * tmpvar_14);
  vec3 tmpvar_21;
  tmpvar_21 = (tmpvar_8 - (2.0 * (
    dot (tmpvar_7, tmpvar_8)
   * tmpvar_7)));
  vec3 worldNormal_22;
  worldNormal_22 = tmpvar_21;
  if ((unity_SpecCube_ProbePosition.w > 0.0)) {
    vec3 tmpvar_23;
    tmpvar_23 = normalize(tmpvar_21);
    vec3 tmpvar_24;
    tmpvar_24 = ((unity_SpecCube_BoxMax.xyz - xlv_TEXCOORD8) / tmpvar_23);
    vec3 tmpvar_25;
    tmpvar_25 = ((unity_SpecCube_BoxMin.xyz - xlv_TEXCOORD8) / tmpvar_23);
    bvec3 tmpvar_26;
    tmpvar_26 = greaterThan (tmpvar_23, vec3(0.0, 0.0, 0.0));
    float tmpvar_27;
    if (tmpvar_26.x) {
      tmpvar_27 = tmpvar_24.x;
    } else {
      tmpvar_27 = tmpvar_25.x;
    };
    float tmpvar_28;
    if (tmpvar_26.y) {
      tmpvar_28 = tmpvar_24.y;
    } else {
      tmpvar_28 = tmpvar_25.y;
    };
    float tmpvar_29;
    if (tmpvar_26.z) {
      tmpvar_29 = tmpvar_24.z;
    } else {
      tmpvar_29 = tmpvar_25.z;
    };
    vec3 tmpvar_30;
    tmpvar_30 = ((unity_SpecCube_BoxMax.xyz + unity_SpecCube_BoxMin.xyz) * 0.5);
    worldNormal_22 = (((
      (tmpvar_30 - unity_SpecCube_ProbePosition.xyz)
     + xlv_TEXCOORD8) + (tmpvar_23 * 
      min (min (tmpvar_27, tmpvar_28), tmpvar_29)
    )) - tmpvar_30);
  };
  vec4 tmpvar_31;
  tmpvar_31.xyz = worldNormal_22;
  tmpvar_31.w = (pow ((1.0 - tmpvar_9.y), 0.75) * 7.0);
  vec4 tmpvar_32;
  tmpvar_32 = textureCubeLod (unity_SpecCube, worldNormal_22, tmpvar_31.w);
  vec3 tmpvar_33;
  tmpvar_33 = ((unity_SpecCube_HDR.x * pow (tmpvar_32.w, unity_SpecCube_HDR.y)) * tmpvar_32.xyz);
  if ((unity_SpecCube_BoxMin.w < 0.99999)) {
    vec3 worldNormal_34;
    worldNormal_34 = tmpvar_21;
    if ((unity_SpecCube_ProbePosition1.w > 0.0)) {
      vec3 tmpvar_35;
      tmpvar_35 = normalize(tmpvar_21);
      vec3 tmpvar_36;
      tmpvar_36 = ((unity_SpecCube_BoxMax1.xyz - xlv_TEXCOORD8) / tmpvar_35);
      vec3 tmpvar_37;
      tmpvar_37 = ((unity_SpecCube_BoxMin1.xyz - xlv_TEXCOORD8) / tmpvar_35);
      bvec3 tmpvar_38;
      tmpvar_38 = greaterThan (tmpvar_35, vec3(0.0, 0.0, 0.0));
      float tmpvar_39;
      if (tmpvar_38.x) {
        tmpvar_39 = tmpvar_36.x;
      } else {
        tmpvar_39 = tmpvar_37.x;
      };
      float tmpvar_40;
      if (tmpvar_38.y) {
        tmpvar_40 = tmpvar_36.y;
      } else {
        tmpvar_40 = tmpvar_37.y;
      };
      float tmpvar_41;
      if (tmpvar_38.z) {
        tmpvar_41 = tmpvar_36.z;
      } else {
        tmpvar_41 = tmpvar_37.z;
      };
      vec3 tmpvar_42;
      tmpvar_42 = ((unity_SpecCube_BoxMax1.xyz + unity_SpecCube_BoxMin1.xyz) * 0.5);
      worldNormal_34 = (((
        (tmpvar_42 - unity_SpecCube_ProbePosition1.xyz)
       + xlv_TEXCOORD8) + (tmpvar_35 * 
        min (min (tmpvar_39, tmpvar_40), tmpvar_41)
      )) - tmpvar_42);
    };
    vec4 tmpvar_43;
    tmpvar_43.xyz = worldNormal_34;
    tmpvar_43.w = (pow ((1.0 - tmpvar_9.y), 0.75) * 7.0);
    vec4 tmpvar_44;
    tmpvar_44 = textureCubeLod (unity_SpecCube1, worldNormal_34, tmpvar_43.w);
    tmpvar_18 = mix (((unity_SpecCube_HDR1.x * 
      pow (tmpvar_44.w, unity_SpecCube_HDR1.y)
    ) * tmpvar_44.xyz), tmpvar_33, unity_SpecCube_BoxMin.www);
  } else {
    tmpvar_18 = tmpvar_33;
  };
  tmpvar_18 = (tmpvar_18 * tmpvar_14);
  vec3 viewDir_45;
  viewDir_45 = -(tmpvar_8);
  float tmpvar_46;
  tmpvar_46 = (1.0 - tmpvar_9.y);
  vec3 tmpvar_47;
  tmpvar_47 = normalize((_WorldSpaceLightPos0.xyz + viewDir_45));
  float tmpvar_48;
  tmpvar_48 = max (0.0, dot (tmpvar_7, viewDir_45));
  float tmpvar_49;
  tmpvar_49 = max (0.0, dot (_WorldSpaceLightPos0.xyz, tmpvar_47));
  float tmpvar_50;
  tmpvar_50 = ((tmpvar_46 * tmpvar_46) * 0.797885);
  float tmpvar_51;
  float tmpvar_52;
  tmpvar_52 = (10.0 / log2((
    ((1.0 - tmpvar_46) * 0.968)
   + 0.03)));
  tmpvar_51 = (tmpvar_52 * tmpvar_52);
  float tmpvar_53;
  tmpvar_53 = (0.5 + ((
    (2.0 * tmpvar_49)
   * tmpvar_49) * tmpvar_46));
  vec3 tmpvar_54;
  tmpvar_54 = (((tmpvar_11 * 
    (tmpvar_17 + (tmpvar_16 * ((
      (1.0 + ((tmpvar_53 - 1.0) * pow ((1.0001 - tmpvar_15), 5.0)))
     * 
      (1.0 + ((tmpvar_53 - 1.0) * pow ((1.0001 - tmpvar_48), 5.0)))
    ) * tmpvar_15)))
  ) + (
    ((max (0.0, (
      (((1.0/((
        ((tmpvar_15 * (1.0 - tmpvar_50)) + tmpvar_50)
       * 
        ((tmpvar_48 * (1.0 - tmpvar_50)) + tmpvar_50)
      ))) * (pow (
        max (0.0, dot (tmpvar_7, tmpvar_47))
      , tmpvar_51) * (
        (tmpvar_51 + 1.0)
       / 6.28319))) * tmpvar_15)
     / 4.0)) * 3.14159) * tmpvar_16)
   * 
    (tmpvar_12 + ((1.0 - tmpvar_12) * pow (abs(
      (1.0 - max (0.0, dot (viewDir_45, tmpvar_47)))
    ), 5.0)))
  )) + (tmpvar_18 * mix (tmpvar_12, vec3(
    clamp ((tmpvar_9.y + (1.0 - tmpvar_13)), 0.0, 1.0)
  ), vec3(
    pow (abs((1.0 - tmpvar_48)), 5.0)
  ))));
  vec4 tmpvar_55;
  tmpvar_55.w = 1.0;
  tmpvar_55.xyz = tmpvar_54;
  c_1.w = tmpvar_55.w;
  c_1.xyz = tmpvar_54;
  c_1.xyz = c_1.xyz;
  vec4 xlat_varoutput_56;
  xlat_varoutput_56.xyz = c_1.xyz;
  xlat_varoutput_56.w = 1.0;
  gl_FragData[0] = xlat_varoutput_56;
}