Debian Codegraph @

third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/depth-compare.asm.frag

raw
1 #include <metal_stdlib>
2 #include <simd/simd.h>
3
4 using namespace metal;
5
6 struct type_View
7 {
8 float4x4 View_TranslatedWorldToClip;
9 float4x4 View_WorldToClip;
10 float4x4 View_TranslatedWorldToView;
11 float4x4 View_ViewToTranslatedWorld;
12 float4x4 View_TranslatedWorldToCameraView;
13 float4x4 View_CameraViewToTranslatedWorld;
14 float4x4 View_ViewToClip;
15 float4x4 View_ViewToClipNoAA;
16 float4x4 View_ClipToView;
17 float4x4 View_ClipToTranslatedWorld;
18 float4x4 View_SVPositionToTranslatedWorld;
19 float4x4 View_ScreenToWorld;
20 float4x4 View_ScreenToTranslatedWorld;
21 packed_float3 View_ViewForward;
22 float PrePadding_View_844;
23 packed_float3 View_ViewUp;
24 float PrePadding_View_860;
25 packed_float3 View_ViewRight;
26 float PrePadding_View_876;
27 packed_float3 View_HMDViewNoRollUp;
28 float PrePadding_View_892;
29 packed_float3 View_HMDViewNoRollRight;
30 float PrePadding_View_908;
31 float4 View_InvDeviceZToWorldZTransform;
32 float4 View_ScreenPositionScaleBias;
33 packed_float3 View_WorldCameraOrigin;
34 float PrePadding_View_956;
35 packed_float3 View_TranslatedWorldCameraOrigin;
36 float PrePadding_View_972;
37 packed_float3 View_WorldViewOrigin;
38 float PrePadding_View_988;
39 packed_float3 View_PreViewTranslation;
40 float PrePadding_View_1004;
41 float4x4 View_PrevProjection;
42 float4x4 View_PrevViewProj;
43 float4x4 View_PrevViewRotationProj;
44 float4x4 View_PrevViewToClip;
45 float4x4 View_PrevClipToView;
46 float4x4 View_PrevTranslatedWorldToClip;
47 float4x4 View_PrevTranslatedWorldToView;
48 float4x4 View_PrevViewToTranslatedWorld;
49 float4x4 View_PrevTranslatedWorldToCameraView;
50 float4x4 View_PrevCameraViewToTranslatedWorld;
51 packed_float3 View_PrevWorldCameraOrigin;
52 float PrePadding_View_1660;
53 packed_float3 View_PrevWorldViewOrigin;
54 float PrePadding_View_1676;
55 packed_float3 View_PrevPreViewTranslation;
56 float PrePadding_View_1692;
57 float4x4 View_PrevInvViewProj;
58 float4x4 View_PrevScreenToTranslatedWorld;
59 float4x4 View_ClipToPrevClip;
60 float4 View_TemporalAAJitter;
61 float4 View_GlobalClippingPlane;
62 float2 View_FieldOfViewWideAngles;
63 float2 View_PrevFieldOfViewWideAngles;
64 float4 View_ViewRectMin;
65 float4 View_ViewSizeAndInvSize;
66 float4 View_BufferSizeAndInvSize;
67 float4 View_BufferBilinearUVMinMax;
68 int View_NumSceneColorMSAASamples;
69 float View_PreExposure;
70 float View_OneOverPreExposure;
71 float PrePadding_View_2012;
72 float4 View_DiffuseOverrideParameter;
73 float4 View_SpecularOverrideParameter;
74 float4 View_NormalOverrideParameter;
75 float2 View_RoughnessOverrideParameter;
76 float View_PrevFrameGameTime;
77 float View_PrevFrameRealTime;
78 float View_OutOfBoundsMask;
79 float PrePadding_View_2084;
80 float PrePadding_View_2088;
81 float PrePadding_View_2092;
82 packed_float3 View_WorldCameraMovementSinceLastFrame;
83 float View_CullingSign;
84 float View_NearPlane;
85 float View_AdaptiveTessellationFactor;
86 float View_GameTime;
87 float View_RealTime;
88 float View_DeltaTime;
89 float View_MaterialTextureMipBias;
90 float View_MaterialTextureDerivativeMultiply;
91 uint View_Random;
92 uint View_FrameNumber;
93 uint View_StateFrameIndexMod8;
94 uint View_StateFrameIndex;
95 float View_CameraCut;
96 float View_UnlitViewmodeMask;
97 float PrePadding_View_2164;
98 float PrePadding_View_2168;
99 float PrePadding_View_2172;
100 float4 View_DirectionalLightColor;
101 packed_float3 View_DirectionalLightDirection;
102 float PrePadding_View_2204;
103 float4 View_TranslucencyLightingVolumeMin[2];
104 float4 View_TranslucencyLightingVolumeInvSize[2];
105 float4 View_TemporalAAParams;
106 float4 View_CircleDOFParams;
107 float View_DepthOfFieldSensorWidth;
108 float View_DepthOfFieldFocalDistance;
109 float View_DepthOfFieldScale;
110 float View_DepthOfFieldFocalLength;
111 float View_DepthOfFieldFocalRegion;
112 float View_DepthOfFieldNearTransitionRegion;
113 float View_DepthOfFieldFarTransitionRegion;
114 float View_MotionBlurNormalizedToPixel;
115 float View_bSubsurfacePostprocessEnabled;
116 float View_GeneralPurposeTweak;
117 float View_DemosaicVposOffset;
118 float PrePadding_View_2348;
119 packed_float3 View_IndirectLightingColorScale;
120 float View_HDR32bppEncodingMode;
121 packed_float3 View_AtmosphericFogSunDirection;
122 float View_AtmosphericFogSunPower;
123 float View_AtmosphericFogPower;
124 float View_AtmosphericFogDensityScale;
125 float View_AtmosphericFogDensityOffset;
126 float View_AtmosphericFogGroundOffset;
127 float View_AtmosphericFogDistanceScale;
128 float View_AtmosphericFogAltitudeScale;
129 float View_AtmosphericFogHeightScaleRayleigh;
130 float View_AtmosphericFogStartDistance;
131 float View_AtmosphericFogDistanceOffset;
132 float View_AtmosphericFogSunDiscScale;
133 uint View_AtmosphericFogRenderMask;
134 uint View_AtmosphericFogInscatterAltitudeSampleNum;
135 float4 View_AtmosphericFogSunColor;
136 packed_float3 View_NormalCurvatureToRoughnessScaleBias;
137 float View_RenderingReflectionCaptureMask;
138 float4 View_AmbientCubemapTint;
139 float View_AmbientCubemapIntensity;
140 float View_SkyLightParameters;
141 float PrePadding_View_2488;
142 float PrePadding_View_2492;
143 float4 View_SkyLightColor;
144 float4 View_SkyIrradianceEnvironmentMap[7];
145 float View_MobilePreviewMode;
146 float View_HMDEyePaddingOffset;
147 float View_ReflectionCubemapMaxMip;
148 float View_ShowDecalsMask;
149 uint View_DistanceFieldAOSpecularOcclusionMode;
150 float View_IndirectCapsuleSelfShadowingIntensity;
151 float PrePadding_View_2648;
152 float PrePadding_View_2652;
153 packed_float3 View_ReflectionEnvironmentRoughnessMixingScaleBiasAndLargestWeight;
154 int View_StereoPassIndex;
155 float4 View_GlobalVolumeCenterAndExtent[4];
156 float4 View_GlobalVolumeWorldToUVAddAndMul[4];
157 float View_GlobalVolumeDimension;
158 float View_GlobalVolumeTexelSize;
159 float View_MaxGlobalDistance;
160 float View_bCheckerboardSubsurfaceProfileRendering;
161 packed_float3 View_VolumetricFogInvGridSize;
162 float PrePadding_View_2828;
163 packed_float3 View_VolumetricFogGridZParams;
164 float PrePadding_View_2844;
165 float2 View_VolumetricFogSVPosToVolumeUV;
166 float View_VolumetricFogMaxDistance;
167 float PrePadding_View_2860;
168 packed_float3 View_VolumetricLightmapWorldToUVScale;
169 float PrePadding_View_2876;
170 packed_float3 View_VolumetricLightmapWorldToUVAdd;
171 float PrePadding_View_2892;
172 packed_float3 View_VolumetricLightmapIndirectionTextureSize;
173 float View_VolumetricLightmapBrickSize;
174 packed_float3 View_VolumetricLightmapBrickTexelSize;
175 float View_StereoIPD;
176 float View_IndirectLightingCacheShowFlag;
177 float View_EyeToPixelSpreadAngle;
178 };
179
180 struct type_Globals
181 {
182 float3 SoftTransitionScale;
183 float4x4 ShadowViewProjectionMatrices[6];
184 float InvShadowmapResolution;
185 float ShadowFadeFraction;
186 float ShadowSharpen;
187 float4 LightPositionAndInvRadius;
188 float2 ProjectionDepthBiasParameters;
189 float4 PointLightDepthBiasAndProjParameters;
190 };
191
192 constant float4 _453 = {};
193
194 struct main0_out
195 {
196 float4 out_var_SV_Target0 [[color(0)]];
197 };
198
199 fragment main0_out main0(constant type_View& View [[buffer(0)]], constant type_Globals& _Globals [[buffer(1)]], texture2d<float> SceneTexturesStruct_SceneDepthTexture [[texture(0)]], texture2d<float> SceneTexturesStruct_GBufferATexture [[texture(1)]], texture2d<float> SceneTexturesStruct_GBufferBTexture [[texture(2)]], texture2d<float> SceneTexturesStruct_GBufferDTexture [[texture(3)]], depthcube<float> ShadowDepthCubeTexture [[texture(4)]], texture2d<float> SSProfilesTexture [[texture(5)]], sampler SceneTexturesStruct_SceneDepthTextureSampler [[sampler(0)]], sampler SceneTexturesStruct_GBufferATextureSampler [[sampler(1)]], sampler SceneTexturesStruct_GBufferBTextureSampler [[sampler(2)]], sampler SceneTexturesStruct_GBufferDTextureSampler [[sampler(3)]], sampler ShadowDepthTextureSampler [[sampler(4)]], sampler ShadowDepthCubeTextureSampler [[sampler(5)]], float4 gl_FragCoord [[position]])
200 {
201 main0_out out = {};
202 float2 _114 = gl_FragCoord.xy * View.View_BufferSizeAndInvSize.zw;
203 float4 _118 = SceneTexturesStruct_SceneDepthTexture.sample(SceneTexturesStruct_SceneDepthTextureSampler, _114, level(0.0));
204 float _119 = _118.x;
205 float _133 = ((_119 * View.View_InvDeviceZToWorldZTransform.x) + View.View_InvDeviceZToWorldZTransform.y) + (1.0 / ((_119 * View.View_InvDeviceZToWorldZTransform.z) - View.View_InvDeviceZToWorldZTransform.w));
206 float4 _147 = View.View_ScreenToWorld * float4(((_114 - View.View_ScreenPositionScaleBias.wz) / View.View_ScreenPositionScaleBias.xy) * float2(_133), _133, 1.0);
207 float3 _148 = _147.xyz;
208 float3 _152 = _Globals.LightPositionAndInvRadius.xyz - _148;
209 float _158 = length(_152);
210 bool _160 = (_158 * _Globals.LightPositionAndInvRadius.w) < 1.0;
211 float _207;
212 if (_160)
213 {
214 float3 _165 = abs(_152);
215 float _166 = _165.x;
216 float _167 = _165.y;
217 float _168 = _165.z;
218 float _170 = fast::max(_166, fast::max(_167, _168));
219 int _189;
220 if (_170 == _166)
221 {
222 _189 = (_166 == _152.x) ? 0 : 1;
223 }
224 else
225 {
226 int _185;
227 if (_170 == _167)
228 {
229 _185 = (_167 == _152.y) ? 2 : 3;
230 }
231 else
232 {
233 _185 = (_168 == _152.z) ? 4 : 5;
234 }
235 _189 = _185;
236 }
237 float4 _196 = _Globals.ShadowViewProjectionMatrices[_189] * float4(_147.xyz, 1.0);
238 float _198 = _196.w;
239 _207 = ShadowDepthCubeTexture.sample_compare(ShadowDepthCubeTextureSampler, (_152 / float3(_158)), (_196.z / _198) + ((-_Globals.PointLightDepthBiasAndProjParameters.x) / _198), level(0.0));
240 }
241 else
242 {
243 _207 = 1.0;
244 }
245 float _213 = fast::clamp(((_207 - 0.5) * _Globals.ShadowSharpen) + 0.5, 0.0, 1.0);
246 float _218 = sqrt(mix(1.0, _213 * _213, _Globals.ShadowFadeFraction));
247 float4 _219 = _453;
248 _219.z = _218;
249 float3 _236 = normalize((SceneTexturesStruct_GBufferATexture.sample(SceneTexturesStruct_GBufferATextureSampler, _114, level(0.0)).xyz * float3(2.0)) - float3(1.0));
250 uint _240 = uint(round(SceneTexturesStruct_GBufferBTexture.sample(SceneTexturesStruct_GBufferBTextureSampler, _114, level(0.0)).w * 255.0));
251 bool _248 = (_240 & 15u) == 5u;
252 float _448;
253 if (_248)
254 {
255 float4 _260 = SSProfilesTexture.read(uint2(int3(1, int(uint((select(float4(0.0), SceneTexturesStruct_GBufferDTexture.sample(SceneTexturesStruct_GBufferDTextureSampler, _114, level(0.0)), bool4(!(((_240 & 4294967280u) & 16u) != 0u))).x * 255.0) + 0.5)), 0).xy), 0);
256 float _263 = _260.y * 0.5;
257 float _274 = pow(fast::clamp(dot(-(_152 * float3(rsqrt(dot(_152, _152)))), _236), 0.0, 1.0), 1.0);
258 float _445;
259 if (_160)
260 {
261 float3 _278 = _152 / float3(_158);
262 float3 _280 = normalize(cross(_278, float3(0.0, 0.0, 1.0)));
263 float3 _284 = float3(_Globals.InvShadowmapResolution);
264 float3 _285 = _280 * _284;
265 float3 _286 = cross(_280, _278) * _284;
266 float3 _287 = abs(_278);
267 float _288 = _287.x;
268 float _289 = _287.y;
269 float _290 = _287.z;
270 float _292 = fast::max(_288, fast::max(_289, _290));
271 int _311;
272 if (_292 == _288)
273 {
274 _311 = (_288 == _278.x) ? 0 : 1;
275 }
276 else
277 {
278 int _307;
279 if (_292 == _289)
280 {
281 _307 = (_289 == _278.y) ? 2 : 3;
282 }
283 else
284 {
285 _307 = (_290 == _278.z) ? 4 : 5;
286 }
287 _311 = _307;
288 }
289 float4 _318 = _Globals.ShadowViewProjectionMatrices[_311] * float4(_148 - (_236 * float3(_263)), 1.0);
290 float _323 = _260.x * (10.0 / _Globals.LightPositionAndInvRadius.w);
291 float _329 = (1.0 / (((_318.z / _318.w) * _Globals.PointLightDepthBiasAndProjParameters.z) - _Globals.PointLightDepthBiasAndProjParameters.w)) * _Globals.LightPositionAndInvRadius.w;
292 float _342 = (_329 - ((1.0 / ((float4(ShadowDepthCubeTexture.sample(ShadowDepthTextureSampler, (_278 + (_286 * float3(2.5))), level(0.0))).x * _Globals.PointLightDepthBiasAndProjParameters.z) - _Globals.PointLightDepthBiasAndProjParameters.w)) * _Globals.LightPositionAndInvRadius.w)) * _323;
293 float _364 = (_329 - ((1.0 / ((float4(ShadowDepthCubeTexture.sample(ShadowDepthTextureSampler, ((_278 + (_285 * float3(2.3776409626007080078125))) + (_286 * float3(0.77254199981689453125))), level(0.0))).x * _Globals.PointLightDepthBiasAndProjParameters.z) - _Globals.PointLightDepthBiasAndProjParameters.w)) * _Globals.LightPositionAndInvRadius.w)) * _323;
294 float _387 = (_329 - ((1.0 / ((float4(ShadowDepthCubeTexture.sample(ShadowDepthTextureSampler, ((_278 + (_285 * float3(1.46946299076080322265625))) + (_286 * float3(-2.0225429534912109375))), level(0.0))).x * _Globals.PointLightDepthBiasAndProjParameters.z) - _Globals.PointLightDepthBiasAndProjParameters.w)) * _Globals.LightPositionAndInvRadius.w)) * _323;
295 float _410 = (_329 - ((1.0 / ((float4(ShadowDepthCubeTexture.sample(ShadowDepthTextureSampler, ((_278 + (_285 * float3(-1.46946299076080322265625))) + (_286 * float3(-2.02254199981689453125))), level(0.0))).x * _Globals.PointLightDepthBiasAndProjParameters.z) - _Globals.PointLightDepthBiasAndProjParameters.w)) * _Globals.LightPositionAndInvRadius.w)) * _323;
296 float _433 = (_329 - ((1.0 / ((float4(ShadowDepthCubeTexture.sample(ShadowDepthTextureSampler, ((_278 + (_285 * float3(-2.3776409626007080078125))) + (_286 * float3(0.772543013095855712890625))), level(0.0))).x * _Globals.PointLightDepthBiasAndProjParameters.z) - _Globals.PointLightDepthBiasAndProjParameters.w)) * _Globals.LightPositionAndInvRadius.w)) * _323;
297 _445 = (((((fast::clamp(abs((_342 > 0.0) ? (_342 + _263) : fast::max(0.0, (_342 * _274) + _263)), 0.1500000059604644775390625, 5.0) + 0.25) + (fast::clamp(abs((_364 > 0.0) ? (_364 + _263) : fast::max(0.0, (_364 * _274) + _263)), 0.1500000059604644775390625, 5.0) + 0.25)) + (fast::clamp(abs((_387 > 0.0) ? (_387 + _263) : fast::max(0.0, (_387 * _274) + _263)), 0.1500000059604644775390625, 5.0) + 0.25)) + (fast::clamp(abs((_410 > 0.0) ? (_410 + _263) : fast::max(0.0, (_410 * _274) + _263)), 0.1500000059604644775390625, 5.0) + 0.25)) + (fast::clamp(abs((_433 > 0.0) ? (_433 + _263) : fast::max(0.0, (_433 * _274) + _263)), 0.1500000059604644775390625, 5.0) + 0.25)) * 0.20000000298023223876953125;
298 }
299 else
300 {
301 _445 = 1.0;
302 }
303 _448 = 1.0 - (_445 * 0.20000000298023223876953125);
304 }
305 else
306 {
307 _448 = 1.0;
308 }
309 float4 _451 = float4(float3(1.0).x, float3(1.0).y, _219.z, float3(1.0).z);
310 _451.w = _248 ? sqrt(_448) : _218;
311 out.out_var_SV_Target0 = _451;
312 return out;
313 }
314