summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/3rdparty/glsl-optimizer/tests/fragment/z-prepasslight-outES3Metal.txt
blob: 57b1c341d4d650dffddaa2a92084410540252b90 (plain) (blame)
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
#include <metal_stdlib>
#pragma clang diagnostic ignored "-Wparentheses-equality"
using namespace metal;
struct xlatMtlShaderInput {
  float4 xlv_TEXCOORD0;
  float3 xlv_TEXCOORD1;
};
struct xlatMtlShaderOutput {
  half4 _fragData [[color(0)]];
};
struct xlatMtlShaderUniform {
  float4x4 _CameraToWorld;
  float4 _LightColor;
  float4x4 _LightMatrix0;
  float4 _LightPos;
  float4 _LightPositionRange;
  float4 _LightShadowData;
  float4 _ProjectionParams;
  float3 _WorldSpaceCameraPos;
  float4 _ZBufferParams;
  float4 unity_LightmapFade;
};
fragment xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]]
  ,   texture2d<half> _CameraDepthTexture [[texture(0)]], sampler _mtlsmp__CameraDepthTexture [[sampler(0)]]
  ,   texture2d<half> _CameraNormalsTexture [[texture(1)]], sampler _mtlsmp__CameraNormalsTexture [[sampler(1)]]
  ,   texturecube<half> _LightTexture0 [[texture(2)]], sampler _mtlsmp__LightTexture0 [[sampler(2)]]
  ,   texture2d<half> _LightTextureB0 [[texture(3)]], sampler _mtlsmp__LightTextureB0 [[sampler(3)]]
  ,   texturecube<half> _ShadowMapTexture [[texture(4)]], sampler _mtlsmp__ShadowMapTexture [[sampler(4)]])
{
  xlatMtlShaderOutput _mtl_o;
  half4 res_1;
  float spec_2;
  half3 h_3;
  float atten_4;
  half3 lightDir_5;
  float3 tolight_6;
  float3 wpos_7;
  float depth_8;
  half3 normal_9;
  half4 nspec_10;
  float2 uv_11;
  uv_11 = (_mtl_i.xlv_TEXCOORD0.xy / _mtl_i.xlv_TEXCOORD0.w);
  half4 tmpvar_12;
  tmpvar_12 = _CameraNormalsTexture.sample(_mtlsmp__CameraNormalsTexture, (float2)(uv_11));
  nspec_10 = tmpvar_12;
  normal_9 = ((nspec_10.xyz * (half)2.0) - (half)1.0);
  normal_9 = normalize(normal_9);
  half4 tmpvar_13;
  tmpvar_13 = _CameraDepthTexture.sample(_mtlsmp__CameraDepthTexture, (float2)(uv_11));
  depth_8 = float(tmpvar_13.x);
  float tmpvar_14;
  tmpvar_14 = (1.0/(((_mtl_u._ZBufferParams.x * depth_8) + _mtl_u._ZBufferParams.y)));
  depth_8 = tmpvar_14;
  float4 tmpvar_15;
  tmpvar_15.w = 1.0;
  tmpvar_15.xyz = ((_mtl_i.xlv_TEXCOORD1 * (_mtl_u._ProjectionParams.z / _mtl_i.xlv_TEXCOORD1.z)) * tmpvar_14);
  wpos_7 = (_mtl_u._CameraToWorld * tmpvar_15).xyz;
  tolight_6 = (wpos_7 - _mtl_u._LightPos.xyz);
  float3 tmpvar_16;
  tmpvar_16 = normalize(tolight_6);
  lightDir_5 = half3(-(tmpvar_16));
  float2 tmpvar_17;
  tmpvar_17 = float2((dot (tolight_6, tolight_6) * _mtl_u._LightPos.w));
  half4 tmpvar_18;
  tmpvar_18 = _LightTextureB0.sample(_mtlsmp__LightTextureB0, (float2)(tmpvar_17));
  atten_4 = float(tmpvar_18.w);
  float mydist_19;
  mydist_19 = (sqrt(dot (tolight_6, tolight_6)) * _mtl_u._LightPositionRange.w);
  mydist_19 = (mydist_19 * 0.97);
  float4 shadowVals_20;
  float3 vec_21;
  vec_21 = (tolight_6 + float3(0.0078125, 0.0078125, 0.0078125));
  float4 packDist_22;
  half4 tmpvar_23;
  tmpvar_23 = _ShadowMapTexture.sample(_mtlsmp__ShadowMapTexture, (float3)(vec_21));
  packDist_22 = float4(tmpvar_23);
  shadowVals_20.x = dot (packDist_22, float4(1.0, 0.00392157, 1.53787e-05, 6.22737e-09));
  float3 vec_24;
  vec_24 = (tolight_6 + float3(-0.0078125, -0.0078125, 0.0078125));
  float4 packDist_25;
  half4 tmpvar_26;
  tmpvar_26 = _ShadowMapTexture.sample(_mtlsmp__ShadowMapTexture, (float3)(vec_24));
  packDist_25 = float4(tmpvar_26);
  shadowVals_20.y = dot (packDist_25, float4(1.0, 0.00392157, 1.53787e-05, 6.22737e-09));
  float3 vec_27;
  vec_27 = (tolight_6 + float3(-0.0078125, 0.0078125, -0.0078125));
  float4 packDist_28;
  half4 tmpvar_29;
  tmpvar_29 = _ShadowMapTexture.sample(_mtlsmp__ShadowMapTexture, (float3)(vec_27));
  packDist_28 = float4(tmpvar_29);
  shadowVals_20.z = dot (packDist_28, float4(1.0, 0.00392157, 1.53787e-05, 6.22737e-09));
  float3 vec_30;
  vec_30 = (tolight_6 + float3(0.0078125, -0.0078125, -0.0078125));
  float4 packDist_31;
  half4 tmpvar_32;
  tmpvar_32 = _ShadowMapTexture.sample(_mtlsmp__ShadowMapTexture, (float3)(vec_30));
  packDist_31 = float4(tmpvar_32);
  shadowVals_20.w = dot (packDist_31, float4(1.0, 0.00392157, 1.53787e-05, 6.22737e-09));
  bool4 tmpvar_33;
  tmpvar_33 = bool4((shadowVals_20 < float4(mydist_19)));
  float4 tmpvar_34;
  tmpvar_34 = _mtl_u._LightShadowData.xxxx;
  float tmpvar_35;
  if (tmpvar_33.x) {
    tmpvar_35 = tmpvar_34.x;
  } else {
    tmpvar_35 = 1.0;
  };
  float tmpvar_36;
  if (tmpvar_33.y) {
    tmpvar_36 = tmpvar_34.y;
  } else {
    tmpvar_36 = 1.0;
  };
  float tmpvar_37;
  if (tmpvar_33.z) {
    tmpvar_37 = tmpvar_34.z;
  } else {
    tmpvar_37 = 1.0;
  };
  float tmpvar_38;
  if (tmpvar_33.w) {
    tmpvar_38 = tmpvar_34.w;
  } else {
    tmpvar_38 = 1.0;
  };
  half4 tmpvar_39;
  tmpvar_39.x = half(tmpvar_35);
  tmpvar_39.y = half(tmpvar_36);
  tmpvar_39.z = half(tmpvar_37);
  tmpvar_39.w = half(tmpvar_38);
  half tmpvar_40;
  tmpvar_40 = dot (tmpvar_39, (half4)float4(0.25, 0.25, 0.25, 0.25));
  atten_4 = (atten_4 * (float)tmpvar_40);
  float4 tmpvar_41;
  tmpvar_41.w = 1.0;
  tmpvar_41.xyz = wpos_7;
  half4 tmpvar_42;
  float3 P_43;
  P_43 = (_mtl_u._LightMatrix0 * tmpvar_41).xyz;
  tmpvar_42 = _LightTexture0.sample(_mtlsmp__LightTexture0, (float3)(P_43));
  atten_4 = (atten_4 * (float)tmpvar_42.w);
  float3 tmpvar_44;
  tmpvar_44 = normalize(((float3)lightDir_5 - normalize(
    (wpos_7 - _mtl_u._WorldSpaceCameraPos)
  )));
  h_3 = half3(tmpvar_44);
  half tmpvar_45;
  tmpvar_45 = pow (max ((half)0.0, dot (h_3, normal_9)), (nspec_10.w * (half)128.0));
  spec_2 = float(tmpvar_45);
  spec_2 = (spec_2 * clamp (atten_4, 0.0, 1.0));
  res_1.xyz = half3((_mtl_u._LightColor.xyz * ((float)max ((half)0.0, 
    dot (lightDir_5, normal_9)
  ) * atten_4)));
  half3 c_46;
  c_46 = half3(_mtl_u._LightColor.xyz);
  res_1.w = half((spec_2 * (float)dot (c_46, (half3)float3(0.22, 0.707, 0.071))));
  float tmpvar_47;
  tmpvar_47 = clamp ((1.0 - (
    (tmpvar_15.z * _mtl_u.unity_LightmapFade.z)
   + _mtl_u.unity_LightmapFade.w)), 0.0, 1.0);
  res_1 = ((half4)((float4)res_1 * tmpvar_47));
  _mtl_o._fragData = exp2(-(res_1));
  return _mtl_o;
}


// stats: 62 alu 8 tex 4 flow
// inputs: 2
//  #0: xlv_TEXCOORD0 (high float) 4x1 [-1]
//  #1: xlv_TEXCOORD1 (high float) 3x1 [-1]
// uniforms: 10 (total size: 256)
//  #0: _CameraToWorld (high float) 4x4 [-1] loc 0
//  #1: _LightColor (high float) 4x1 [-1] loc 64
//  #2: _LightMatrix0 (high float) 4x4 [-1] loc 80
//  #3: _LightPos (high float) 4x1 [-1] loc 144
//  #4: _LightPositionRange (high float) 4x1 [-1] loc 160
//  #5: _LightShadowData (high float) 4x1 [-1] loc 176
//  #6: _ProjectionParams (high float) 4x1 [-1] loc 192
//  #7: _WorldSpaceCameraPos (high float) 3x1 [-1] loc 208
//  #8: _ZBufferParams (high float) 4x1 [-1] loc 224
//  #9: unity_LightmapFade (high float) 4x1 [-1] loc 240
// textures: 5
//  #0: _CameraDepthTexture (low 2d) 0x0 [-1] loc 0
//  #1: _CameraNormalsTexture (low 2d) 0x0 [-1] loc 1
//  #2: _LightTexture0 (low cube) 0x0 [-1] loc 2
//  #3: _LightTextureB0 (low 2d) 0x0 [-1] loc 3
//  #4: _ShadowMapTexture (low cube) 0x0 [-1] loc 4