summaryrefslogtreecommitdiff
path: root/shaders/unity/57-DeferredDirectional.shader_test
blob: 72946b73d6988a44c1cfce71b1619e62f13ece62 (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
# Built-in shader from Unity 5.0.0b19:
# Hidden/Internal-DeferredShading
# internal variant: DIRECTIONAL SHADOWS_SCREEN
# This shader GLSL dump is put under MIT license
[require]
GLSL >= 1.10

[vertex shader]
uniform vec4 _ProjectionParams;


uniform float _LightAsQuad;
varying vec4 xlv_TEXCOORD0;
varying vec3 xlv_TEXCOORD1;
void main ()
{
  vec4 tmpvar_1;
  tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex);
  vec4 o_2;
  vec4 tmpvar_3;
  tmpvar_3 = (tmpvar_1 * 0.5);
  vec2 tmpvar_4;
  tmpvar_4.x = tmpvar_3.x;
  tmpvar_4.y = (tmpvar_3.y * _ProjectionParams.x);
  o_2.xy = (tmpvar_4 + tmpvar_3.w);
  o_2.zw = tmpvar_1.zw;
  gl_Position = tmpvar_1;
  xlv_TEXCOORD0 = o_2;
  xlv_TEXCOORD1 = mix (((gl_ModelViewMatrix * gl_Vertex).xyz * vec3(-1.0, -1.0, 1.0)), gl_Normal, vec3(_LightAsQuad));
}

[fragment shader]
uniform vec3 _WorldSpaceCameraPos;
uniform vec4 _ProjectionParams;
uniform vec4 _ZBufferParams;
uniform vec4 _LightShadowData;
uniform vec4 unity_ShadowFadeCenterAndType;
uniform sampler2D _CameraDepthTexture;
uniform vec4 _LightDir;
uniform vec4 _LightColor;
uniform mat4 _CameraToWorld;
uniform sampler2D _ShadowMapTexture;
uniform sampler2D _CameraGBufferTexture0;
uniform sampler2D _CameraGBufferTexture1;
uniform sampler2D _CameraGBufferTexture2;
varying vec4 xlv_TEXCOORD0;
varying vec3 xlv_TEXCOORD1;
void main ()
{
  vec3 lightDir_1;
  vec2 tmpvar_2;
  tmpvar_2 = (xlv_TEXCOORD0.xy / xlv_TEXCOORD0.w);
  vec4 tmpvar_3;
  tmpvar_3.w = 1.0;
  tmpvar_3.xyz = ((xlv_TEXCOORD1 * (_ProjectionParams.z / xlv_TEXCOORD1.z)) * (1.0/((
    (_ZBufferParams.x * texture2D (_CameraDepthTexture, tmpvar_2).x)
   + _ZBufferParams.y))));
  vec3 tmpvar_4;
  tmpvar_4 = (_CameraToWorld * tmpvar_3).xyz;
  vec3 tmpvar_5;
  tmpvar_5 = (tmpvar_4 - unity_ShadowFadeCenterAndType.xyz);
  lightDir_1 = -(_LightDir.xyz);
  vec4 tmpvar_6;
  tmpvar_6 = texture2D (_CameraGBufferTexture1, tmpvar_2);
  vec3 tmpvar_7;
  tmpvar_7 = (_LightColor.xyz * clamp ((texture2D (_ShadowMapTexture, tmpvar_2).x + 
    clamp (((mix (tmpvar_3.z, 
      sqrt(dot (tmpvar_5, tmpvar_5))
    , unity_ShadowFadeCenterAndType.w) * _LightShadowData.z) + _LightShadowData.w), 0.0, 1.0)
  ), 0.0, 1.0));
  vec3 tmpvar_8;
  tmpvar_8 = normalize(((texture2D (_CameraGBufferTexture2, tmpvar_2).xyz * 2.0) - 1.0));
  float tmpvar_9;
  tmpvar_9 = max (0.0, dot (tmpvar_8, lightDir_1));
  vec3 viewDir_10;
  viewDir_10 = -(normalize((tmpvar_4 - _WorldSpaceCameraPos)));
  float tmpvar_11;
  tmpvar_11 = (1.0 - tmpvar_6.w);
  vec3 tmpvar_12;
  tmpvar_12 = normalize((lightDir_1 + viewDir_10));
  float tmpvar_13;
  tmpvar_13 = max (0.0, dot (tmpvar_8, viewDir_10));
  float tmpvar_14;
  tmpvar_14 = max (0.0, dot (lightDir_1, tmpvar_12));
  float tmpvar_15;
  tmpvar_15 = ((tmpvar_11 * tmpvar_11) * 0.797885);
  float tmpvar_16;
  float tmpvar_17;
  tmpvar_17 = (10.0 / log2((
    ((1.0 - tmpvar_11) * 0.968)
   + 0.03)));
  tmpvar_16 = (tmpvar_17 * tmpvar_17);
  float tmpvar_18;
  tmpvar_18 = (0.5 + ((
    (2.0 * tmpvar_14)
   * tmpvar_14) * tmpvar_11));
  vec4 tmpvar_19;
  tmpvar_19.w = 1.0;
  tmpvar_19.xyz = ((texture2D (_CameraGBufferTexture0, tmpvar_2).xyz * (tmpvar_7 * 
    (((1.0 + (
      (tmpvar_18 - 1.0)
     * 
      pow ((1.0001 - tmpvar_9), 5.0)
    )) * (1.0 + (
      (tmpvar_18 - 1.0)
     * 
      pow ((1.0001 - tmpvar_13), 5.0)
    ))) * tmpvar_9)
  )) + ((
    (max (0.0, ((
      ((1.0/(((
        (tmpvar_9 * (1.0 - tmpvar_15))
       + tmpvar_15) * (
        (tmpvar_13 * (1.0 - tmpvar_15))
       + tmpvar_15)))) * (pow (max (0.0, 
        dot (tmpvar_8, tmpvar_12)
      ), tmpvar_16) * ((tmpvar_16 + 1.0) / 6.28319)))
     * tmpvar_9) / 4.0)) * 3.14159)
   * tmpvar_7) * (tmpvar_6.xyz + 
    ((1.0 - tmpvar_6.xyz) * pow (abs((1.0 - 
      max (0.0, dot (viewDir_10, tmpvar_12))
    )), 5.0))
  )));
  gl_FragData[0] = exp2(-(tmpvar_19));
}