Deband

  • klotim
More
8 years 9 months ago #21 by klotim Replied by klotim on topic Deband
omg, thank you so much! :D

Please Log in or Create an account to join the conversation.

  • JPulowski
  • Topic Author
More
8 years 9 months ago #22 by JPulowski Replied by JPulowski on topic Deband

Martigen wrote: Do we know what other effects Dither make an impact on/is worth enabling the performance hit? I know vignette, but that's about it.

SunBroDave wrote:

Wicked Sick wrote: Guys, can other effects introduce banding?

Yes. Use SweetFX's Dither effect to lessen banding from other effects.

Yes, every effect might introduce banding.

SweetFX's dithering shader only applies dithering to SweetFX's shared shaders.
Which are:
  • Nostalgia
  • Levels
  • Technicolor
  • Technicolor 2
  • DPX
  • Monochrome
  • Color Matrix
  • Lift Gamma Gain
  • Tonemap
  • Vibrance
  • Curves
  • Sepia
  • Filmic Pass
  • Reinhard Linear
  • Vignette
  • Film Grain

It doesn't affect any shader except the ones above. Deband shader has an additional independent dithering option to smooth out the results.

In my tests I found that the optimal position for the deband shader is the first place. But you might play with its position to see how the final image gets affected.

Please Log in or Create an account to join the conversation.

  • Wicked Sick
More
8 years 9 months ago #23 by Wicked Sick Replied by Wicked Sick on topic Deband
So, changing the shaders order will change the final image? I am sure I have read something about this around here, but I feel like dying (flu and stuff) and my brain ins't what it used to be.

Changing the order also affect the FPS?

Please Log in or Create an account to join the conversation.

  • JPulowski
  • Topic Author
More
8 years 9 months ago #24 by JPulowski Replied by JPulowski on topic Deband

Wicked Sick wrote: So, changing the shaders order will change the final image? I am sure I have read something about this around here, but I feel like dying (flu and stuff) and my brain ins't what it used to be.

Changing the order also affect the FPS?

Yes, changing the order might also change the final image. For instance, using Paint shader after LumaSharpen will make LumaSharpen uneffective. Think it as using Photoshop.

And no, there shouldn't be any difference in performance when changing shader order.
The following user(s) said Thank You: Wicked Sick

Please Log in or Create an account to join the conversation.

  • Wicked Sick
More
8 years 9 months ago #25 by Wicked Sick Replied by Wicked Sick on topic Deband
hmmmm Thank you. I didn't know that. I never worried about changing the order. Later, I will try changing the order while playing to see what happens.

Please Log in or Create an account to join the conversation.

  • Arioch
More
8 years 8 months ago #26 by Arioch Replied by Arioch on topic Deband
I would love to try this effect. Currently I am using Reshade to add SweetFX 2.0 in Witcher 3. What would I need to add to my existing installed files to add just the deband effect to my existing SweetFX files?

Thanks!

Please Log in or Create an account to join the conversation.

  • Alo81
More
8 years 8 months ago #27 by Alo81 Replied by Alo81 on topic Deband
This shader is amazing.

It fixed my biggest gripe with The Fall, being the constant horrific banding.

You must view them at full size, as resizing can add additional banding.
Vanilla


Deband + Martins Film Grain


GIGANTIC improvement. Thanks so much OP.
The following user(s) said Thank You: JPulowski

Please Log in or Create an account to join the conversation.

  • JPulowski
  • Topic Author
More
8 years 8 months ago #28 by JPulowski Replied by JPulowski on topic Deband

Arioch wrote: I would love to try this effect. Currently I am using Reshade to add SweetFX 2.0 in Witcher 3. What would I need to add to my existing installed files to add just the deband effect to my existing SweetFX files?

Thanks!

Since ReShade 1.0.0, SweetFX + ReShade bundle is unsupported. I suggest using ReShade Framework if you aren't already using it. Framework includes all the currently available shaders compatible with ReShade.

Adding custom shaders to SweetFX + ReShade bundle is possible but it requires some technical knowledge and some tempering. Like I said using Framework is a lot easier. Just apply your SweetFX preset settings with the mediator then also activate Deband shader from CustomFX section.
The following user(s) said Thank You: Arioch

Please Log in or Create an account to join the conversation.

  • Cloudbill
More
8 years 7 months ago #29 by Cloudbill Replied by Cloudbill on topic Deband
JPulowski, is there any chance you could/would port your Deband script to work with MPC-HC hlsl scripting? I have been looking for a stand alone hlsl deband script for MPC-HC that actually works for a very, very long time?

Please Log in or Create an account to join the conversation.

  • Aelius Maximus
More
8 years 7 months ago #30 by Aelius Maximus Replied by Aelius Maximus on topic Deband

Cloudbill wrote: JPulowski, is there any chance you could/would port your Deband script to work with MPC-HC hlsl scripting? I have been looking for a stand alone hlsl deband script for MPC-HC that actually works for a very, very long time?


ReShade can be injected into MPC-HC using ENB Injector
The following user(s) said Thank You: Cloudbill

Please Log in or Create an account to join the conversation.

  • Cloudbill
More
8 years 7 months ago - 8 years 7 months ago #31 by Cloudbill Replied by Cloudbill on topic Deband

Aelius Maximus wrote:
ReShade can be injected into MPC-HC using ENB Injector


I'm only looking for one single shader script. I don't need or want any of what Reshade can do for video playback. Except of course, the deband shader. It would be needless overkill to use Reshade and a modified ENB injector just for a single shader script. Thanks for the suggestion though.
Last edit: 8 years 7 months ago by Cloudbill.

Please Log in or Create an account to join the conversation.

  • crosire
More
8 years 7 months ago - 8 years 7 months ago #32 by crosire Replied by crosire on topic Deband

Cloudbill wrote: I'm only looking for one single shader script. I don't need or want any of what Reshade can do for video playback. Except of course, the deband shader. It would be needless overkill to use Reshade and a modified ENB injector just for a single shader script. Thanks for the suggestion though.

Not necessarily overkill.
Quick suggestion: You don't need the whole ReShade Framework. You can throw all that away and only use the Deband shader alone with ReShade (remember, ReShade is only the injector, it alone is very lightweight).

Take the "ReShade\CustomFX\Deband.h" file, rename it to "ReShade.fx", delete everything except for the ReShade DLL and put that file right next to it. Then open the file and paste the following at the top (to add the config and fix some variables that are otherwise part of the framework). That's it, now you only have the deband shader alone, ready to be injected into MPC-HC.
// Deband configuration
#define USE_DEBAND 1
#define DEBAND_RADIUS 32.0
#define DEBAND_THRESHOLD 0.017
#define DEBAND_SAMPLE_COUNT 8
#define DEBAND_OFFSET_MODE 3
#define DEBAND_DITHERING 1

// ReShade Framework stuff used in deband shader
#define RFX_Start_Enabled 1
#define RFX_pixelSize float2(BUFFER_RCP_WIDTH, BUFFER_RCP_HEIGHT)
#define RFX_ScreenSize float2(BUFFER_WIDTH, BUFFER_HEIGHT)
texture RFX_backbufferTex : COLOR;
sampler RFX_backbufferColor { Texture = RFX_backbufferTex; };
uniform float RFX_frametime < source = "frametime"; >;
void RFX_VS_PostProcess(uint id : SV_VertexID, out float4 pos : SV_Position, out float2 texcoord : TEXCOORD)
{
	texcoord.x = (id == 2) ? 2.0 : 0.0; texcoord.y = (id == 1) ? 2.0 : 0.0;
	pos = float4(texcoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
}
Last edit: 8 years 7 months ago by crosire.
The following user(s) said Thank You: Cloudbill

Please Log in or Create an account to join the conversation.

  • Cloudbill
More
8 years 7 months ago #33 by Cloudbill Replied by Cloudbill on topic Deband

crosire wrote:

Cloudbill wrote: I'm only looking for one single shader script. I don't need or want any of what Reshade can do for video playback. Except of course, the deband shader. It would be needless overkill to use Reshade and a modified ENB injector just for a single shader script. Thanks for the suggestion though.

Not necessarily overkill.
Quick suggestion: You don't need the whole ReShade Framework. You can throw all that away and only use the Deband shader alone with ReShade (remember, ReShade is only the injector, it alone is very lightweight).

Take the "ReShade\CustomFX\Deband.h" file, rename it to "ReShade.fx", delete everything except for the ReShade DLL and put that file right next to it. Then open the file and paste the following at the top (to add the config and fix some variables that are otherwise part of the framework). That's it, now you only have the deband shader alone, ready to be injected into MPC-HC.
// Deband configuration
#define USE_DEBAND 1
#define DEBAND_RADIUS 32.0
#define DEBAND_THRESHOLD 0.017
#define DEBAND_SAMPLE_COUNT 8
#define DEBAND_OFFSET_MODE 3
#define DEBAND_DITHERING 1

// ReShade Framework stuff used in deband shader
#define RFX_Start_Enabled 1
#define RFX_pixelSize float2(BUFFER_RCP_WIDTH, BUFFER_RCP_HEIGHT)
#define RFX_ScreenSize float2(BUFFER_WIDTH, BUFFER_HEIGHT)
texture RFX_backbufferTex : COLOR;
sampler RFX_backbufferColor { Texture = RFX_backbufferTex; };
uniform float RFX_frametime < source = "frametime"; >;
void RFX_VS_PostProcess(uint id : SV_VertexID, out float4 pos : SV_Position, out float2 texcoord : TEXCOORD)
{
	texcoord.x = (id == 2) ? 2.0 : 0.0; texcoord.y = (id == 1) ? 2.0 : 0.0;
	pos = float4(texcoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
}


The question is, when does the injector inject the deband script? I assume it injects it after MPC-HC has already done what it needs to do. Things like pre-resizing shaders, resizing and post-resizing shaders. With a deband shader it needs to be initiated before resizing.

Please Log in or Create an account to join the conversation.

  • crosire
More
8 years 7 months ago #34 by crosire Replied by crosire on topic Deband

Cloudbill wrote: The question is, when does the injector inject the deband script? I assume it injects it after MPC-HC has already done what it needs to do. Things like pre-resizing shaders, resizing and post-resizing shaders. With a deband shader it needs to be initiated before resizing.

I see. Yeah, it's the last thing to run.

Please Log in or Create an account to join the conversation.

  • JPulowski
  • Topic Author
More
8 years 7 months ago #35 by JPulowski Replied by JPulowski on topic Deband

Cloudbill wrote: JPulowski, is there any chance you could/would port your Deband script to work with MPC-HC hlsl scripting? I have been looking for a stand alone hlsl deband script for MPC-HC that actually works for a very, very long time?

I would not suggest using the Deband shader with MPC-HC. Instead use madVR which has a higher quality deband shader already. Also other than MPC-HC, MPDN has its own deband shader.

Please Log in or Create an account to join the conversation.

  • Cloudbill
More
8 years 7 months ago #36 by Cloudbill Replied by Cloudbill on topic Deband

JPulowski wrote:

Cloudbill wrote: JPulowski, is there any chance you could/would port your Deband script to work with MPC-HC hlsl scripting? I have been looking for a stand alone hlsl deband script for MPC-HC that actually works for a very, very long time?

I would not suggest using the Deband shader with MPC-HC. Instead use madVR which has a higher quality deband shader already. Also other than MPC-HC, MPDN has its own deband shader.


I actually use madVR for most of my video needs. I have a substantial collection of VHS/TIVO rips from 1995-2004. Now these files weren't very high quality to begin with and converting them to .AVI didn't help matters. They need a lot of post processing to clean them up and madVR simply doesn't offer the necessary post processing (Denoising mostly) yet. So I use a forked version of MPC-HC which offers multiple high quality resizers and up to 32 bit dithering. This deviated MPC-HC allows the use of hlsl scripts the same as the main branch. This is why I've been looking for a standalone debanding hlsl script that actually works and doesn't make a blurry mess of things.

Please Log in or Create an account to join the conversation.

  • JPulowski
  • Topic Author
More
8 years 7 months ago #37 by JPulowski Replied by JPulowski on topic Deband

Cloudbill wrote: I actually use madVR for most of my video needs. I have a substantial collection of VHS/TIVO rips from 1995-2004. Now these files weren't very high quality to begin with and converting them to .AVI didn't help matters. They need a lot of post processing to clean them up and madVR simply doesn't offer the necessary post processing (Denoising mostly) yet. So I use a forked version of MPC-HC which offers multiple high quality resizers and up to 32 bit dithering. This deviated MPC-HC allows the use of hlsl scripts the same as the main branch. This is why I've been looking for a standalone debanding hlsl script that actually works and doesn't make a blurry mess of things.

In that case you are always free to use the original Deband shader which was designed for MPC-HC in the first place.
sampler s0 : register(s0);
float4 p0 : register(c0);

#define IMAGE_WIDTH        (p0[0])
#define IMAGE_HEIGHT    (p0[1])

#define RADIUS            16
#define THRESHOLD        (3.0 / 256.0)

#define SAMPLE_COUNT    8        // 1 ... 8
//#define SKIP_THRESHOLD_TEST        // just for testing

/*
    OFFSET_MODE
        1 = cross (axis aligned, fast)
        2 = diagonal (45°, slower)
        3 = box (fully random, much slower)
*/
#define OFFSET_MODE        1

#define OUTPUT_BOOST    1.0
#define OUTPUT_OFFSET    0.0

float rand(float2 pos)
{
     return frac(sin(dot(pos.xy, float2(12.9898, 78.233))) * 43758.5453);
}

bool is_within_threshold(float3 original, float3 other)
{
    return !any(max(abs(original - other) - float3(THRESHOLD, THRESHOLD, THRESHOLD), float3(0, 0, 0)));
}

float4 main(float2 pos0 : TEXCOORD0) : COLOR
{
    float2 step = float2(1.0 / IMAGE_WIDTH, 1.0 / IMAGE_HEIGHT) * RADIUS;
    float2 halfstep = step * 0.5;

    // compute additional sample positions

    float2 seed = pos0 + p0[3]; // no idea what p0[3] is exactly, but it changes every frame, which is what we need...
#if OFFSET_MODE == 1
    float2 offset = float2(rand(seed), 0.0);
#elif OFFSET_MODE == 2
    float2 offset = float2(rand(seed), 0.0);
    offset.y = offset.x;
#elif OFFSET_MODE == 3
    float2 offset = float2(rand(seed), rand(seed + float2(0.1, 0.2)));
#endif

    float2 on[8] = {
        float2( offset.x,  offset.y) * step,
        float2( offset.y, -offset.x) * step,
        float2(-offset.x, -offset.y) * step,
        float2(-offset.y,  offset.x) * step,
        float2( offset.x,  offset.y) * halfstep,
        float2( offset.y, -offset.x) * halfstep,
        float2(-offset.x, -offset.y) * halfstep,
        float2(-offset.y,  offset.x) * halfstep,
        };

    float3 col0 = tex2D(s0, pos0).rgb;
    float4 accu = float4(col0, 1.0);

    for (int i = 0; i < SAMPLE_COUNT; i++)
    {
        float4 cn = float4(tex2D(s0, pos0 + on[i]).rgb, 1.0);
#ifndef SKIP_THRESHOLD_TEST
        if (is_within_threshold(col0, cn.rgb))
#endif
            accu += cn;
    }

    accu.rgb = accu.rgb / accu.a;

    // boost to make it easier to inspect the effect's output
    accu.rgb -= float3(OUTPUT_OFFSET, OUTPUT_OFFSET, OUTPUT_OFFSET);
    accu.rgb *= OUTPUT_BOOST;
    accu.rgb = clamp(accu.rgb, float3(0, 0, 0), float3(1, 1, 1));

    return float4(accu.rgb, 1.0);
}
The following user(s) said Thank You: Cloudbill

Please Log in or Create an account to join the conversation.

  • Cloudbill
More
8 years 7 months ago #38 by Cloudbill Replied by Cloudbill on topic Deband
Hopefully it won't make things a blurry mess. I wasn't even aware that they had a deband shader for MPC-HC. If it is the same one I've run into from time to time it will make a blurry mess. I'll check it when I get home in about an hour and let you know. Thanks for your patience and help.

Please Log in or Create an account to join the conversation.

  • Cloudbill
More
8 years 7 months ago #39 by Cloudbill Replied by Cloudbill on topic Deband
I couldn't see any difference when using Reshade as instructed by crosire. I perceived quite a difference with the shader you posted JPulowski, It doesn't complete blur everything but it still seems to indiscriminately blur a little bit too much for my taste. I guess I'll keep relying on high random dithering to help combat banding. Again, thanks for the help with a non-related gaming issue crosire and JPulowski..

Please Log in or Create an account to join the conversation.

  • Aelius Maximus
More
8 years 7 months ago #40 by Aelius Maximus Replied by Aelius Maximus on topic Deband

Cloudbill wrote: I couldn't see any difference when using Reshade as instructed by crosire. I perceived quite a difference with the shader you posted JPulowski, It doesn't complete blur everything but it still seems to indiscriminately blur a little bit too much for my taste. I guess I'll keep relying on high random dithering to help combat banding. Again, thanks for the help with a non-related gaming issue crosire and JPulowski..


It works, you're obviously not doing something right..

Please Log in or Create an account to join the conversation.

We use cookies
We use cookies on our website. Some of them are essential for the operation of the forum. You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.