Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace ShoterXX
- {
- static const uint2 vertexID = uint2(2,1);
- #define fetchAt(COORDS) tex2Dlod(ReShade::BackBuffer, float4(COORDS, 0, 0))
- #define CreateLQTextureLOD(NAME, x, y, lod)\
- \
- texture2D NAME##Tex\
- {\
- Width = ##x;\
- Height = ##y;\
- Format = RGBA8;\
- MipLevels = lod;\
- };\
- \
- sampler2D NAME\
- {\
- Texture = NAME##Tex;\
- };
- #define DoBlurPassOdd(i) \
- pass \
- { \
- VertexShader = ShoterXX::VS_PI_BLUR##i; \
- PixelShader = ShoterXX::PS_PI_BlurPush##i; \
- RenderTarget = ShoterXX::PI_Blur2Tex; \
- }
- #define DoBlurPassEven(i) \
- pass \
- { \
- VertexShader = ShoterXX::VS_PI_BLUR##i; \
- PixelShader = ShoterXX::PS_PI_BlurPull##i; \
- RenderTarget = ShoterXX::PI_BlurTex; \
- }
- #define CreateBlurVertex(i)\
- \
- void VS_PI_BLUR##i(in uint id : SV_VertexID, out float4 position : SV_Position, out float2 xy : TEXCOORD, out float4x4 fetchMatrix : TEXCOORD1)\
- {\
- xy = (id == vertexID) ? 2.0 : 0.0;\
- position = float4(xy * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1);\
- \
- float2 pixOffset = ReShade::PixelSize * (i*i + 0.5) * ppB.y;\
- \
- pixOffset.y *= ((ppB.x + i) % 2) ? -1 : 1;\
- \
- fetchMatrix._11_12_13_14 = float4(xy, 0, 0);\
- fetchMatrix._21_22_23_24 = float4(xy + float2( 0.00000000000, 1.0) * pixOffset, 0, 2);\
- fetchMatrix._31_32_33_34 = float4(xy + float2( 0.86602540378, 0.5) * pixOffset, 0, 2);\
- fetchMatrix._41_42_43_44 = float4(xy + float2(-0.86602540378, 0.5) * pixOffset, 0, 2);\
- }
- #define CreateBlurPassOdd(i)\
- \
- CreateBlurVertex(i)\
- \
- void PS_PI_BlurPush##i(in float4 vpos : SV_Position, in float2 xy : TEXCOORD, in float4x4 fetchMatrix : TEXCOORD1, out float4 put : SV_Target0)\
- {\
- DoBlur(i, PI_Blur, xy, put, fetchMatrix);\
- }
- #define CreateBlurPassEven(i)\
- \
- CreateBlurVertex(i)\
- \
- void PS_PI_BlurPull##i(in float4 vpos : SV_Position, in float2 xy : TEXCOORD, in float4x4 fetchMatrix : TEXCOORD1, out float4 put : SV_Target0)\
- {\
- DoBlur(i, PI_Blur2, xy, put, fetchMatrix);\
- }
- CreateLQTextureLOD(PI_Blur , BUFFER_WIDTH/1.999, BUFFER_HEIGHT/2.002, 3);
- CreateLQTextureLOD(PI_Blur2, BUFFER_WIDTH/2.001, BUFFER_HEIGHT/1.998, 3);
- uniform float2 ppB < source = "pingpong"; min = 0; max = 1; step = 100; >;
- void DoBlur(in int i, in sampler2D tex, in float2 xy, out float4 put, in float4x4 fetchMatrix)
- {
- int j;
- [unroll]
- for(j = 0; j<4; j++)
- fetchMatrix[j] = tex2Dlod(tex, fetchMatrix[j]);
- fetchMatrix._14 = 1 - dot(fetchMatrix._24_34_44 = saturate(1 - abs((put.w = fetchMatrix._14) - fetchMatrix._24_34_44) * 64)/3, 1);
- [unroll]
- for(j = 0; j<4; j++)
- fetchMatrix[j].rgb = pow(fetchMatrix[j].rgb, 8) * fetchMatrix[j].a;
- put.rgb = pow((fetchMatrix._11_12_13 + fetchMatrix._21_22_23) + (fetchMatrix._31_32_33 + fetchMatrix._41_42_43), rcp(8));
- }
- void DoBlurNP(in int i, in sampler2D tex, in float2 xy, out float4 put, in float4x4 fetchMatrix)
- {
- int j;
- [unroll]
- for(j = 0; j<4; j++)
- fetchMatrix[j] = tex2Dlod(tex, fetchMatrix[j]);
- fetchMatrix._14 = 1 - dot(fetchMatrix._24_34_44 = saturate(1 - abs((put.w = fetchMatrix._14) - fetchMatrix._24_34_44) * 64)/3, 1);
- [unroll]
- for(j = 0; j<4; j++)
- fetchMatrix[j].rgb = pow(fetchMatrix[j].rgb, 8) * fetchMatrix[j].a;
- put.rgb = (fetchMatrix._11_12_13 + fetchMatrix._21_22_23) + (fetchMatrix._31_32_33 + fetchMatrix._41_42_43);
- }
- void PS_PI_BlurGet(in float4 vpos : SV_Position, in float2 xy : TEXCOORD, in float4x4 fetchMatrix : TEXCOORD1, out float4 put : SV_Target0)
- {
- float4 curP;
- DoBlurNP(6, PI_Blur, xy, curP, fetchMatrix);
- float2 pixOffset = xy + ReShade::PixelSize * 0.5;
- put = fetchAt(pixOffset);
- put = pow(curP * 0.750 + put * put * 0.250, rcp(8));
- put.a = ReShade::GetLinearizedDepth(pixOffset);
- }
- CreateBlurPassOdd(0)
- CreateBlurPassEven(1)
- CreateBlurPassOdd(2)
- CreateBlurPassEven(3)
- CreateBlurPassOdd(4)
- CreateBlurPassEven(5)
- CreateBlurPassOdd(6)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement