Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- // ReShade effect file
- // visit facebook.com/MartyMcModding for news/updates
- //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- //bloom shit test
- //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- #include "ReShade.fxh"
- uniform float BLOOM_CONTRAST <
- ui_type = "drag";
- ui_min = 0.00; ui_max = 10.00;
- ui_tooltip = "Bloom : Bloom contrast, higher values restrict bloom to bright areas.";
- > = 1.00;
- uniform float BLOOM_AMOUNT <
- ui_type = "drag";
- ui_min = 0.00; ui_max = 10.00;
- ui_tooltip = "Bloom : Amount of darkening.";
- > = 1.00;
- uniform float BLOOM_MULT_1024 <
- ui_type = "drag";
- ui_min = 0.00; ui_max = 5.00;
- ui_tooltip = "Bloom : Multiplicator of 1024x1024 texture.";
- > = 0.00;
- uniform float BLOOM_MULT_512 <
- ui_type = "drag";
- ui_min = 0.00; ui_max = 5.00;
- ui_tooltip = "Bloom : Multiplicator of 512x512 texture.";
- > = 0.00;
- uniform float BLOOM_MULT_256 <
- ui_type = "drag";
- ui_min = 0.00; ui_max = 5.00;
- ui_tooltip = "Bloom : Multiplicator of 256x256 texture.";
- > = 1.00;
- uniform float BLOOM_MULT_128 <
- ui_type = "drag";
- ui_min = 0.00; ui_max = 5.00;
- ui_tooltip = "Bloom : Multiplicator of 128x128 texture.";
- > = 1.00;
- uniform float BLOOM_MULT_64 <
- ui_type = "drag";
- ui_min = 0.00; ui_max = 5.00;
- ui_tooltip = "Bloom : Multiplicator of 64x64 texture.";
- > = 1.00;
- uniform float BLOOM_MULT_32 <
- ui_type = "drag";
- ui_min = 0.00; ui_max = 5.00;
- ui_tooltip = "Bloom : Multiplicator of 32x32 texture.";
- > = 1.00;
- uniform float BLOOM_BLUR_MULT <
- ui_type = "drag";
- ui_min = 0.00; ui_max = 16.00;
- ui_tooltip = "Bloom : Multiplicator of 32x32 texture.";
- > = 1.00;
- //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- //
- //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- //textures
- texture2D TextureDownsampled {Width = 1024; Height = 1024;Format = RGBA16F;};
- texture2D RenderTarget1024 {Width = 1024; Height = 1024;Format = RGBA16F;};
- texture2D RenderTarget512 {Width = 512; Height = 512; Format = RGBA16F;};
- texture2D RenderTarget256 {Width = 256; Height = 256; Format = RGBA16F;};
- texture2D RenderTarget128 {Width = 128; Height = 128; Format = RGBA16F;};
- texture2D RenderTarget64 {Width = 64; Height = 64; Format = RGBA16F;};
- texture2D RenderTarget32 {Width = 32; Height = 32; Format = RGBA16F; MipLevels = 5;};
- //samplers
- sampler2D sTextureDownsampled { Texture = TextureDownsampled; };
- sampler2D sRenderTarget1024 { Texture = RenderTarget1024; };
- sampler2D sRenderTarget512 { Texture = RenderTarget512; };
- sampler2D sRenderTarget256 { Texture = RenderTarget256; };
- sampler2D sRenderTarget128 { Texture = RenderTarget128; };
- sampler2D sRenderTarget64 { Texture = RenderTarget64; };
- sampler2D sRenderTarget32 { Texture = RenderTarget32; };
- //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- //
- //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- float4 LinearGaussianBlurSmall(sampler2D sRenderTargetX, float2 texcoord, float texSize)
- {
- float offset[3] = { 0.0, 1.3846153846, 3.2307692308 };
- float weight[3] = { 0.2270270270, 0.3162162162, 0.0702702703 };
- float4 tempBloom;
- float2 tempOffset;
- float tempWeight;
- float4 bloom = 0.0;
- float2 SampleRadiusScaled = float2(1.0,ReShade::AspectRatio) * rcp(texSize) * BLOOM_BLUR_MULT;
- [loop]
- for(int x = -2; x <= 2; ++x)
- [loop]
- for(int y = -2; y <= 2; ++y)
- {
- int2 index = abs(int2(x,y));
- tempOffset = texcoord.xy + float2(offset[index.x] * sign(x),offset[index.y] * sign(y)) * SampleRadiusScaled;
- bloom += tex2Dlod(sRenderTargetX, float4(tempOffset.xy,0,0)) * weight[index.x] * weight[index.y];
- }
- return bloom;
- }
- //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- float4 LinearGaussianBlurMedium(sampler2D sRenderTargetX, float2 texcoord, float texSize)
- {
- float offset[6] = { 0.0, 1.4584295168, 3.40398480678, 5.3518057801, 7.302940716, 9.2581597095 };
- float weight[6] = { 0.13298, 0.23227575, 0.1353261595, 0.0511557427, 0.01253922, 0.0019913644 };
- float4 tempBloom;
- float2 tempOffset;
- float tempWeight;
- float4 bloom = 0.0;
- float2 SampleRadiusScaled = float2(1.0,ReShade::AspectRatio) * rcp(texSize) * BLOOM_BLUR_MULT;
- [loop]
- for(int x = -5; x <= 5; ++x)
- [loop]
- for(int y = -5; y <= 5; ++y)
- {
- int2 index = abs(int2(x,y));
- tempOffset = texcoord.xy + float2(offset[index.x] * sign(x),offset[index.y] * sign(y)) * SampleRadiusScaled;
- bloom += tex2Dlod(sRenderTargetX, float4(tempOffset.xy,0,0)) * weight[index.x] * weight[index.y];
- }
- return bloom;
- }
- //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- float4 tex2Dbicub(sampler tex, float2 texcoord, float2 textureDimensions)
- {
- texcoord *= textureDimensions;
- float2 texelCenter = floor(texcoord - 0.5) + 0.5;
- float2 dist1 = texcoord - texelCenter;
- float2 dist2 = dist1 * dist1;
- float2 dist3 = dist1 * dist2;
- float2 weight0 = dist2 - 0.5 * (dist3 + dist1);
- float2 weight1 = 1.5 * dist3 - 2.5 * dist2 + 1.0;
- float2 weight3 = 0.5 * ( dist3 - dist2 );
- float2 weight2 = 1.0 - weight0 - weight1 - weight3;
- float4 scalingFactor01 = float4(weight0 + weight1,weight2 + weight3);
- float4 texCoord01 = texelCenter.xyxy + float4(- 1.0 + weight1 / scalingFactor01.xy,
- 1.0 + weight3 / scalingFactor01.zw);
- texCoord01 /= textureDimensions.xyxy;
- return tex2Dlod(tex, float4(texCoord01.xy, 0,0)) * scalingFactor01.x*scalingFactor01.y +
- tex2Dlod(tex, float4(texCoord01.zy, 0,0)) * scalingFactor01.z*scalingFactor01.y +
- tex2Dlod(tex, float4(texCoord01.xw, 0,0)) * scalingFactor01.x*scalingFactor01.w +
- tex2Dlod(tex, float4(texCoord01.zw, 0,0)) * scalingFactor01.z*scalingFactor01.w;
- }
- //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- //
- //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- void PS_Bloom_ToDownsampled(float4 vpos : SV_Position, float2 texcoord : TEXCOORD, out float4 bloom : SV_Target0)
- {
- float4 scenecolor = tex2D(ReShade::BackBuffer, texcoord.xy);
- bloom = scenecolor;
- bloom.w = max(max(bloom.x,bloom.y),bloom.z);
- bloom.xyz = pow(saturate(bloom.xyz),BLOOM_CONTRAST);
- }
- //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- void PS_Bloom_To1024(float4 vpos : SV_Position, float2 texcoord : TEXCOORD, out float4 bloom : SV_Target0)
- {
- bloom = LinearGaussianBlurSmall(sTextureDownsampled, texcoord.xy, 1024.0);
- }
- void PS_Bloom_To512(float4 vpos : SV_Position, float2 texcoord : TEXCOORD, out float4 bloom : SV_Target0)
- {
- bloom = LinearGaussianBlurSmall(sRenderTarget1024, texcoord.xy, 1024.0);
- }
- void PS_Bloom_To256(float4 vpos : SV_Position, float2 texcoord : TEXCOORD, out float4 bloom : SV_Target0)
- {
- bloom = LinearGaussianBlurMedium(sRenderTarget512, texcoord.xy, 512.0);
- }
- void PS_Bloom_To128(float4 vpos : SV_Position, float2 texcoord : TEXCOORD, out float4 bloom : SV_Target0)
- {
- bloom = LinearGaussianBlurMedium(sRenderTarget256, texcoord.xy, 256.0);
- }
- void PS_Bloom_To64(float4 vpos : SV_Position, float2 texcoord : TEXCOORD, out float4 bloom : SV_Target0)
- {
- bloom = LinearGaussianBlurSmall(sRenderTarget128, texcoord.xy, 128.0);
- }
- void PS_Bloom_To32(float4 vpos : SV_Position, float2 texcoord : TEXCOORD, out float4 bloom : SV_Target0)
- {
- bloom = LinearGaussianBlurSmall(sRenderTarget64, texcoord.xy, 64.0);
- }
- //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- void PS_Bloom_Combine(float4 vpos : SV_Position, float2 texcoord : TEXCOORD, out float4 res : SV_Target0)
- {
- float3 bloom = 0.0;
- float3 color = tex2D(ReShade::BackBuffer, texcoord.xy).xyz;
- float3 bloomTextures[6] = { tex2Dbicub(sRenderTarget1024, texcoord.xy, float2(1024.0,1024.0)).xyz,
- tex2Dbicub(sRenderTarget512, texcoord.xy, float2(512.0,512.0)).xyz,
- tex2Dbicub(sRenderTarget256, texcoord.xy, float2(256.0,256.0)).xyz,
- tex2Dbicub(sRenderTarget128, texcoord.xy, float2(128.0,128.0)).xyz,
- tex2Dbicub(sRenderTarget64, texcoord.xy, float2(64.0,64.0)).xyz,
- tex2Dbicub(sRenderTarget32, texcoord.xy, float2(32.0,32.0)).xyz};
- bloom.xyz = BLOOM_MULT_1024 * bloomTextures[0]
- + BLOOM_MULT_512 * bloomTextures[1]
- + BLOOM_MULT_256 * bloomTextures[2]
- + BLOOM_MULT_128 * bloomTextures[3]
- + BLOOM_MULT_64 * bloomTextures[4]
- + BLOOM_MULT_32 * bloomTextures[5];
- color.xyz *= 1.0 - dot(bloom.xyz,0.333) * BLOOM_AMOUNT;
- //color.xyz = bloom.xyz;
- res.xyz = color.xyz;
- res.w = 1.0;
- }
- //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- //
- //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- technique Bloom
- {
- pass P0
- {
- VertexShader = PostProcessVS;
- PixelShader = PS_Bloom_ToDownsampled;
- RenderTarget0 = TextureDownsampled;
- }
- pass P1
- {
- VertexShader = PostProcessVS;
- PixelShader = PS_Bloom_To1024;
- RenderTarget = RenderTarget1024;
- }
- pass P2
- {
- VertexShader = PostProcessVS;
- PixelShader = PS_Bloom_To512;
- RenderTarget = RenderTarget512;
- }
- pass P3
- {
- VertexShader = PostProcessVS;
- PixelShader = PS_Bloom_To256;
- RenderTarget = RenderTarget256;
- }
- pass P4
- {
- VertexShader = PostProcessVS;
- PixelShader = PS_Bloom_To128;
- RenderTarget = RenderTarget128;
- }
- pass P5
- {
- VertexShader = PostProcessVS;
- PixelShader = PS_Bloom_To64;
- RenderTarget = RenderTarget64;
- }
- pass P6
- {
- VertexShader = PostProcessVS;
- PixelShader = PS_Bloom_To32;
- RenderTarget = RenderTarget32;
- }
- pass Combine
- {
- VertexShader = PostProcessVS;
- PixelShader = PS_Bloom_Combine;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement