194 lines
5.3 KiB
Plaintext
194 lines
5.3 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 _88 = {};
|
|
constant float3 _90 = {};
|
|
|
|
struct main0_out
|
|
{
|
|
float4 out_var_SV_Target0 [[color(0)]];
|
|
float4 out_var_SV_Target1 [[color(1)]];
|
|
};
|
|
|
|
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 _99 = int(scene._m0[in.in_var_TEXCOORD4].textureMode);
|
|
int _100 = _99 & 240;
|
|
float4 _134;
|
|
if (_100 == 16)
|
|
{
|
|
float3 _121 = 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);
|
|
_134 = float4(dot(_121, float3(1.164000034332275390625, 0.0, 1.7929999828338623046875)), dot(_121, float3(1.164000034332275390625, -0.212999999523162841796875, -0.53299999237060546875)), dot(_121, float3(1.164000034332275390625, 2.111999988555908203125, 0.0)), 1.0);
|
|
}
|
|
else
|
|
{
|
|
float4 _133;
|
|
if (_100 == 0)
|
|
{
|
|
_133 = Texture0.sample(Sampler0, in.in_var_TEXCOORD0);
|
|
}
|
|
else
|
|
{
|
|
_133 = _88;
|
|
}
|
|
_134 = _133;
|
|
}
|
|
float4 _140;
|
|
if ((_99 & 1) == 1)
|
|
{
|
|
_140 = powr(_134, float4(2.2000000476837158203125));
|
|
}
|
|
else
|
|
{
|
|
_140 = _134;
|
|
}
|
|
if (_140.w < 0.00999999977648258209228515625)
|
|
{
|
|
discard_fragment();
|
|
}
|
|
float3 _150 = float3(0.800000011920928955078125, 0.800000011920928955078125, 0.5) * Uniforms.lightPower;
|
|
float3 _197;
|
|
do
|
|
{
|
|
float3 _154 = Uniforms.lightPosition.xyz - in.in_var_TEXCOORD1;
|
|
float _155 = length(_154);
|
|
float _156 = _155 * _155;
|
|
float _162;
|
|
if (_155 > 2.0)
|
|
{
|
|
_162 = 0.5 / _156;
|
|
}
|
|
else
|
|
{
|
|
_162 = 1.0 / _156;
|
|
}
|
|
float _167;
|
|
if (_155 > 4.0)
|
|
{
|
|
_167 = _162 * 0.5;
|
|
}
|
|
else
|
|
{
|
|
_167 = _162;
|
|
}
|
|
float _169 = (_155 > 15.0) ? 0.0 : _167;
|
|
float _171 = (_169 > 1.0) ? 1.0 : _169;
|
|
if (length(in.in_var_TEXCOORD2) < 0.100000001490116119384765625)
|
|
{
|
|
_197 = (in.in_var_TEXCOORD1 * _150) * _171;
|
|
break;
|
|
}
|
|
float3 _178 = fast::normalize(_154);
|
|
_197 = ((_150 * precise::max(dot(_178, in.in_var_TEXCOORD2), 0.0)) * _171) + (((_150 * powr(precise::max(dot(in.in_var_TEXCOORD2, fast::normalize(_178 + fast::normalize(in.in_var_TEXCOORD1 - Uniforms.viewPos.xyz))), 0.0), 30.0)) * 2.0) * _171);
|
|
break;
|
|
} while(false);
|
|
float3 _214 = ((in.in_var_TEXCOORD3.xyz / float3(in.in_var_TEXCOORD3.w)) * 0.5) + float3(0.5);
|
|
float3 _216;
|
|
_216.x = _214.x;
|
|
float2 _217 = _216.xy;
|
|
_217.y = -_214.y;
|
|
float _224;
|
|
int _227;
|
|
int _229;
|
|
_224 = 0.0;
|
|
_227 = 0;
|
|
_229 = -4;
|
|
float _225;
|
|
int _228;
|
|
for (; _229 <= 4; _224 = _225, _227 = _228, _229++)
|
|
{
|
|
_228 = _227;
|
|
_225 = _224;
|
|
for (int _238 = -4; _238 <= 4; )
|
|
{
|
|
_228++;
|
|
_225 += float((in.in_var_TEXCOORD3.z - 0.004999999888241291046142578125) > DirectionalShadowDepthMap.sample(DirectionalShadowSampler, (_217 + float2(float(_238) * 0.000244140625, float(_229) * 0.000244140625))).x);
|
|
_238++;
|
|
continue;
|
|
}
|
|
}
|
|
float3 _267;
|
|
if ((_99 & 2) > 0)
|
|
{
|
|
_267 = _140.xyz * 2.0;
|
|
}
|
|
else
|
|
{
|
|
_267 = _140.xyz * ((float3(0.100000001490116119384765625) + _197) + ((Uniforms.directionalLightColor.xyz * precise::max(dot(Uniforms.directionalLight.xyz, in.in_var_TEXCOORD2), 0.0)) * (1.0 - (_224 / float(_227)))));
|
|
}
|
|
float4 _276;
|
|
if (_267.x > 1.0)
|
|
{
|
|
float4 _275 = float4(0.0, 0.0, 0.0, 1.0);
|
|
_275.x = _267.x;
|
|
_276 = _275;
|
|
}
|
|
else
|
|
{
|
|
_276 = float4(0.0, 0.0, 0.0, 1.0);
|
|
}
|
|
float4 _281;
|
|
if (_267.y > 1.0)
|
|
{
|
|
float4 _280 = _276;
|
|
_280.y = _267.y;
|
|
_281 = _280;
|
|
}
|
|
else
|
|
{
|
|
_281 = _276;
|
|
}
|
|
float4 _286;
|
|
if (_267.z > 1.0)
|
|
{
|
|
float4 _285 = _281;
|
|
_285.z = _267.z;
|
|
_286 = _285;
|
|
}
|
|
else
|
|
{
|
|
_286 = _281;
|
|
}
|
|
out.out_var_SV_Target0 = float4(_267, _140.w);
|
|
out.out_var_SV_Target1 = _286;
|
|
return out;
|
|
}
|
|
|