Cinematic effects for ReShade

  • Loadus
  • Topic Author
More
5 years 5 months ago #1 by Loadus Cinematic effects for ReShade was created by Loadus
Hoblaa!

Finally took the time to really deep dive into ReShade 3.x. I already had some of my shaders on 2.x but they weren't really optimized or portable in any sense. So I ported the stuff over and rewrote a lot of it while also optimizing the performance for distribution.

Huge kudos for you guys for ReShade, the 3.x was absolutely awesome to work in. o/

So here's a tiny Cinematic effect thingy for you guys - I'd love to get a 'sanity check' on this as I'm doing a lot of crazy stuff in there, like large radius gaussian blurs etc. I ran into a lot of problems with HLSL refusing to compile certain variables (the original code is actually from GLSL, which allows all kinds of volatile things), but it should (maybe) now be ok for release. I would also like to hide some of the variables, like the sampling quality, because the user doesn't really need to touch those (original shader changed the size of the render texture from those, but now they're just stepping values).

I mainly set the parameters for Elite Dangerous and here's what it looks like >> imgur.com/a/6RBr2s9

I'll have to test it out on other games as well and set the default parameters in a way that they're not all over the place. O . <

Here's the shader >>

/*
	PandaFX version 2.0 for ReShade 3.4.1
	by Jukka Korhonen aka Loadus ~ twitter.com/thatbonsaipanda
	November 2018
	jukka.korhonen@gmail.com
	
	Applies cinematic lens effects and color grading.
	Free licence to copy, modify, tweak and publish but
	if you can, give credit. Thanks. o/
	
	- jP
 */

#include "ReShade.fxh"

// ------------------------------------

uniform float Blend_Amount <
	ui_label = "Blend Amount";
	ui_type = "drag";
	ui_min = 0.0;
	ui_max = 1.0;
	ui_tooltip = "Blend the effect with the original image.";
> = 1.0;

// ------------------------------------

uniform bool Enable_Diffusion <
	ui_label = "Enable the lens diffusion effect";
	ui_tooltip = "Enable a light diffusion that emulates the glare of a camera lens.";
> = true;

uniform bool Enable_Bleach_Bypass <
	ui_label = "Enable the 'Bleach Bypass' effect";
	ui_tooltip = "Enable a cinematic contrast effect that emulates a bleach bypass on film. Used a lot in war movies and gives the image a grittier feel.";
> = true;

uniform bool Enable_Static_Dither <
	ui_label = "Static Dither";
	ui_tooltip = "Dither the diffusion. Only applies a static dither image texture.";
> = true;

uniform bool Enable_Dither <
	ui_label = "Dither";
	ui_tooltip = "Dither the final result.";
> = false;


// ------------------------------------

uniform float Contrast_R <
    ui_label = "Contrast (Red)";
	ui_type = "drag";
	ui_min = 0.00001;
	ui_max = 20.0;
	ui_tooltip = "Apply contrast to red.";
> = 4.5;

uniform float Contrast_G <
    ui_label = "Contrast (Green)";
	ui_type = "drag";
	ui_min = 0.00001;
	ui_max = 20.0;
	ui_tooltip = "Apply contrast to green.";
> = 3.0;

uniform float Contrast_B <
    ui_label = "Contrast (Blue)";
	ui_type = "drag";
	ui_min = 0.00001;
	ui_max = 20.0;
	ui_tooltip = "Apply contrast to blue.";
> = 3.0;

uniform float Gamma_R <
    ui_label = "Gamma (Red)";
	ui_type = "drag";
	ui_min = 0.02;
	ui_max = 5.0;
	ui_tooltip = "Apply Gamma to red.";
> = 0.8;

uniform float Gamma_G <
    ui_label = "Gamma (Green)";
	ui_type = "drag";
	ui_min = 0.02;
	ui_max = 5.0;
	ui_tooltip = "Apply Gamma to green.";
> = 0.7;

uniform float Gamma_B <
    ui_label = "Gamma (Blue)";
	ui_type = "drag";
	ui_min = 0.02;
	ui_max = 5.0;
	ui_tooltip = "Apply Gamma to blue.";
> = 0.7;

// ------------------------------------

uniform float Diffusion_1_Amount <
    ui_label = "Diffusion 1 Amount";
	ui_type = "drag";
	ui_min = 0.0;
	ui_max = 1.0;
	ui_tooltip = "Adjust the amount of the first diffusion layer.";
> = 0.5;

uniform float Diffusion_2_Amount <
    ui_label = "Diffusion 2 Amount";
	ui_type = "drag";
	ui_min = 0.0;
	ui_max = 1.0;
	ui_tooltip = "Adjust the amount of the second diffusion layer.";
> = 0.5;

uniform float Diffusion_3_Amount <
    ui_label = "Diffusion 3 Amount";
	ui_type = "drag";
	ui_min = 0.0;
	ui_max = 1.0;
	ui_tooltip = "Adjust the amount of the third diffusion layer.";
> = 1.0;

uniform float Diffusion_1_Radius <
	ui_label = "Diffusion 1 Radius";
	ui_type = "drag";
	ui_min = 5.0;
	ui_max = 20.0;
	ui_tooltip = "Set the radius of the first diffusion layer.";
> = 8.0;

uniform float Diffusion_2_Radius <
	ui_label = "Diffusion 2 Radius";
	ui_type = "drag";
	ui_min = 5.0;
	ui_max = 20.0;
	ui_tooltip = "Set the radius of the second diffusion layer.";
> = 8.0;

uniform float Diffusion_3_Radius <
	ui_label = "Diffusion 3 Radius";
	ui_type = "drag";
	ui_min = 5.0;
	ui_max = 20.0;
	ui_tooltip = "Set the radius of the third diffusion layer.";
> = 16.0;

uniform float Diffusion_1_Gamma <
    ui_label = "Diffusion 1 Gamma";
	ui_type = "drag";
	ui_min = 0.02;
	ui_max = 5.0;
	ui_tooltip = "Apply Gamma to first diffusion layer.";
> = 2.2;

uniform float Diffusion_2_Gamma <
    ui_label = "Diffusion 2 Gamma";
	ui_type = "drag";
	ui_min = 0.02;
	ui_max = 5.0;
	ui_tooltip = "Apply Gamma to second diffusion layer.";
> = 1.3;

uniform float Diffusion_3_Gamma <
    ui_label = "Diffusion 3 Gamma";
	ui_type = "drag";
	ui_min = 0.02;
	ui_max = 5.0;
	ui_tooltip = "Apply Gamma to third diffusion layer.";
> = 1.0;

// ------------------------------------

uniform float Bleach_Bypass_Amount <
	ui_label = "Bleach Bypass Amount";
	ui_type = "drag";
	ui_min = 0.0;
	ui_max = 1.0;
	ui_tooltip = "Adjust the amount of the third diffusion layer.";
> = 0.5;

// ------------------------------------

uniform int Diffusion_1_Quality <
	ui_label = "Diffusion 1 sampling quality";
	// ui_type = "drag";
	// ui_min = 1;
	// ui_max = 64;
	ui_tooltip = "Set the quality of the first diffusion layer. Number is the divider of how many times the texture size is divided in half. Lower number = higher quality, but more processing needed. (No need to adjust this.)";
> = 2;

uniform int Diffusion_2_Quality <
	ui_label = "Diffusion 2 sampling quality";
	// ui_type = "drag";
	// ui_min = 1;
	// ui_max = 64;
	ui_tooltip = "Set the quality of the second diffusion layer. Number is the divider of how many times the texture size is divided in half. Lower number = higher quality, but more processing needed. (No need to adjust this.)";
> = 16;

uniform int Diffusion_3_Quality <
	ui_label = "Diffusion 3 sampling quality";
	// ui_type = "drag";
	// ui_min = 1;
	// ui_max = 64;
	ui_tooltip = "Set the quality of the third diffusion layer. Number is the divider of how many times the texture size is divided in half. Lower number = higher quality, but more processing needed. (No need to adjust this.)";
> = 64;

// ------------------------------------




texture NoiseTex <source = "hd_noise.png"; > { Width = 1920; Height = 1080; Format = RGBA8; };
sampler NoiseSampler { Texture = NoiseTex; };

texture prePassLayer { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA8; };

texture blurLayerHorizontal { Width = BUFFER_WIDTH / 2; Height = BUFFER_HEIGHT / 2; Format = RGBA8; };
texture blurLayerVertical { Width = BUFFER_WIDTH / 2; Height = BUFFER_HEIGHT / 2; Format = RGBA8; };
texture blurLayerHorizontalMedRes { Width = BUFFER_WIDTH / 16; Height = BUFFER_HEIGHT / 16; Format = RGBA8; };
texture blurLayerVerticalMedRes { Width = BUFFER_WIDTH / 16; Height = BUFFER_HEIGHT / 16; Format = RGBA8; };
texture blurLayerHorizontalLoRes { Width = BUFFER_WIDTH / 64; Height = BUFFER_HEIGHT / 64; Format = RGBA8; };
texture blurLayerVerticalLoRes { Width = BUFFER_WIDTH / 64; Height = BUFFER_HEIGHT / 64; Format = RGBA8; };

uniform int framecount < source = "framecount"; >;

sampler2D PFX_PrePassLayer
{
	Texture = prePassLayer;
	MinFilter = LINEAR;
	MagFilter = LINEAR;
	MipFilter = LINEAR;
	AddressU = Clamp;
	AddressV = Clamp;
	SRGBTexture=FALSE;
	MaxMipLevel=0;
	MipMapLodBias=0;	
};

// ------- samplers for large radius blur
sampler2D PFX_blurHorizontalLayer
{
	Texture = blurLayerHorizontal;
	MinFilter = LINEAR;
	MagFilter = LINEAR;
	MipFilter = LINEAR;
	AddressU = Clamp;
	AddressV = Clamp;
	SRGBTexture=FALSE;
	MaxMipLevel=0;
	MipMapLodBias=0;	
};

sampler2D PFX_blurVerticalLayer
{
	Texture = blurLayerVertical;
	MinFilter = LINEAR;
	MagFilter = LINEAR;
	MipFilter = LINEAR;
	AddressU = Clamp;
	AddressV = Clamp;
	SRGBTexture=FALSE;
	MaxMipLevel=0;
	MipMapLodBias=0;	
};

sampler2D PFX_blurHorizontalLayerMedRes
{
	Texture = blurLayerHorizontalMedRes;
	MinFilter = LINEAR;
	MagFilter = LINEAR;
	MipFilter = LINEAR;
	AddressU = Clamp;
	AddressV = Clamp;
	SRGBTexture=FALSE;
	MaxMipLevel=0;
	MipMapLodBias=0;	
};

sampler2D PFX_blurVerticalLayerMedRes
{
	Texture = blurLayerVerticalMedRes;
	MinFilter = LINEAR;
	MagFilter = LINEAR;
	MipFilter = LINEAR;
	AddressU = Clamp;
	AddressV = Clamp;
	SRGBTexture=FALSE;
	MaxMipLevel=0;
	MipMapLodBias=0;	
};

sampler2D PFX_blurHorizontalLayerLoRes
{
	Texture = blurLayerHorizontalLoRes;
	MinFilter = LINEAR;
	MagFilter = LINEAR;
	MipFilter = LINEAR;
	AddressU = Clamp;
	AddressV = Clamp;
	SRGBTexture=FALSE;
	MaxMipLevel=0;
	MipMapLodBias=0;	
};

sampler2D PFX_blurVerticalLayerLoRes
{
	Texture = blurLayerVerticalLoRes;
	MinFilter = LINEAR;
	MagFilter = LINEAR;
	MipFilter = LINEAR;
	AddressU = Clamp;
	AddressV = Clamp;
	SRGBTexture=FALSE;
	MaxMipLevel=0;
	MipMapLodBias=0;	
};


float AdjustableSigmoidCurve (float value, float amount) {

	float curve = 1.0; 

    if (value < 0.5)
    {
        curve = pow(value, amount) * pow(2.0, amount) * 0.5; 
    }
        
    else
    { 	
    	curve = 1.0 - pow(1.0 - value, amount) * pow(2.0, amount) * 0.5; 
    }

    return curve;
}

float Randomize (float2 coord) {
	float noise = (frac(sin(dot(coord, float2(12.9898, 78.233))) * 43758.5453));
	return clamp(noise, 0.0, 1.0);
}

float SigmoidCurve (float value) {
	value = value * 2.0 - 1.0;
	return -value * abs(value) * 0.5 + value + 0.5;	
}

float4 BlurH (sampler input, float2 uv, float radius, float sampling) {


	float2 coordinate = float2(0.0, 0.0);
	float4 A = float4(0.0, 0.0, 0.0, 1.0); 
	float4 C = float4(0.0, 0.0, 0.0, 1.0);
	float weight = 1.0; 
	float width = 1.0 / BUFFER_WIDTH * sampling;					
	float divisor = 0.000001; 

		for (float x = -radius; x <= radius; x++)
		{
			coordinate = uv + float2(x * width, 0.0);
			coordinate = clamp(coordinate, 0.0, 1.0); 
			A = tex2D(input, coordinate);		
				weight = SigmoidCurve(1.0 - (abs(x) / radius));		
				C += A * weight; 		
			divisor += weight;
		}
	
	return C / divisor; 
}

float4 BlurV (sampler input, float2 uv, float radius, float sampling) {

	float2 coordinate = float2(0.0, 0.0);
	float4 A = float4(0.0, 0.0, 0.0, 1.0); 
	float4 C = float4(0.0, 0.0, 0.0, 1.0); 
	float weight = 1.0; 	
	float height = 1.0 / BUFFER_HEIGHT * sampling;					
	float divisor = 0.000001; 
	
		for (float y = -radius; y <= radius; y++)
		{
			coordinate = uv + float2(0.0, y * height);
			coordinate = clamp(coordinate, 0.0, 1.0);		
			A = tex2D(input, coordinate);	
				weight = SigmoidCurve(1.0 - (abs(y) / radius)); 		
				C += A * weight; 		
			divisor += weight;
		}

	return C / divisor; 
}


void PS_PrePass (float4 pos : SV_Position, 
				 float2 uv : TEXCOORD, 
				 out float4 result : SV_Target) 
{

	float4 A = tex2D(ReShade::BackBuffer, uv);
		   A.r = pow(A.r, Gamma_R);
		   A.g = pow(A.g, Gamma_G);
		   A.b = pow(A.b, Gamma_B);
		   A.r = AdjustableSigmoidCurve(A.r, Contrast_R);
		   A.g = AdjustableSigmoidCurve(A.g, Contrast_G);
		   A.b = AdjustableSigmoidCurve(A.b, Contrast_B);
	
	// ------- Change color weights of the final render, similar to a printed film

		A.g = A.g * 0.8 + A.b * 0.2;

		float red = A.r - A.g - A.b;
		float green = A.g - A.r - A.b;
		float blue = A.b - A.r - A.g;

		red = clamp(red, 0.0, 1.0);
		green = clamp(green, 0.0, 1.0);
		blue = clamp(blue, 0.0, 1.0);

		A = A * (1.0 - red * 0.6);
		A = A * (1.0 - green * 0.8);	
		A = A * (1.0 - blue * 0.3);
		
		// A.r = AdjustableSigmoidCurve(A.r, 1.4);
		// A.r = pow(A.r, 1.1);	
		
		result = A;
}


void PS_HorizontalPass (float4 pos : SV_Position, 
						float2 uv : TEXCOORD, out float4 result : SV_Target) 
{
	result = BlurH(PFX_PrePassLayer, uv, Diffusion_1_Radius, Diffusion_1_Quality);
	// result = BlurH(ReShade::BackBuffer, uv, Diffusion_1_Radius, Diffusion_1_Quality);
}

void PS_VerticalPass (float4 pos : SV_Position, 
					  float2 uv : TEXCOORD, out float4 result : SV_Target) 
{
	result = BlurV(PFX_blurHorizontalLayer, uv, Diffusion_1_Radius, Diffusion_1_Quality);
}

void PS_HorizontalPassMedRes (float4 pos : SV_Position, 
						float2 uv : TEXCOORD, out float4 result : SV_Target) 
{
	result = BlurH(PFX_blurVerticalLayer, uv, Diffusion_2_Radius, Diffusion_2_Quality);
}

void PS_VerticalPassMedRes (float4 pos : SV_Position, 
					  float2 uv : TEXCOORD, out float4 result : SV_Target) 
{
	result = BlurV(PFX_blurHorizontalLayerMedRes, uv, Diffusion_2_Radius, Diffusion_2_Quality);
}

void PS_HorizontalPassLoRes (float4 pos : SV_Position, 
						float2 uv : TEXCOORD, out float4 result : SV_Target) 
{
	result = BlurH(PFX_blurVerticalLayerMedRes, uv, Diffusion_3_Radius, Diffusion_3_Quality);
}

void PS_VerticalPassLoRes (float4 pos : SV_Position, 
					  float2 uv : TEXCOORD, out float4 result : SV_Target) 
{
	result = BlurV(PFX_blurHorizontalLayerLoRes, uv, Diffusion_3_Radius, Diffusion_3_Quality);
}




float4 PandaComposition (float4 vpos : SV_Position, 
						 float2 uv : TEXCOORD) : SV_Target 
{
	// ------- Create blurred layers for lens diffusion

		float4 blurLayer;
		float4 blurLayerMedRes;
		float4 blurLayerLoRes;
	
	if (Enable_Diffusion)
	{
		// TODO enable/disable for performance >>
		blurLayer = tex2D(PFX_blurVerticalLayer, uv);
		blurLayerMedRes = tex2D(PFX_blurVerticalLayerMedRes, uv);
		blurLayerLoRes = tex2D(PFX_blurVerticalLayerLoRes, uv);
		

			// ------- Colorize the blur layers

				float4 blurLayerMedResGray = dot(0.3333, blurLayerMedRes.rgb);
				blurLayerMedRes = lerp(blurLayerMedRes, blurLayerMedResGray, 0.75);

				float4 blurLayerLoResGray = dot(0.3333, blurLayerLoRes.rgb);
				blurLayerLoRes = lerp(blurLayerLoRes, blurLayerLoResGray, 0.75);

				// blurLayerMedRes.g *= 0.75;
				// blurLayerMedRes.b *= 0.5;

				// blurLayerLoRes.g *= 0.75;
				// blurLayerLoRes.r *= 0.5;


			// ------- Set blur layer weights

				blurLayer *= Diffusion_1_Amount;
				blurLayerMedRes *= Diffusion_2_Amount;
				blurLayerLoRes *= Diffusion_3_Amount;
			
				blurLayer = pow(blurLayer, Diffusion_1_Gamma);
				blurLayerMedRes = pow(blurLayerMedRes, Diffusion_2_Gamma);
				blurLayerLoRes = pow(blurLayerLoRes, Diffusion_3_Gamma);

		if (Enable_Static_Dither)
		{
			float4 hd_noise = tex2D(NoiseSampler, uv); 

			blurLayer.rgb = 1.0 - (1.0 - (hd_noise.rgb * 0.01)) * (1.0 - blurLayer.rgb);
			blurLayerMedRes.rgb = 1.0 - (1.0 - (hd_noise.rgb * 0.01)) * (1.0 - blurLayerMedRes.rgb);
			blurLayerLoRes.rgb = 1.0 - (1.0 - (hd_noise.rgb * 0.01)) * (1.0 - blurLayerLoRes.rgb);
		}

	}


	// ------- Read original image

		float4 A = tex2D(PFX_PrePassLayer, uv);
		float4 O = tex2D(ReShade::BackBuffer, uv);


	// ------- Screen blend the blur layers to create lens diffusion

		if (Enable_Diffusion) 
		{
			blurLayer = clamp(blurLayer, 0.0, 1.0);
			blurLayerMedRes = clamp(blurLayerMedRes, 0.0, 1.0);
			blurLayerLoRes = clamp(blurLayerLoRes, 0.0, 1.0);

	 		A.rgb = 1.0 - (1.0 - blurLayer.rgb) * (1.0 - A.rgb);
			A.rgb = 1.0 - (1.0 - blurLayerMedRes.rgb) * (1.0 - A.rgb);
			A.rgb = 1.0 - (1.0 - blurLayerLoRes.rgb) * (1.0 - A.rgb);
		}


	// ------ Compress contrast using Hard Light blending ------
		
		if (Enable_Bleach_Bypass)
		{
			float Ag = dot(float3(0.3333, 0.3333, 0.3333), A.rgb);
			float4 B = A;
			float4 C = 0;

			if (Ag > 0.5)
			{
				C = 1 - 2 * (1 - Ag) * (1 - B);
			}

			else
			{
				C = 2 * Ag * B;
			}

			C = pow(C, 0.6);
			A = lerp(A, C, Bleach_Bypass_Amount);
		}





	// ------ Compress to TV levels if needed ------
		
		// A = A * 0.9373 + 0.0627;

	// ------ Create noise for dark level dither (heavy processing!) ------
		
		if (Enable_Dither)
		{
			float rndSample = tex2D(NoiseSampler, uv);
			float uvRnd = Randomize(rndSample * framecount);
			float uvRnd2 = Randomize(rndSample * framecount + 1);

			float Nt = tex2D(NoiseSampler, uv * uvRnd);
			float Nt2 = tex2D(NoiseSampler, uv * uvRnd2);

			A -= Nt2 * 0.04;
			A += Nt * 0.04;
		}

		A = lerp(O, A, Blend_Amount);

	return A;
}

technique PandaFX 
{
		pass PreProcess	
		{
			VertexShader = PostProcessVS;
			PixelShader = PS_PrePass;
			RenderTarget = prePassLayer;
		}

		pass HorizontalPass
		{
			VertexShader = PostProcessVS;
			PixelShader = PS_HorizontalPass;
			RenderTarget = blurLayerHorizontal;
		}

		pass VerticalPass
		{
			VertexShader = PostProcessVS;
			PixelShader = PS_VerticalPass;
			RenderTarget = blurLayerVertical;
		}

		pass HorizontalPassMedRes
		{
			VertexShader = PostProcessVS;
			PixelShader = PS_HorizontalPassMedRes;
			RenderTarget = blurLayerHorizontalMedRes;
		}

		pass VerticalPassMedRes
		{
			VertexShader = PostProcessVS;
			PixelShader = PS_VerticalPassMedRes;
			RenderTarget = blurLayerVerticalMedRes;
		}

		pass HorizontalPassLoRes
		{
			VertexShader = PostProcessVS;
			PixelShader = PS_HorizontalPassLoRes;
			RenderTarget = blurLayerHorizontalLoRes;
		}

		pass VerticalPassLoRes
		{
			VertexShader = PostProcessVS;
			PixelShader = PS_VerticalPassLoRes;
			RenderTarget = blurLayerVerticalLoRes;
		}

	pass CustomPass
	{
		VertexShader = PostProcessVS;
		PixelShader = PandaComposition ;
	}
}
The following user(s) said Thank You: Wicked Sick, Kleio420, klotim, Deathmedic, WalterDasTrevas, Marty, Arkane, Daodan

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

  • Tojkar
More
5 years 5 months ago #2 by Tojkar Replied by Tojkar on topic Cinematic effects for ReShade
Definitely interesting shader based on a quick test in ACD. However, the default values definitely needs some tweaking. Currently the overblown whites will burn your face, if you watch the screen without any protection.

I haven't playd Elite, but from your screenshots it looks like it's vanilla color palette is almost absent from whites so it might be impossible to config it to sensible values using that game. But still, I'll definitely add this to my arsenal.

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

  • Loadus
  • Topic Author
More
5 years 5 months ago #3 by Loadus Replied by Loadus on topic Cinematic effects for ReShade
Yup, tested it with Mass Effect Andromeda, No Man's Sky and Elite's beta (which has much more 'brighter' rendering now) and the defaults are really too harsh.

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

  • Arkane
More
5 years 5 months ago #4 by Arkane Replied by Arkane on topic Cinematic effects for ReShade
Hi, I really wanted to look at your work, but I get an error when Reshade trying to load a shader :с. Maybe there are some solutions??

Warning: Spoiler!

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

  • OtisInf
More
5 years 5 months ago #5 by OtisInf Replied by OtisInf on topic Cinematic effects for ReShade
@Loadus, @Arkane, the shader has some bugs it seems. It does at line 578

float rndSample = tex2D(NoiseSampler, uv);

but tex2D returns a float4 by default without swizzle (.rgb like suffix). It's really odd that this has worked at all, as rndSample is passed to Randomize which expects.... a float2.

@Loadus, you're sure you uploaded the right version of the shader source? :) (as it indeed has some issues)

Some tips: (haven't looked at it running yet, just the code)
Also, try to look into adding ui_step for the variables to make sure using the UI is more user friendly so dragging increases/decreases values more smoothly.

You also don't need to specify all sampler variables, most of what you specify are the defaults. See:
github.com/crosire/reshade-shaders/blob/master/REFERENCE.md

You can also categorize UI variables/uniforms, with ui_category so you can e.g. use that to create a category 'Advanced' for the settings you don't want every user to bother with. If you want to completely hide them, you can e.g. define a constant and comment it out by default: (and uncomment it when you need it during development). Define it at the top
// #define DEBUG 1
and then where needed add an #ifdef DEBUG #endif combo to allow the extra uniforms/code when needed (e.g. during development, where you uncomment that line) but a user normally doesn't have these activated as the line is by default commented out.
The following user(s) said Thank You: 5Alex, Loadus

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

  • Loadus
  • Topic Author
More
5 years 5 months ago #6 by Loadus Replied by Loadus on topic Cinematic effects for ReShade
There's possibly loads of errors in there, I'm not a programmer, I struggled for many years to come up with a good blur algorithm that I can do blooms and other effects with on the GPU. :D

ui_step sounds nice, I have no idea what the possible variables are as I didn't find documentation for the stuff (which you linked, nice nice). I stole most of the UI stuff from other shaders and learned from there.

The sampler declaration stuff was mostly for debug purposes, on some GPUs I ran into some interesting effects. :D

Can't use a constant on the last three values, they break the for loop in the blur algorithm (which is no biggie, could always hardcode the values).

Excellent tips, thank you so much! o/

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

  • Deathmedic
More
5 years 5 months ago #7 by Deathmedic Replied by Deathmedic on topic Cinematic effects for ReShade
seems to work nicely got a lot of errors but none of them were red.

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

  • OtisInf
More
5 years 5 months ago #8 by OtisInf Replied by OtisInf on topic Cinematic effects for ReShade
@deadmedic: you tried it out in an opengl game or dx9 game? I'm curious as I can't imagine it would work at all but some people clearly have it working. Will try it out tomorrow as well to see for myself, perhaps I'm overlooking something :)

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

  • Apocalypso
More
5 years 5 months ago #9 by Apocalypso Replied by Apocalypso on topic Cinematic effects for ReShade
It doesn't work for me on Gw2 (dx9).

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

  • OtisInf
More
5 years 5 months ago - 5 years 5 months ago #10 by OtisInf Replied by OtisInf on topic Cinematic effects for ReShade
Ah I see it compiles but with warnings. No surprises there. Will see if I can clean it up.

(edit) Oh this is a neat shader! Lots of things can be improved here and there. I won't go too far, it's your code after all, but will try to make the UI a bit easier to understand/use, remove redundant code, add division by zero protection and clean up the code a bit. Will post a gist on github with the new code when I'm done, you then have to decide what to do with it: add it to the repo or keep it here :)

The coding styles differ a lot per section, you wrote this all yourself (no shame in copy/pasting code that can be copy/pasted!) or is it old/new code combined?
Last edit: 5 years 5 months ago by OtisInf.

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

  • OtisInf
More
5 years 5 months ago #11 by OtisInf Replied by OtisInf on topic Cinematic effects for ReShade
Optimized it a bit (removed several if statements, removed redundant arithmetic etc.), cleaned it up, made sure it works on dx9 (tex2D vs tex2Dlod) , removed the warnings, reordered/updated the UI elements/uniforms. Changed the defaults as well, as they were a bit erm... harsh ;).

See: gist.github.com/FransBouma/32c384f17e5fca1af64c9da5bd398117

Shader looks very useful, I'll use it a lot I think, as it gives great power over tweaking the final image. Combined with cinematic DOF in UE4 demo app 'Mobile':

OFF:


ON:


So, what do you want to do, merge it with the github repo? tweak it a bit more? If you need help with getting the shader admitted into the main repo: just create a fork of the shader repository, clone it to disk, copy the file into the folder, commit (e.g. using Github For Windows, it makes it really easy), and create a Pull request. If that's all noise to you, I can add it for you, full credit to you of course :)
The following user(s) said Thank You: Kleio420, klotim, Apocalypso, Deathmedic, WalterDasTrevas, Marty, Arkane, Loadus

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

  • Deathmedic
More
5 years 5 months ago #12 by Deathmedic Replied by Deathmedic on topic Cinematic effects for ReShade
dx11 i've been using it with fallout 4.

I haven't really used the latest reshade with it, as my fallout 4 install is on 3.0.8 .. which is quite old.

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

  • Loadus
  • Topic Author
More
5 years 5 months ago - 5 years 5 months ago #13 by Loadus Replied by Loadus on topic Cinematic effects for ReShade
Yes, feel free to add the shader to GitHub etc.

Most of the processing code is from my own stash at ShaderToy >> www.shadertoy.com/user/Loadus

But the structure of the shader is stolen directly from a ReShade shader (I can't remember which one). :D

EDIT: Latest version I have installed is >> pastebin.com/L8tv3R4j
Last edit: 5 years 5 months ago by Loadus. Reason: added link to pastebin
The following user(s) said Thank You: Marty

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

  • Daodan
More
5 years 5 months ago #14 by Daodan Replied by Daodan on topic Cinematic effects for ReShade
@Loadus
You could add a couple of \n's to the longer tooltip strings so they look a bit tidier in code and the UI:
ui_tooltip = "Enable a light diffusion that\n"
             "emulates the glare of a camera lens.";

ui_tooltip = "Enable a cinematic contrast effect\n"
             "that emulates a bleach bypass on film.\n"
             "Used a lot in war movies and gives\n"
             "the image a grittier feel.";

ui_tooltip = "Set the quality of the first diffusion layer.\n"
             "Number is the divider of how many times the\n"
             "texture size is divided in half.\n"
             "Lower number = higher quality, but more\n"
             "processing needed. (No need to adjust this.)";
The following user(s) said Thank You: Loadus

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

  • Kleio420
More
5 years 5 months ago #15 by Kleio420 Replied by Kleio420 on topic Cinematic effects for ReShade
like this a lot actually pretty simple group of settings that change the look of the scene a lot

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

  • ctech
More
5 years 5 months ago #16 by ctech Replied by ctech on topic Cinematic effects for ReShade
I use reshade in ED and SC (star citizen). I liked this effect, is there a tutorial or explanation on how to apply it?

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

  • Dazaster
More
5 years 4 months ago #17 by Dazaster Replied by Dazaster on topic Cinematic effects for ReShade
Hey there, been using this the last few days for GTA V and Fallout 4. Really like it. Now with the release of Reshade 4.0.0 I get "reshade-shaders\Shaders\pandafx.fx(529, 19): warning X3206: implicit truncation of vector type" a couple of times. Still working though. Also, are you planning on making an hd_noise.png available at any time? I made my own, but I'm sure some people can't, or won't.

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

  • Daodan
More
5 years 4 months ago #18 by Daodan Replied by Daodan on topic Cinematic effects for ReShade
You can find the hd_noise.png in the last image of the link he provided:

Loadus wrote: I mainly set the parameters for Elite Dangerous and here's what it looks like >> imgur.com/a/6RBr2s9

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

  • Marot
More
5 years 2 months ago - 4 years 10 months ago #19 by Marot Replied by Marot on topic Cinematic effects for ReShade
I'm not the author obviously, but I went ahead and fixed those warnings as I've been playing with this shader quite a lot myself recently.
Last edit: 4 years 10 months ago by Marot.

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

  • Arkane
More
5 years 2 months ago #20 by Arkane Replied by Arkane on topic Cinematic effects for ReShade

Marot wrote: I'm not the author obviously, but I went ahead and fixed those warnings as I've been playing with this shader quite a lot myself recently:

Dazaster wrote: Hey there, been using this the last few days for GTA V and Fallout 4. Really like it. Now with the release of Reshade 4.0.0 I get "reshade-shaders\Shaders\pandafx.fx(529, 19): warning X3206: implicit truncation of vector type" a couple of times. Still working though.

/*
	PandaFX version 2.2.1 for ReShade 4.1.1
	by Jukka Korhonen aka Loadus ~ twitter.com/thatbonsaipanda
	November 2018
	jukka.korhonen@gmail.com
	
	Modified quickly by Marot for better ReShade 4.0 compatibility.
	
	Applies cinematic lens effects and color grading.
	Free licence to copy, modify, tweak and publish but
	if you can, give credit. Thanks. o/
	
	- jP
 */

#include "ReShade.fxh"

// ------------------------------------

uniform float Blend_Amount <
	ui_label = "Blend Amount";
	ui_type = "slider";
	ui_min = 0.0;
	ui_max = 1.0;
	ui_tooltip = "Blend the effect with the original image.";
> = 1.0;

// ------------------------------------

uniform bool Enable_Diffusion <
	ui_label = "Enable the lens diffusion effect";
	ui_tooltip = "Enable a light diffusion that emulates the glare of a camera lens.";
> = true;

uniform bool Enable_Bleach_Bypass <
	ui_label = "Enable the 'Bleach Bypass' effect";
	ui_tooltip = "Enable a cinematic contrast effect that emulates a bleach bypass on film. Used a lot in war movies and gives the image a grittier feel.";
> = true;

uniform bool Enable_Dither <
	ui_label = "Dither";
	ui_tooltip = "Dither the final result.";
> = true;


// ------------------------------------

uniform float Contrast_R <
    ui_label = "Contrast (Red)";
	ui_type = "slider";
	ui_min = 0.00001;
	ui_max = 20.0;
	ui_tooltip = "Apply contrast to red.";
> = 2.2;

uniform float Contrast_G <
    ui_label = "Contrast (Green)";
	ui_type = "slider";
	ui_min = 0.00001;
	ui_max = 20.0;
	ui_tooltip = "Apply contrast to green.";
> = 2.0;

uniform float Contrast_B <
    ui_label = "Contrast (Blue)";
	ui_type = "slider";
	ui_min = 0.00001;
	ui_max = 20.0;
	ui_tooltip = "Apply contrast to blue.";
> = 2.0;

uniform float Gamma_R <
    ui_label = "Gamma (Red)";
	ui_type = "slider";
	ui_min = 0.02;
	ui_max = 5.0;
	ui_tooltip = "Apply Gamma to red.";
> = 1.0;

uniform float Gamma_G <
    ui_label = "Gamma (Green)";
	ui_type = "slider";
	ui_min = 0.02;
	ui_max = 5.0;
	ui_tooltip = "Apply Gamma to green.";
> = 1.0;

uniform float Gamma_B <
    ui_label = "Gamma (Blue)";
	ui_type = "slider";
	ui_min = 0.02;
	ui_max = 5.0;
	ui_tooltip = "Apply Gamma to blue.";
> = 1.0;

// ------------------------------------

uniform float Diffusion_1_Amount <
    ui_label = "Diffusion 1 Amount";
	ui_type = "slider";
	ui_min = 0.0;
	ui_max = 1.0;
	ui_tooltip = "Adjust the amount of the first diffusion layer.";
> = 0.5;

uniform float Diffusion_2_Amount <
    ui_label = "Diffusion 2 Amount";
	ui_type = "slider";
	ui_min = 0.0;
	ui_max = 1.0;
	ui_tooltip = "Adjust the amount of the second diffusion layer.";
> = 0.5;

uniform float Diffusion_3_Amount <
    ui_label = "Diffusion 3 Amount";
	ui_type = "slider";
	ui_min = 0.0;
	ui_max = 1.0;
	ui_tooltip = "Adjust the amount of the third diffusion layer.";
> = 0.5;

uniform float Diffusion_1_Radius <
	ui_label = "Diffusion 1 Radius";
	ui_type = "slider";
	ui_min = 5.0;
	ui_max = 20.0;
	ui_tooltip = "Set the radius of the first diffusion layer.";
> = 8.0;

uniform float Diffusion_2_Radius <
	ui_label = "Diffusion 2 Radius";
	ui_type = "slider";
	ui_min = 5.0;
	ui_max = 20.0;
	ui_tooltip = "Set the radius of the second diffusion layer.";
> = 8.0;

uniform float Diffusion_3_Radius <
	ui_label = "Diffusion 3 Radius";
	ui_type = "slider";
	ui_min = 5.0;
	ui_max = 20.0;
	ui_tooltip = "Set the radius of the third diffusion layer.";
> = 8.0;

uniform float Diffusion_1_Gamma <
    ui_label = "Diffusion 1 Gamma";
	ui_type = "slider";
	ui_min = 0.02;
	ui_max = 5.0;
	ui_tooltip = "Apply Gamma to first diffusion layer.";
> = 2.2;

uniform float Diffusion_2_Gamma <
    ui_label = "Diffusion 2 Gamma";
	ui_type = "slider";
	ui_min = 0.02;
	ui_max = 5.0;
	ui_tooltip = "Apply Gamma to second diffusion layer.";
> = 1.3;

uniform float Diffusion_3_Gamma <
    ui_label = "Diffusion 3 Gamma";
	ui_type = "slider";
	ui_min = 0.02;
	ui_max = 5.0;
	ui_tooltip = "Apply Gamma to third diffusion layer.";
> = 1.0;

// ------------------------------------

uniform float Bleach_Bypass_Amount <
	ui_label = "Bleach Bypass Amount";
	ui_type = "slider";
	ui_min = 0.0;
	ui_max = 1.0;
	ui_tooltip = "Adjust the amount of the third diffusion layer.";
> = 0.5;

// ------------------------------------

uniform float Dither_Amount <
    ui_label = "Dither Amount";
	ui_type = "slider";
	ui_min = 0.0;
	ui_max = 1.0;
	ui_tooltip = "Adjust the amount of the dither on the diffusion layers (to smooth out banding).";
> = 0.15;

// ------------------------------------

uniform float Diffusion_1_Desaturate <
    ui_label = "Diffusion 1 desaturation";
	ui_type = "slider";
	ui_min = 0.0;
	ui_max = 1.0;
	ui_tooltip = "Adjust the saturation of the first diffusion layer.";
> = 0.0;

uniform float Diffusion_2_Desaturate <
    ui_label = "Diffusion 2 desaturation";
	ui_type = "slider";
	ui_min = 0.0;
	ui_max = 1.0;
	ui_tooltip = "Adjust the saturation of the second diffusion layer.";
> = 0.5;

uniform float Diffusion_3_Desaturate <
    ui_label = "Diffusion 3 desaturation";
	ui_type = "slider";
	ui_min = 0.0;
	ui_max = 1.0;
	ui_tooltip = "Adjust the saturation of the third diffusion layer.";
> = 0.75;

// ------------------------------------

uniform float Diffusion_1_Quality <
	ui_label = "Diffusion 1 sampling quality";
	// ui_type = "slider";
	// ui_min = 1;
	// ui_max = 64;
	ui_tooltip = "Set the quality of the first diffusion layer. Number is the divider of how many times the texture size is divided in half. Lower number = higher quality, but more processing needed. (No need to adjust this.)";
> = 2;

uniform float Diffusion_2_Quality <
	ui_label = "Diffusion 2 sampling quality";
	// ui_type = "slider";
	// ui_min = 1;
	// ui_max = 64;
	ui_tooltip = "Set the quality of the second diffusion layer. Number is the divider of how many times the texture size is divided in half. Lower number = higher quality, but more processing needed. (No need to adjust this.)";
> = 16;

uniform float Diffusion_3_Quality <
	ui_label = "Diffusion 3 sampling quality";
	// ui_type = "slider";
	// ui_min = 1;
	// ui_max = 64;
	ui_tooltip = "Set the quality of the third diffusion layer. Number is the divider of how many times the texture size is divided in half. Lower number = higher quality, but more processing needed. (No need to adjust this.)";
> = 64;

// ------------------------------------



// Provide a noise texture, basically a gray surface with grain:
texture NoiseTex <source = "hd_noise.png"; > { Width = 1920; Height = 1080; Format = RGBA8; };
sampler NoiseSampler { Texture = NoiseTex; };

texture prePassLayer { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA8; };

texture blurLayerHorizontal { Width = BUFFER_WIDTH / 2; Height = BUFFER_HEIGHT / 2; Format = RGBA8; };
texture blurLayerVertical { Width = BUFFER_WIDTH / 2; Height = BUFFER_HEIGHT / 2; Format = RGBA8; };
texture blurLayerHorizontalMedRes { Width = BUFFER_WIDTH / 16; Height = BUFFER_HEIGHT / 16; Format = RGBA8; };
texture blurLayerVerticalMedRes { Width = BUFFER_WIDTH / 16; Height = BUFFER_HEIGHT / 16; Format = RGBA8; };
texture blurLayerHorizontalLoRes { Width = BUFFER_WIDTH / 64; Height = BUFFER_HEIGHT / 64; Format = RGBA8; };
texture blurLayerVerticalLoRes { Width = BUFFER_WIDTH / 64; Height = BUFFER_HEIGHT / 64; Format = RGBA8; };

uniform float framecount < source = "framecount"; >;

sampler2D PFX_PrePassLayer { Texture = prePassLayer; };

// ------- samplers for large radius blur
sampler2D PFX_blurHorizontalLayer {	Texture = blurLayerHorizontal; };
sampler2D PFX_blurVerticalLayer { Texture = blurLayerVertical; };
sampler2D PFX_blurHorizontalLayerMedRes { Texture = blurLayerHorizontalMedRes; };
sampler2D PFX_blurVerticalLayerMedRes {	Texture = blurLayerVerticalMedRes; };
sampler2D PFX_blurHorizontalLayerLoRes { Texture = blurLayerHorizontalLoRes; };
sampler2D PFX_blurVerticalLayerLoRes { Texture = blurLayerVerticalLoRes; };


float AdjustableSigmoidCurve (float value, float amount) {

	float curve = 1.0; 

    if (value < 0.5)
    {
        curve = pow(value, amount) * pow(2.0, amount) * 0.5; 
    }
        
    else
    { 	
    	curve = 1.0 - pow(abs(1.0 - value), amount) * pow(2.0, amount) * 0.5; 
    }

    return curve;
}

float Randomize (float2 coord) {
	float noise = (frac(sin(dot(coord, float2(12.9898, 78.233))) * 43758.5453));
	return clamp(noise, 0.0, 1.0);
}

float SigmoidCurve (float value) {
	value = value * 2.0 - 1.0;
	return -value * abs(value) * 0.5 + value + 0.5;	
}

float SoftLightBlend (float A, float B) {
	
	if (A > 0.5)
	{
		return (2 * A - 1) * (sqrt(B) - B) + B; 
	}

	else
	{
		return (2 * A - 1) * (B - pow(B , 2)) + B; 
	}	

	return 0;
}

float4 BlurH (sampler input, float2 uv, float radius, float sampling) {


	float2 coordinate = float2(0.0, 0.0);
	float4 A = float4(0.0, 0.0, 0.0, 1.0); 
	float4 C = float4(0.0, 0.0, 0.0, 1.0);
	float weight = 1.0; 
	float width = 1.0 / BUFFER_WIDTH * sampling;					
	float divisor = 0.000001; 

		for (float x = -radius; x <= radius; x++)
		{
			coordinate = uv + float2(x * width, 0.0);
			coordinate = clamp(coordinate, 0.0, 1.0); 
			A = tex2D(input, coordinate);		
				weight = SigmoidCurve(1.0 - (abs(x) / radius));		
				C += A * weight; 		
			divisor += weight;
		}
	
	return C / divisor; 
}

float4 BlurV (sampler input, float2 uv, float radius, float sampling) {

	float2 coordinate = float2(0.0, 0.0);
	float4 A = float4(0.0, 0.0, 0.0, 1.0); 
	float4 C = float4(0.0, 0.0, 0.0, 1.0); 
	float weight = 1.0; 	
	float height = 1.0 / BUFFER_HEIGHT * sampling;					
	float divisor = 0.000001; 
	
		for (float y = -radius; y <= radius; y++)
		{
			coordinate = uv + float2(0.0, y * height);
			coordinate = clamp(coordinate, 0.0, 1.0);		
			A = tex2D(input, coordinate);	
				weight = SigmoidCurve(1.0 - (abs(y) / radius)); 		
				C += A * weight; 		
			divisor += weight;
		}

	return C / divisor; 
}


void PS_PrePass (float4 pos : SV_Position, 
				 float2 uv : TEXCOORD, 
				 out float4 result : SV_Target) 
{

	float4 A = tex2D(ReShade::BackBuffer, uv);
		   A.r = pow(abs(A.r), Gamma_R);
		   A.g = pow(abs(A.g), Gamma_G);
		   A.b = pow(abs(A.b), Gamma_B);
		   A.r = AdjustableSigmoidCurve(A.r, Contrast_R);
		   A.g = AdjustableSigmoidCurve(A.g, Contrast_G);
		   A.b = AdjustableSigmoidCurve(A.b, Contrast_B);
	
	// ------- Change color weights of the final render, similar to a printed film

		A.g = A.g * 0.8 + A.b * 0.2;

		float red = A.r - A.g - A.b;
		float green = A.g - A.r - A.b;
		float blue = A.b - A.r - A.g;

		red = clamp(red, 0.0, 1.0);
		green = clamp(green, 0.0, 1.0);
		blue = clamp(blue, 0.0, 1.0);

		A = A * (1.0 - red * 0.6);
		A = A * (1.0 - green * 0.8);	
		A = A * (1.0 - blue * 0.3);
		
		// A.r = AdjustableSigmoidCurve(A.r, 1.4);
		// A.r = pow(A.r, 1.1);	
		
		result = A;
}


void PS_HorizontalPass (float4 pos : SV_Position, 
						float2 uv : TEXCOORD, out float4 result : SV_Target) 
{
	result = BlurH(PFX_PrePassLayer, uv, Diffusion_1_Radius, Diffusion_1_Quality);
	// result = BlurH(ReShade::BackBuffer, uv, Diffusion_1_Radius, Diffusion_1_Quality);
}

void PS_VerticalPass (float4 pos : SV_Position, 
					  float2 uv : TEXCOORD, out float4 result : SV_Target) 
{
	result = BlurV(PFX_blurHorizontalLayer, uv, Diffusion_1_Radius, Diffusion_1_Quality);
}

void PS_HorizontalPassMedRes (float4 pos : SV_Position, 
						float2 uv : TEXCOORD, out float4 result : SV_Target) 
{
	result = BlurH(PFX_blurVerticalLayer, uv, Diffusion_2_Radius, Diffusion_2_Quality);
}

void PS_VerticalPassMedRes (float4 pos : SV_Position, 
					  float2 uv : TEXCOORD, out float4 result : SV_Target) 
{
	result = BlurV(PFX_blurHorizontalLayerMedRes, uv, Diffusion_2_Radius, Diffusion_2_Quality);
}

void PS_HorizontalPassLoRes (float4 pos : SV_Position, 
						float2 uv : TEXCOORD, out float4 result : SV_Target) 
{
	result = BlurH(PFX_blurVerticalLayerMedRes, uv, Diffusion_3_Radius, Diffusion_3_Quality);
}

void PS_VerticalPassLoRes (float4 pos : SV_Position, 
					  float2 uv : TEXCOORD, out float4 result : SV_Target) 
{
	result = BlurV(PFX_blurHorizontalLayerLoRes, uv, Diffusion_3_Radius, Diffusion_3_Quality);
}




float4 PandaComposition (float4 vpos : SV_Position, 
						 float2 uv : TEXCOORD) : SV_Target 
{
	// ------- Create blurred layers for lens diffusion

		float4 blurLayer;
		float4 blurLayerMedRes;
		float4 blurLayerLoRes;
	
	if (Enable_Diffusion)
	{
		// TODO enable/disable for performance >>
		blurLayer = tex2D(PFX_blurVerticalLayer, uv);
		blurLayerMedRes = tex2D(PFX_blurVerticalLayerMedRes, uv);
		blurLayerLoRes = tex2D(PFX_blurVerticalLayerLoRes, uv);
		

			// ------- Blur layer colors

				float4 blurLayerGray = dot(0.3333, blurLayer.rgb);
				blurLayer = lerp(blurLayer, blurLayerGray, Diffusion_2_Desaturate);

				float4 blurLayerMedResGray = dot(0.3333, blurLayerMedRes.rgb);
				blurLayerMedRes = lerp(blurLayerMedRes, blurLayerMedResGray, Diffusion_2_Desaturate);

				float4 blurLayerLoResGray = dot(0.3333, blurLayerLoRes.rgb);
				blurLayerLoRes = lerp(blurLayerLoRes, blurLayerLoResGray, Diffusion_3_Desaturate);

				// blurLayerMedRes.g *= 0.75;
				// blurLayerMedRes.b *= 0.5;

				// blurLayerLoRes.g *= 0.75;
				// blurLayerLoRes.r *= 0.5;


			// ------- Set blur layer weights

				blurLayer *= Diffusion_1_Amount;
				blurLayerMedRes *= Diffusion_2_Amount;
				blurLayerLoRes *= Diffusion_3_Amount;
			
				blurLayer = pow(abs(blurLayer), Diffusion_1_Gamma);
				blurLayerMedRes = pow(abs(blurLayerMedRes), Diffusion_2_Gamma);
				blurLayerLoRes = pow(abs(blurLayerLoRes), Diffusion_3_Gamma);
	}


	// ------- Read original image

		float4 A = tex2D(PFX_PrePassLayer, uv);
		float4 O = tex2D(ReShade::BackBuffer, uv);

	// ------- Screen blend the blur layers to create lens diffusion

		if (Enable_Diffusion) 
		{
			float4 diffusion;

			blurLayer = clamp(blurLayer, 0.0, 1.0);
			blurLayerMedRes = clamp(blurLayerMedRes, 0.0, 1.0);
			blurLayerLoRes = clamp(blurLayerLoRes, 0.0, 1.0);

	 		A.rgb = 1.0 - (1.0 - blurLayer.rgb) * (1.0 - A.rgb);
			A.rgb = 1.0 - (1.0 - blurLayerMedRes.rgb) * (1.0 - A.rgb);
			A.rgb = 1.0 - (1.0 - blurLayerLoRes.rgb) * (1.0 - A.rgb);
		}


	// ------ Compress contrast using Hard Light blending ------
		
		if (Enable_Bleach_Bypass)
		{
			float Ag = dot(float3(0.3333, 0.3333, 0.3333), A.rgb);
			float4 B = A;
			float4 C = 0;

			if (Ag > 0.5)
			{
				C = 1 - 2 * (1 - Ag) * (1 - B);
			}

			else
			{
				C = 2 * Ag * B;
			}

			C = pow(abs(C), 0.6);
			A = lerp(A, C, Bleach_Bypass_Amount);
		}


	// ------- Dither the composition to eliminate banding

		if (Enable_Dither)
		{
			float4 rndSample = tex2D(NoiseSampler, uv);
			float uvRnd = Randomize(rndSample.xy * framecount);
			float uvRnd2 = Randomize(-rndSample.xy * framecount);

			float4 Nt = tex2D(NoiseSampler, uv * uvRnd);
			float4 Nt2 = tex2D(NoiseSampler, uv * uvRnd2);
			float4 Nt3 = tex2D(NoiseSampler, -uv * uvRnd);

			float3 noise = float3(Nt.x, Nt2.x, Nt3.x);

			float4 B = A;

			B.r = SoftLightBlend(noise.r, A.r);
			B.g = SoftLightBlend(noise.g, A.g);
			B.b = SoftLightBlend(noise.b, A.b);

			A = lerp(A, B, Dither_Amount);
		}

	// ------ Compress to TV levels if needed ------
		
		// A = A * 0.9373 + 0.0627;

		A = lerp(O, A, Blend_Amount);

	return A;
}

technique PandaFX 
{
		pass PreProcess	
		{
			VertexShader = PostProcessVS;
			PixelShader = PS_PrePass;
			RenderTarget = prePassLayer;
		}

		pass HorizontalPass
		{
			VertexShader = PostProcessVS;
			PixelShader = PS_HorizontalPass;
			RenderTarget = blurLayerHorizontal;
		}

		pass VerticalPass
		{
			VertexShader = PostProcessVS;
			PixelShader = PS_VerticalPass;
			RenderTarget = blurLayerVertical;
		}

		pass HorizontalPassMedRes
		{
			VertexShader = PostProcessVS;
			PixelShader = PS_HorizontalPassMedRes;
			RenderTarget = blurLayerHorizontalMedRes;
		}

		pass VerticalPassMedRes
		{
			VertexShader = PostProcessVS;
			PixelShader = PS_VerticalPassMedRes;
			RenderTarget = blurLayerVerticalMedRes;
		}

		pass HorizontalPassLoRes
		{
			VertexShader = PostProcessVS;
			PixelShader = PS_HorizontalPassLoRes;
			RenderTarget = blurLayerHorizontalLoRes;
		}

		pass VerticalPassLoRes
		{
			VertexShader = PostProcessVS;
			PixelShader = PS_VerticalPassLoRes;
			RenderTarget = blurLayerVerticalLoRes;
		}

	pass CustomPass
	{
		VertexShader = PostProcessVS;
		PixelShader = PandaComposition ;
	}
}


Thank you for fixing this, but when I tried to watch your shader, I got errors. Are there any solutions?

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.