198 lines
5.5 KiB
Plaintext
198 lines
5.5 KiB
Plaintext
#include <metal_stdlib>
|
|
#include <simd/simd.h>
|
|
|
|
using namespace metal;
|
|
|
|
struct type_Uniforms
|
|
{
|
|
float4 viewPos;
|
|
float4 lightPosition;
|
|
float4 directionalLight;
|
|
float4 directionalLightColor;
|
|
float2 screenSize;
|
|
float lightPower;
|
|
float time;
|
|
};
|
|
|
|
struct Scene
|
|
{
|
|
float4x4 Model;
|
|
uint textureMode;
|
|
uint pad0;
|
|
uint pad1;
|
|
uint pad2;
|
|
};
|
|
|
|
struct type_StructuredBuffer_Scene
|
|
{
|
|
Scene _m0[1];
|
|
};
|
|
|
|
constant float4 _90 = {};
|
|
constant float3 _92 = {};
|
|
|
|
struct main0_out
|
|
{
|
|
float4 out_var_SV_Target0 [[color(0)]];
|
|
float4 out_var_SV_Target1 [[color(1)]];
|
|
float4 out_var_SV_Target2 [[color(2)]];
|
|
float4 out_var_SV_Target3 [[color(3)]];
|
|
};
|
|
|
|
struct main0_in
|
|
{
|
|
float2 in_var_TEXCOORD0 [[user(locn0)]];
|
|
float3 in_var_TEXCOORD1 [[user(locn1)]];
|
|
float3 in_var_TEXCOORD2 [[user(locn2)]];
|
|
float4 in_var_TEXCOORD3 [[user(locn3)]];
|
|
uint in_var_TEXCOORD4 [[user(locn4)]];
|
|
};
|
|
|
|
fragment main0_out main0(main0_in in [[stage_in]], constant type_Uniforms& Uniforms [[buffer(0)]], const device type_StructuredBuffer_Scene& scene [[buffer(1)]], texture2d<float> Texture0 [[texture(0)]], texture2d<float> Texture1 [[texture(1)]], texture2d<float> Texture2 [[texture(2)]], texture2d<float> DirectionalShadowDepthMap [[texture(3)]], sampler Sampler0 [[sampler(0)]], sampler Sampler1 [[sampler(1)]], sampler Sampler2 [[sampler(2)]], sampler DirectionalShadowSampler [[sampler(3)]])
|
|
{
|
|
main0_out out = {};
|
|
int _101 = int(scene._m0[in.in_var_TEXCOORD4].textureMode);
|
|
int _102 = _101 & 240;
|
|
float4 _136;
|
|
if (_102 == 16)
|
|
{
|
|
float3 _123 = float3(Texture0.sample(Sampler0, in.in_var_TEXCOORD0).x, Texture1.sample(Sampler1, in.in_var_TEXCOORD0).x, Texture2.sample(Sampler2, in.in_var_TEXCOORD0).x) + float3(-0.0625, -0.5, -0.5);
|
|
_136 = float4(dot(_123, float3(1.164000034332275390625, 0.0, 1.7929999828338623046875)), dot(_123, float3(1.164000034332275390625, -0.212999999523162841796875, -0.53299999237060546875)), dot(_123, float3(1.164000034332275390625, 2.111999988555908203125, 0.0)), 1.0);
|
|
}
|
|
else
|
|
{
|
|
float4 _135;
|
|
if (_102 == 0)
|
|
{
|
|
_135 = Texture0.sample(Sampler0, in.in_var_TEXCOORD0);
|
|
}
|
|
else
|
|
{
|
|
_135 = _90;
|
|
}
|
|
_136 = _135;
|
|
}
|
|
float4 _142;
|
|
if ((_101 & 1) == 1)
|
|
{
|
|
_142 = powr(_136, float4(2.2000000476837158203125));
|
|
}
|
|
else
|
|
{
|
|
_142 = _136;
|
|
}
|
|
if (_142.w < 0.00999999977648258209228515625)
|
|
{
|
|
discard_fragment();
|
|
}
|
|
float3 _152 = float3(0.800000011920928955078125, 0.800000011920928955078125, 0.5) * Uniforms.lightPower;
|
|
float3 _199;
|
|
do
|
|
{
|
|
float3 _156 = Uniforms.lightPosition.xyz - in.in_var_TEXCOORD1;
|
|
float _157 = length(_156);
|
|
float _158 = _157 * _157;
|
|
float _164;
|
|
if (_157 > 2.0)
|
|
{
|
|
_164 = 0.5 / _158;
|
|
}
|
|
else
|
|
{
|
|
_164 = 1.0 / _158;
|
|
}
|
|
float _169;
|
|
if (_157 > 4.0)
|
|
{
|
|
_169 = _164 * 0.5;
|
|
}
|
|
else
|
|
{
|
|
_169 = _164;
|
|
}
|
|
float _171 = (_157 > 15.0) ? 0.0 : _169;
|
|
float _173 = (_171 > 1.0) ? 1.0 : _171;
|
|
if (length(in.in_var_TEXCOORD2) < 0.100000001490116119384765625)
|
|
{
|
|
_199 = (in.in_var_TEXCOORD1 * _152) * _173;
|
|
break;
|
|
}
|
|
float3 _180 = fast::normalize(_156);
|
|
_199 = ((_152 * precise::max(dot(_180, in.in_var_TEXCOORD2), 0.0)) * _173) + (((_152 * powr(precise::max(dot(in.in_var_TEXCOORD2, fast::normalize(_180 + fast::normalize(in.in_var_TEXCOORD1 - Uniforms.viewPos.xyz))), 0.0), 30.0)) * 2.0) * _173);
|
|
break;
|
|
} while(false);
|
|
float3 _216 = ((in.in_var_TEXCOORD3.xyz / float3(in.in_var_TEXCOORD3.w)) * 0.5) + float3(0.5);
|
|
float3 _218;
|
|
_218.x = _216.x;
|
|
float2 _219 = _218.xy;
|
|
_219.y = -_216.y;
|
|
float _226;
|
|
int _229;
|
|
int _231;
|
|
_226 = 0.0;
|
|
_229 = 0;
|
|
_231 = -4;
|
|
float _227;
|
|
int _230;
|
|
for (; _231 <= 4; _226 = _227, _229 = _230, _231++)
|
|
{
|
|
_230 = _229;
|
|
_227 = _226;
|
|
for (int _240 = -4; _240 <= 4; )
|
|
{
|
|
_230++;
|
|
_227 += float((in.in_var_TEXCOORD3.z - 0.004999999888241291046142578125) > DirectionalShadowDepthMap.sample(DirectionalShadowSampler, (_219 + float2(float(_240) * 0.000244140625, float(_231) * 0.000244140625))).x);
|
|
_240++;
|
|
continue;
|
|
}
|
|
}
|
|
float3 _269;
|
|
if ((_101 & 2) > 0)
|
|
{
|
|
_269 = _142.xyz * 2.0;
|
|
}
|
|
else
|
|
{
|
|
_269 = _142.xyz * ((float3(0.100000001490116119384765625) + _199) + ((Uniforms.directionalLightColor.xyz * precise::max(dot(Uniforms.directionalLight.xyz, in.in_var_TEXCOORD2), 0.0)) * (1.0 - (_226 / float(_229)))));
|
|
}
|
|
float4 _286;
|
|
if (_269.x > 1.0)
|
|
{
|
|
float4 _285 = float4(0.0, 0.0, 0.0, 1.0);
|
|
_285.x = _269.x;
|
|
_286 = _285;
|
|
}
|
|
else
|
|
{
|
|
_286 = float4(0.0, 0.0, 0.0, 1.0);
|
|
}
|
|
float4 _291;
|
|
if (_269.y > 1.0)
|
|
{
|
|
float4 _290 = _286;
|
|
_290.y = _269.y;
|
|
_291 = _290;
|
|
}
|
|
else
|
|
{
|
|
_291 = _286;
|
|
}
|
|
float4 _296;
|
|
if (_269.z > 1.0)
|
|
{
|
|
float4 _295 = _291;
|
|
_295.z = _269.z;
|
|
_296 = _295;
|
|
}
|
|
else
|
|
{
|
|
_296 = _291;
|
|
}
|
|
out.out_var_SV_Target0 = float4(_269, _142.w);
|
|
out.out_var_SV_Target1 = _296;
|
|
out.out_var_SV_Target2 = float4(in.in_var_TEXCOORD1, 1.0);
|
|
out.out_var_SV_Target3 = float4(in.in_var_TEXCOORD2, 1.0);
|
|
return out;
|
|
}
|
|
|