Backlog/projects/archive/minimal/content/_shaders/msl/postProc.frag.msl

60 lines
2.4 KiB
Plaintext

#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 out_var_SV_Target0 [[color(0)]];
};
struct main0_in
{
float2 in_var_TEXCOORD0 [[user(locn0)]];
};
fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> ColorTexture [[texture(0)]], texture2d<float> EmissiveTexture [[texture(1)]], texture2d<float> SsaoTexture [[texture(2)]], sampler Sampler0 [[sampler(0)]], sampler Sampler1 [[sampler(1)]], sampler Sampler2 [[sampler(2)]])
{
main0_out out = {};
float2 _51 = in.in_var_TEXCOORD0;
_51.y = (_51.y * (-1.0)) + 1.0;
float4 _59 = ColorTexture.sample(Sampler0, _51);
float3 _60 = _59.xyz;
float3 _74;
int _77;
_74 = EmissiveTexture.sample(Sampler1, _51).xyz * 0.2270270287990570068359375;
_77 = 0;
float3 _75;
for (; _77 < 5; _74 = _75, _77++)
{
_75 = _74;
for (int _85 = 0; _85 < 5; )
{
float2 _93 = float2(float(_77) - 2.5, float(_85)) * float2(0.001953125);
_75 = (_75 + (EmissiveTexture.sample(Sampler1, (_51 + _93)).xyz * float3(0.039999999105930328369140625))) + (EmissiveTexture.sample(Sampler1, (_51 - _93)).xyz * float3(0.039999999105930328369140625));
_85++;
continue;
}
}
float3 _109;
int _112;
_109 = float3(0.0);
_112 = 0;
float3 _110;
for (; _112 < 5; _109 = _110, _112++)
{
_110 = _109;
for (int _120 = 0; _120 < 5; )
{
float2 _128 = float2(float(_112) - 2.5, float(_120)) * float2(0.0009765625);
_110 = (_110 + (SsaoTexture.sample(Sampler2, (_51 + _128)).xyz * float3(0.0199999995529651641845703125))) + (SsaoTexture.sample(Sampler2, (_51 - _128)).xyz * float3(0.0199999995529651641845703125));
_120++;
continue;
}
}
float3 _142 = ((powr((_60 * (float3(1.0) + (_60 * float3(0.00999999977648258209228515625)))) / (float3(1.0) + _60), float3(0.4545454680919647216796875)) + (_74 * 0.0500000007450580596923828125)) * 1.0) * _109;
out.out_var_SV_Target0 = float4(((_142.x * (1.0 + (9.9999999747524270787835121154785e-07 * EmissiveTexture.sample(Sampler1, _51).x))) * (1.0 + (9.9999999747524270787835121154785e-07 * ColorTexture.sample(Sampler0, _51).x))) * (1.0 + (9.9999999747524270787835121154785e-07 * SsaoTexture.sample(Sampler2, _51).x)), _142.yz, 1.0);
return out;
}