summaryrefslogtreecommitdiff
path: root/shaders/unity/56-PBS_Deferred_MRT.shader_test
blob: 48af19f16a93316960cdbf4e36b82457ee1b1a62 (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
# Built-in shader from Unity 5.0.0b19:
# Standard; deferred shading g-buffer (MRT) output pass
# internal variant: DIRLIGHTMAP_OFF DYNAMICLIGHTMAP_OFF LIGHTMAP_OFF _METALLICGLOSSMAP _NORMALMAP
# This shader GLSL dump is put under MIT license
[require]
GLSL >= 1.10

[vertex shader]
uniform vec3 _WorldSpaceCameraPos;
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 vec3 xlv_TEXCOORD6;
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;
  vec3 x2_26;
  vec4 tmpvar_27;
  tmpvar_27 = (tmpvar_15.xyzz * tmpvar_15.yzzx);
  x2_26.x = dot (unity_SHBr, tmpvar_27);
  x2_26.y = dot (unity_SHBg, tmpvar_27);
  x2_26.z = dot (unity_SHBb, tmpvar_27);
  tmpvar_6.xyz = (x2_26 + (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 = tmpvar_8;
}

[fragment shader]
#extension GL_ARB_shader_texture_lod : enable
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 _Color;
uniform sampler2D _MainTex;
uniform sampler2D _BumpMap;
uniform float _BumpScale;
uniform sampler2D _MetallicGlossMap;
uniform sampler2D _OcclusionMap;
uniform float _OcclusionStrength;
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 vec3 xlv_TEXCOORD6;
void main ()
{
  vec3 tmpvar_1;
  vec3 tmpvar_2;
  vec3 tmpvar_3;
  tmpvar_1 = xlv_TEXCOORD2.xyz;
  tmpvar_2 = xlv_TEXCOORD2_1.xyz;
  tmpvar_3 = normalize(xlv_TEXCOORD2_2.xyz);
  mat3 tmpvar_4;
  tmpvar_4[0].x = tmpvar_1.x;
  tmpvar_4[0].y = tmpvar_2.x;
  tmpvar_4[0].z = tmpvar_3.x;
  tmpvar_4[1].x = tmpvar_1.y;
  tmpvar_4[1].y = tmpvar_2.y;
  tmpvar_4[1].z = tmpvar_3.y;
  tmpvar_4[2].x = tmpvar_1.z;
  tmpvar_4[2].y = tmpvar_2.z;
  tmpvar_4[2].z = tmpvar_3.z;
  vec3 normal_5;
  normal_5.xy = ((texture2D (_BumpMap, xlv_TEXCOORD0.xy).wy * 2.0) - 1.0);
  normal_5.xy = (normal_5.xy * _BumpScale);
  normal_5.z = sqrt((1.0 - clamp (
    dot (normal_5.xy, normal_5.xy)
  , 0.0, 1.0)));
  vec3 tmpvar_6;
  tmpvar_6 = normalize((normal_5 * tmpvar_4));
  vec3 tmpvar_7;
  tmpvar_7 = normalize(xlv_TEXCOORD1);
  vec2 tmpvar_8;
  tmpvar_8 = texture2D (_MetallicGlossMap, xlv_TEXCOORD0.xy).xw;
  float tmpvar_9;
  tmpvar_9 = tmpvar_8.y;
  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_8.xxx);
  float tmpvar_13;
  tmpvar_13 = (unity_ColorSpaceDielectricSpec.w - (tmpvar_8.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));
  vec3 tmpvar_15;
  vec3 tmpvar_16;
  tmpvar_16 = vec3(0.0, 0.0, 0.0);
  vec4 tmpvar_17;
  tmpvar_17.w = 1.0;
  tmpvar_17.xyz = tmpvar_6;
  vec3 x1_18;
  x1_18.x = dot (unity_SHAr, tmpvar_17);
  x1_18.y = dot (unity_SHAg, tmpvar_17);
  x1_18.z = dot (unity_SHAb, tmpvar_17);
  tmpvar_15 = (xlv_TEXCOORD5.xyz + x1_18);
  tmpvar_15 = (tmpvar_15 * tmpvar_14);
  vec3 tmpvar_19;
  tmpvar_19 = (tmpvar_7 - (2.0 * (
    dot (tmpvar_6, tmpvar_7)
   * tmpvar_6)));
  vec3 worldNormal_20;
  worldNormal_20 = tmpvar_19;
  if ((unity_SpecCube_ProbePosition.w > 0.0)) {
    vec3 tmpvar_21;
    tmpvar_21 = normalize(tmpvar_19);
    vec3 tmpvar_22;
    tmpvar_22 = ((unity_SpecCube_BoxMax.xyz - xlv_TEXCOORD6) / tmpvar_21);
    vec3 tmpvar_23;
    tmpvar_23 = ((unity_SpecCube_BoxMin.xyz - xlv_TEXCOORD6) / tmpvar_21);
    bvec3 tmpvar_24;
    tmpvar_24 = greaterThan (tmpvar_21, vec3(0.0, 0.0, 0.0));
    float tmpvar_25;
    if (tmpvar_24.x) {
      tmpvar_25 = tmpvar_22.x;
    } else {
      tmpvar_25 = tmpvar_23.x;
    };
    float tmpvar_26;
    if (tmpvar_24.y) {
      tmpvar_26 = tmpvar_22.y;
    } else {
      tmpvar_26 = tmpvar_23.y;
    };
    float tmpvar_27;
    if (tmpvar_24.z) {
      tmpvar_27 = tmpvar_22.z;
    } else {
      tmpvar_27 = tmpvar_23.z;
    };
    vec3 tmpvar_28;
    tmpvar_28 = ((unity_SpecCube_BoxMax.xyz + unity_SpecCube_BoxMin.xyz) * 0.5);
    worldNormal_20 = (((
      (tmpvar_28 - unity_SpecCube_ProbePosition.xyz)
     + xlv_TEXCOORD6) + (tmpvar_21 * 
      min (min (tmpvar_25, tmpvar_26), tmpvar_27)
    )) - tmpvar_28);
  };
  vec4 tmpvar_29;
  tmpvar_29.xyz = worldNormal_20;
  tmpvar_29.w = (pow ((1.0 - tmpvar_8.y), 0.75) * 7.0);
  vec4 tmpvar_30;
  tmpvar_30 = textureCubeLod (unity_SpecCube, worldNormal_20, tmpvar_29.w);
  vec3 tmpvar_31;
  tmpvar_31 = ((unity_SpecCube_HDR.x * pow (tmpvar_30.w, unity_SpecCube_HDR.y)) * tmpvar_30.xyz);
  if ((unity_SpecCube_BoxMin.w < 0.99999)) {
    vec3 worldNormal_32;
    worldNormal_32 = tmpvar_19;
    if ((unity_SpecCube_ProbePosition1.w > 0.0)) {
      vec3 tmpvar_33;
      tmpvar_33 = normalize(tmpvar_19);
      vec3 tmpvar_34;
      tmpvar_34 = ((unity_SpecCube_BoxMax1.xyz - xlv_TEXCOORD6) / tmpvar_33);
      vec3 tmpvar_35;
      tmpvar_35 = ((unity_SpecCube_BoxMin1.xyz - xlv_TEXCOORD6) / tmpvar_33);
      bvec3 tmpvar_36;
      tmpvar_36 = greaterThan (tmpvar_33, vec3(0.0, 0.0, 0.0));
      float tmpvar_37;
      if (tmpvar_36.x) {
        tmpvar_37 = tmpvar_34.x;
      } else {
        tmpvar_37 = tmpvar_35.x;
      };
      float tmpvar_38;
      if (tmpvar_36.y) {
        tmpvar_38 = tmpvar_34.y;
      } else {
        tmpvar_38 = tmpvar_35.y;
      };
      float tmpvar_39;
      if (tmpvar_36.z) {
        tmpvar_39 = tmpvar_34.z;
      } else {
        tmpvar_39 = tmpvar_35.z;
      };
      vec3 tmpvar_40;
      tmpvar_40 = ((unity_SpecCube_BoxMax1.xyz + unity_SpecCube_BoxMin1.xyz) * 0.5);
      worldNormal_32 = (((
        (tmpvar_40 - unity_SpecCube_ProbePosition1.xyz)
       + xlv_TEXCOORD6) + (tmpvar_33 * 
        min (min (tmpvar_37, tmpvar_38), tmpvar_39)
      )) - tmpvar_40);
    };
    vec4 tmpvar_41;
    tmpvar_41.xyz = worldNormal_32;
    tmpvar_41.w = (pow ((1.0 - tmpvar_8.y), 0.75) * 7.0);
    vec4 tmpvar_42;
    tmpvar_42 = textureCubeLod (unity_SpecCube1, worldNormal_32, tmpvar_41.w);
    tmpvar_16 = mix (((unity_SpecCube_HDR1.x * 
      pow (tmpvar_42.w, unity_SpecCube_HDR1.y)
    ) * tmpvar_42.xyz), tmpvar_31, unity_SpecCube_BoxMin.www);
  } else {
    tmpvar_16 = tmpvar_31;
  };
  tmpvar_16 = (tmpvar_16 * tmpvar_14);
  vec4 tmpvar_43;
  tmpvar_43.w = 1.0;
  tmpvar_43.xyz = ((tmpvar_11 * tmpvar_15) + (tmpvar_16 * mix (tmpvar_12, vec3(
    clamp ((tmpvar_8.y + (1.0 - tmpvar_13)), 0.0, 1.0)
  ), vec3(
    pow (abs((1.0 - max (0.0, 
      dot (tmpvar_6, -(tmpvar_7))
    ))), 5.0)
  ))));
  vec4 tmpvar_44;
  tmpvar_44.xyz = tmpvar_11;
  tmpvar_44.w = tmpvar_14;
  vec4 tmpvar_45;
  tmpvar_45.xyz = tmpvar_12;
  tmpvar_45.w = tmpvar_9;
  vec4 tmpvar_46;
  tmpvar_46.w = 1.0;
  tmpvar_46.xyz = ((tmpvar_6 * 0.5) + 0.5);
  vec4 tmpvar_47;
  tmpvar_47.w = 1.0;
  tmpvar_47.xyz = exp2(-(tmpvar_43.xyz));
  gl_FragData[0] = tmpvar_44;
  gl_FragData[1] = tmpvar_45;
  gl_FragData[2] = tmpvar_46;
  gl_FragData[3] = tmpvar_47;
}