199 lines
5.5 KiB
Plaintext
199 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)]];
|
|
float3 in_var_TEXCOORD5 [[user(locn5)]];
|
|
};
|
|
|
|
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 _102 = int(scene._m0[in.in_var_TEXCOORD4].textureMode);
|
|
int _103 = _102 & 240;
|
|
float4 _137;
|
|
if (_103 == 16)
|
|
{
|
|
float3 _124 = 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);
|
|
_137 = float4(dot(_124, float3(1.164000034332275390625, 0.0, 1.7929999828338623046875)), dot(_124, float3(1.164000034332275390625, -0.212999999523162841796875, -0.53299999237060546875)), dot(_124, float3(1.164000034332275390625, 2.111999988555908203125, 0.0)), 1.0);
|
|
}
|
|
else
|
|
{
|
|
float4 _136;
|
|
if (_103 == 0)
|
|
{
|
|
_136 = Texture0.sample(Sampler0, in.in_var_TEXCOORD0);
|
|
}
|
|
else
|
|
{
|
|
_136 = _90;
|
|
}
|
|
_137 = _136;
|
|
}
|
|
float4 _143;
|
|
if ((_102 & 1) == 1)
|
|
{
|
|
_143 = powr(_137, float4(2.2000000476837158203125));
|
|
}
|
|
else
|
|
{
|
|
_143 = _137;
|
|
}
|
|
if (_143.w < 0.00999999977648258209228515625)
|
|
{
|
|
discard_fragment();
|
|
}
|
|
float3 _153 = float3(0.800000011920928955078125, 0.800000011920928955078125, 0.5) * Uniforms.lightPower;
|
|
float3 _200;
|
|
do
|
|
{
|
|
float3 _157 = Uniforms.lightPosition.xyz - in.in_var_TEXCOORD1;
|
|
float _158 = length(_157);
|
|
float _159 = _158 * _158;
|
|
float _165;
|
|
if (_158 > 2.0)
|
|
{
|
|
_165 = 0.5 / _159;
|
|
}
|
|
else
|
|
{
|
|
_165 = 1.0 / _159;
|
|
}
|
|
float _170;
|
|
if (_158 > 4.0)
|
|
{
|
|
_170 = _165 * 0.5;
|
|
}
|
|
else
|
|
{
|
|
_170 = _165;
|
|
}
|
|
float _172 = (_158 > 15.0) ? 0.0 : _170;
|
|
float _174 = (_172 > 1.0) ? 1.0 : _172;
|
|
if (length(in.in_var_TEXCOORD2) < 0.100000001490116119384765625)
|
|
{
|
|
_200 = (in.in_var_TEXCOORD1 * _153) * _174;
|
|
break;
|
|
}
|
|
float3 _181 = fast::normalize(_157);
|
|
_200 = ((_153 * precise::max(dot(_181, in.in_var_TEXCOORD2), 0.0)) * _174) + (((_153 * powr(precise::max(dot(in.in_var_TEXCOORD2, fast::normalize(_181 + fast::normalize(in.in_var_TEXCOORD1 - Uniforms.viewPos.xyz))), 0.0), 30.0)) * 2.0) * _174);
|
|
break;
|
|
} while(false);
|
|
float3 _217 = ((in.in_var_TEXCOORD3.xyz / float3(in.in_var_TEXCOORD3.w)) * 0.5) + float3(0.5);
|
|
float3 _219;
|
|
_219.x = _217.x;
|
|
float2 _220 = _219.xy;
|
|
_220.y = -_217.y;
|
|
float _227;
|
|
int _230;
|
|
int _232;
|
|
_227 = 0.0;
|
|
_230 = 0;
|
|
_232 = -2;
|
|
float _228;
|
|
int _231;
|
|
for (; _232 <= 2; _227 = _228, _230 = _231, _232++)
|
|
{
|
|
_231 = _230;
|
|
_228 = _227;
|
|
for (int _241 = -2; _241 <= 2; )
|
|
{
|
|
_231++;
|
|
_228 += float((in.in_var_TEXCOORD3.z - 0.0030000000260770320892333984375) > DirectionalShadowDepthMap.sample(DirectionalShadowSampler, (_220 + float2(float(_241) * 0.000244140625, float(_232) * 0.000244140625))).x);
|
|
_241++;
|
|
continue;
|
|
}
|
|
}
|
|
float3 _270;
|
|
if ((_102 & 2) > 0)
|
|
{
|
|
_270 = _143.xyz * 2.0;
|
|
}
|
|
else
|
|
{
|
|
_270 = _143.xyz * ((float3(0.100000001490116119384765625) + _200) + ((Uniforms.directionalLightColor.xyz * precise::max(dot(Uniforms.directionalLight.xyz, in.in_var_TEXCOORD2), 0.0)) * (1.0 - (_227 / float(_230)))));
|
|
}
|
|
float4 _287;
|
|
if (_270.x > 1.0)
|
|
{
|
|
float4 _286 = float4(0.0, 0.0, 0.0, 1.0);
|
|
_286.x = _270.x;
|
|
_287 = _286;
|
|
}
|
|
else
|
|
{
|
|
_287 = float4(0.0, 0.0, 0.0, 1.0);
|
|
}
|
|
float4 _292;
|
|
if (_270.y > 1.0)
|
|
{
|
|
float4 _291 = _287;
|
|
_291.y = _270.y;
|
|
_292 = _291;
|
|
}
|
|
else
|
|
{
|
|
_292 = _287;
|
|
}
|
|
float4 _297;
|
|
if (_270.z > 1.0)
|
|
{
|
|
float4 _296 = _292;
|
|
_296.z = _270.z;
|
|
_297 = _296;
|
|
}
|
|
else
|
|
{
|
|
_297 = _292;
|
|
}
|
|
out.out_var_SV_Target0 = float4(_270, _143.w);
|
|
out.out_var_SV_Target1 = _297;
|
|
out.out_var_SV_Target2 = float4(in.in_var_TEXCOORD1, 1.0);
|
|
out.out_var_SV_Target3 = float4(in.in_var_TEXCOORD5, 1.0);
|
|
return out;
|
|
}
|
|
|