SSAO blur
This commit is contained in:
parent
cd902baa85
commit
0e5ffc847d
|
|
@ -16,6 +16,34 @@ float3 reinhard2(float3 x) {
|
|||
return x2 / x3;
|
||||
}
|
||||
|
||||
float3 blurSSAO(float2 uv)
|
||||
{
|
||||
const float offset[5] = {0.0, 1.0, 2.0, 3.0, 4.0};
|
||||
const float weight[5] = {0.2270270270, 0.1945945946, 0.1216216216, 0.0540540541, 0.0162162162};
|
||||
|
||||
float3 c = float3(0,0,0); // SsaoTexture.Sample(Sampler2, uv).xyz * weight[0] / 25;
|
||||
|
||||
for(int j = 0; j < 5; j++ )
|
||||
{
|
||||
for(int i = 0; i < 5; i++ )
|
||||
{
|
||||
{
|
||||
float2 uv2 = uv + float2(j - 2.5, i) / 1024;
|
||||
float3 s = SsaoTexture.Sample(Sampler2, uv2).xyz / 50;
|
||||
c += s;
|
||||
}
|
||||
|
||||
{
|
||||
float2 uv2 = uv - float2(j - 2.5, i) / 1024;
|
||||
float3 s = SsaoTexture.Sample(Sampler2, uv2).xyz / 50;
|
||||
c += s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
float3 blur(float2 uv)
|
||||
{
|
||||
const float offset[5] = {0.0, 1.0, 2.0, 3.0, 4.0};
|
||||
|
|
@ -102,9 +130,10 @@ float4 main(float2 UV : TEXCOORD0) : SV_Target0
|
|||
// c = float3(uv.x, uv.y, 0.0);
|
||||
|
||||
// c = SsaoTexture.Sample(Sampler2, uv).x;
|
||||
// float ssao = SsaoTexture.Sample(Sampler2, uv).x;
|
||||
|
||||
float ssao = SsaoTexture.Sample(Sampler2, uv).x;
|
||||
c = ssao * c;
|
||||
float ssao = blurSSAO(uv);
|
||||
c = c * ssao;
|
||||
|
||||
c.x *= 1.0 + 0.000001 * EmissiveTexture.Sample(Sampler1, uv).x;
|
||||
c.x *= 1.0 + 0.000001 * ColorTexture.Sample(Sampler0, uv).x;
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -16,28 +16,44 @@ struct main0_in
|
|||
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 _45 = in.in_var_TEXCOORD0;
|
||||
_45.y = (_45.y * (-1.0)) + 1.0;
|
||||
float4 _53 = ColorTexture.sample(Sampler0, _45);
|
||||
float3 _54 = _53.xyz;
|
||||
float3 _68;
|
||||
int _71;
|
||||
_68 = EmissiveTexture.sample(Sampler1, _45).xyz * 0.2270270287990570068359375;
|
||||
_71 = 0;
|
||||
float3 _69;
|
||||
for (; _71 < 5; _68 = _69, _71++)
|
||||
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++)
|
||||
{
|
||||
_69 = _68;
|
||||
for (int _79 = 0; _79 < 5; )
|
||||
_75 = _74;
|
||||
for (int _85 = 0; _85 < 5; )
|
||||
{
|
||||
float2 _87 = float2(float(_71) - 2.5, float(_79)) * float2(0.001953125);
|
||||
_69 = (_69 + (EmissiveTexture.sample(Sampler1, (_45 + _87)).xyz * float3(0.039999999105930328369140625))) + (EmissiveTexture.sample(Sampler1, (_45 - _87)).xyz * float3(0.039999999105930328369140625));
|
||||
_79++;
|
||||
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 _107 = ((powr((_54 * (float3(1.0) + (_54 * float3(0.00999999977648258209228515625)))) / (float3(1.0) + _54), float3(0.4545454680919647216796875)) + (_68 * 0.0500000007450580596923828125)) * 1.0) * SsaoTexture.sample(Sampler2, _45).x;
|
||||
out.out_var_SV_Target0 = float4(((_107.x * (1.0 + (9.9999999747524270787835121154785e-07 * EmissiveTexture.sample(Sampler1, _45).x))) * (1.0 + (9.9999999747524270787835121154785e-07 * ColorTexture.sample(Sampler0, _45).x))) * (1.0 + (9.9999999747524270787835121154785e-07 * SsaoTexture.sample(Sampler2, _45).x)), _107.yz, 1.0);
|
||||
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 _143 = ((powr((_60 * (float3(1.0) + (_60 * float3(0.00999999977648258209228515625)))) / (float3(1.0) + _60), float3(0.4545454680919647216796875)) + (_74 * 0.0500000007450580596923828125)) * 1.0) * _109.x;
|
||||
out.out_var_SV_Target0 = float4(((_143.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)), _143.yz, 1.0);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Reference in New Issue