Welcome, Guest.
Username: Password: Remember me

TOPIC: Pseudo depth buffer missing from 2.0?

Pseudo depth buffer missing from 2.0? 3 months 2 weeks ago #1

This was such a cool function and was a great way for testing various depth dependent effects. USing it with Matso depth of field in a very subtle manner actaully looked pretty nice and was good for screenshot taking purposes to at least give the impression that there was DOF present. Is there any way i can quickly re-implement this into my ReShade 2.0 config? Crosire? Anyone?

Thanks.
Last Edit: 3 months 2 weeks ago by Aelius Maximus.
The administrator has disabled public write access.

Pseudo depth buffer missing from 2.0? 3 months 2 weeks ago #2

  • brussell
  • brussell's Avatar
  • Offline
  • Posts: 139
  • Thank you received: 113
Copy ReShade/BasicFX/Textures/dMask.png (ReShade 1.0) to ReShade/Profiles/Default/Textures/dMask.png and apply these changes (not tested but should work):

ReShade.fx
	...
	// Global Textures and Samplers
	texture BackBufferTex : COLOR;
	texture DepthBufferTex : DEPTH;

	texture OriginalColorTex { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA8; };
	sampler BackBuffer { Texture = BackBufferTex; };
	sampler OriginalColor { Texture = OriginalColorTex; };
	sampler OriginalDepth { Texture = DepthBufferTex; };

#if RESHADE_DEPTH_CALCULATION
	texture DepthTex { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = R32F; };
	sampler DepthTexSampler { Texture = DepthTex; };
#endif

#if RESHADE_PSEUDODOF
	texture PseudoDofTex < source = "ReShade/Profiles/Default/Textures/dMask.png"; > { Width = 1024; Height = 1024; MipLevels = 1; Format = RGBA8; };
	sampler PseudoDofSampler { Texture = PseudoDofTex; };
#endif

	// Full-screen triangle vertex shader
	void VS_PostProcess(in 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);
	}

	// Color and depth buffer copy and linearization shaders
	float4 PS_CopyBackBuffer(float4 vpos : SV_Position, float2 texcoord : TEXCOORD) : SV_Target
	{
		return tex2D(BackBuffer, texcoord);
	}

#if RESHADE_DEPTH_CALCULATION
	void PS_Depth_Calculation(float4 vpos : SV_Position, float2 texcoord : TEXCOORD0, out float depth : SV_Target)
	{

#if RESHADE_PSEUDODOF
	depth tex2D(PseudoDofSampler, texcoord).x;
#else
	#if RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN
		texcoord.y = 1.0 - texcoord.y;
	#endif

	depth = tex2D(OriginalDepth, texcoord).x;

	#if RESHADE_DEPTH_INPUT_IS_LOGARITHMIC
		const float C = 0.01;
		depth = (exp(depth * log(C + 1.0)) - 1.0) / C;
	#endif
	#if RESHADE_DEPTH_INPUT_IS_REVERSED
		depth = 1.0 - depth;
	#endif
		const float N = 1.0;
		depth /= RESHADE_DEPTH_LINEARIZATION_FAR_PLANE - depth * (RESHADE_DEPTH_LINEARIZATION_FAR_PLANE - N);
#endif
	}
#endif
}
...

ReShade/Profiles/Default/Global.cfg
...
//>Depth Settings<\\
#define RESHADE_DEPTH_CALCULATION 1 //[0:1] //-Set this to 0 if run an application that does not allow depth buffer access or you use no depth dependent effects and want some additional fps.
#define RESHADE_DEPTH_LINEARIZATION_FAR_PLANE 1000.0 //[0.0:100000.0] //-The far clipping plane distance.
#define RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN 0 //[0:1] //-Set this to one for games where the depth buffer is upside down.
#define RESHADE_DEPTH_INPUT_IS_REVERSED 0 //[0:1] //-Set this to one for games using a reversed depth buffer.
#define RESHADE_DEPTH_INPUT_IS_LOGARITHMIC 0 //[0:1] //-Set this to one for games using a logarithmic depth buffer.
#define RESHADE_PSEUDODOF 1 //[0:1] //-To use or configure depth shader without acces to depth buffer.
The administrator has disabled public write access.
The following user(s) said Thank You: Aelius Maximus

Pseudo depth buffer missing from 2.0? 3 months 2 weeks ago #3

Thanks for going to the effort of porting the code forward from 1.0, So close as well, there is just one error code which is preventing it from compiling

ReShade.fx(111, 32): error X3004: undeclared identifier 'BackBufferTex'

Perhaps an old definition that is no longer supported? I'm not too sure, hopefully there will be no more after that is corrected
Thank you again
Last Edit: 3 months 2 weeks ago by Aelius Maximus.
The administrator has disabled public write access.

Pseudo depth buffer missing from 2.0? 3 months 2 weeks ago #4

Aelius Maximus wrote:
Thanks for going to the effort of porting the code forward from 1.0, So close as well, there is just one error code which is preventing it from compiling

ReShade.fx(111, 32): error X3004: undeclared identifier 'BackBufferTex'

Perhaps an old definition that is no longer supported? I'm not too sure, hopefully there will be no more after that is corrected
Thank you again

You can set your own.
texture BackBufferTex : COLOR;

sampler BackBuffer 
	{ 
		Texture = BackBufferTex; 
	};

Just change the Name BackBuffer to "whateveryouwant" or Just use BackBuffer
My PayPal Me Link If you like to donate paypal.me/BlueSkyDefender

Also my steam page steamcommunity.com/id/BlueSkyDefender
Last Edit: 3 months 2 weeks ago by BlueSkyKnight.
The administrator has disabled public write access.
The following user(s) said Thank You: Aelius Maximus

Pseudo depth buffer missing from 2.0? 3 months 2 weeks ago #5

  • brussell
  • brussell's Avatar
  • Offline
  • Posts: 139
  • Thank you received: 113
Sorry for the delay. This should work now:

Copy ReShade/BasicFX/Textures/dMask.png (ReShade 1.0) to ReShade/dMask.png and use the following files:

ReShade.fx
#if !defined(__RESHADE__) || __RESHADE__ < 20000
	#error "ReShade 2.0+ is required to use these shaders"
#endif

#define STR(value) #value
#define STE(value) STR(value)

#include "ReShade\KeyCodes.h"

// Global Settings
#if exists(STE(ReShade/Profiles/__APPLICATION_NAME__/Global.cfg))
	#include STE(ReShade/Profiles/__APPLICATION_NAME__/Global.cfg)
#else
	#warning "Could not find application profile, falling back to default"
	#include "ReShade/Profiles/Default/Global.cfg"
#endif

#pragma reshade screenshot_key RESHADE_SCREENSHOT_KEY
#pragma reshade screenshot_format RESHADE_SCREENSHOT_FORMAT

#if RESHADE_SHOW_FPS
	#pragma reshade showfps
#endif
#if RESHADE_SHOW_CLOCK
	#pragma reshade showclock
#endif
#if RESHADE_SHOW_STATISTICS
	#pragma reshade showstatistics
#endif
#if RESHADE_SHOW_TOGGLE_MESSAGES
	#pragma reshade showtogglemessage
#endif

namespace ReShade
{
	// Global Variables
	static const float AspectRatio = BUFFER_WIDTH * BUFFER_RCP_HEIGHT;
	static const float2 PixelSize = float2(BUFFER_RCP_WIDTH, BUFFER_RCP_HEIGHT);
	static const float2 ScreenSize = float2(BUFFER_WIDTH, BUFFER_HEIGHT);
	uniform float Timer < source = "timer"; >;
	uniform float FrameTime < source = "frametime"; >;
	uniform float2 MouseCoords < source = "mousepoint"; >;
	
	// Global Textures and Samplers
	texture BackBufferTex : COLOR;
	texture DepthBufferTex : DEPTH;

	texture OriginalColorTex { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA8; };
#if RESHADE_DEPTH_LINEARIZATION
	texture LinearizedDepthTex { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = R32F; };
#else
	texture LinearizedDepthTex : DEPTH;
#endif

	sampler BackBuffer { Texture = BackBufferTex; };
	sampler OriginalColor { Texture = OriginalColorTex; };
	sampler OriginalDepth { Texture = DepthBufferTex; };
	sampler LinearizedDepth { Texture = LinearizedDepthTex; };

#if RESHADE_PSEUDODOF_ENABLE 
	texture PseudoDOFTex < source = "ReShade/dMask.png"; > { Width = 1024; Height = 1024; Format = R8; };
	sampler PseudoDOF
	{
		Texture = PseudoDOFTex;
		MinFilter = LINEAR;
		MagFilter = LINEAR;
		MipFilter = LINEAR;
		AddressU = Clamp;
		AddressV = Clamp;
	};
#endif 

	// Full-screen triangle vertex shader
	void VS_PostProcess(in 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);
	}

	// Color and depth buffer copy and linearization shaders
	float4 PS_CopyBackBuffer(float4 vpos : SV_Position, float2 texcoord : TEXCOORD) : SV_Target
	{
		return tex2D(BackBuffer, texcoord);
	}
#if RESHADE_DEPTH_LINEARIZATION
	void PS_DepthLinearization(float4 vpos : SV_Position, float2 texcoord : TEXCOORD0, out float depth : SV_Target)
	{
	
#if RESHADE_PSEUDODOF_ENABLE 	
	depth = tex2D(PseudoDOF, texcoord).x;
#else

#if RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN
		texcoord.y = 1.0 - texcoord.y;
#endif
		depth = tex2D(OriginalDepth, texcoord).x;

#if RESHADE_DEPTH_INPUT_IS_LOGARITHMIC
		const float C = 0.01;
		depth = (exp(depth * log(C + 1.0)) - 1.0) / C;
#endif
#if RESHADE_DEPTH_INPUT_IS_REVERSED
		depth = 1.0 - depth;
#endif
		const float N = 1.0;
		depth /= RESHADE_DEPTH_LINEARIZATION_FAR_PLANE - depth * (RESHADE_DEPTH_LINEARIZATION_FAR_PLANE - N);
#endif
	}
#endif
}

technique Setup < enabled = true; >
{
	pass ColorBackup
	{
		VertexShader = ReShade::VS_PostProcess;
		PixelShader = ReShade::PS_CopyBackBuffer;
		RenderTarget = ReShade::OriginalColorTex;
	}
#if RESHADE_DEPTH_LINEARIZATION
	pass DepthLinearization
	{
		VertexShader = ReShade::VS_PostProcess;
		PixelShader = ReShade::PS_DepthLinearization;
		RenderTarget = ReShade::LinearizedDepthTex;
	}
#endif
}

// Preset Settings
#if !defined(RESHADE_PRESET) || !exists(STE(ReShade/Presets/RESHADE_PRESET))
	#warning "Could not find preset, falling back to default"
	#undef RESHADE_PRESET
	#define RESHADE_PRESET Default
#endif

#define EFFECT(author, name) STE(ReShade/Shaders/author/name.fx)
#define EFFECT_CONFIG(author) STE(ReShade/Presets/RESHADE_PRESET/Shaders_by_##author.cfg)
#define EFFECT_CONFIG_UNDEF(author) STE(ReShade/Shaders/author.undef)

#include STE(ReShade/Presets/RESHADE_PRESET/Pipeline.cfg)

ReShade/Profiles/Default/Global.cfg
////----------//
///**Global**///
//----------////
#define RESHADE_PRESET Default

//>User<\\
#define RESHADE_START_ENABLED 1 //[0:1] //-Controls whether to start with effects on or off.
#define RESHADE_SCREENSHOT_KEY VK_SNAPSHOT //[undef] //-Sets the key for taking screenshots. Default is the PrintScreen key.
#define RESHADE_SCREENSHOT_FORMAT png //[undef] //-Sets the screenshot image format.
#define RESHADE_TOGGLE_KEY VK_SCROLL //[undef] //-Sets the global key to toggle effects on and off.

//>User Interface<\\
#define RESHADE_SHOW_FPS 0 //[0:1] //-Controls the display of a simple FPS counter.
#define RESHADE_SHOW_CLOCK 0 //[0:1] //-Controls the display of a simple realtime clock.
#define RESHADE_SHOW_STATISTICS 0 //[0:1] //-Controls the display of the detailed developer statistics.
#define RESHADE_SHOW_TOGGLE_MESSAGES 0 //[0:1] //-Controls the display of an info message when the toggle key is pressed.

//>Depth Settings<\\
#define RESHADE_DEPTH_LINEARIZATION 1 //[0:1] //-Set this to zero for games without depth buffer access or if you do not use any depth dependent effects.
#define RESHADE_DEPTH_LINEARIZATION_FAR_PLANE 1000.0 //[0.0:100000.0] //-The far clipping plane distance.
#define RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN 0 //[0:1] //-Set this to one for games where the depth buffer is upside down.
#define RESHADE_DEPTH_INPUT_IS_REVERSED 0 //[0:1] //-Set this to one for games using a reversed depth buffer.
#define RESHADE_DEPTH_INPUT_IS_LOGARITHMIC 0 //[0:1] //-Set this to one for games using a logarithmic depth buffer.
#define RESHADE_PSEUDODOF_ENABLE 1 //[0:1] //-Enable PseudoDof
The administrator has disabled public write access.
The following user(s) said Thank You: Aelius Maximus

Pseudo depth buffer missing from 2.0? 3 months 2 weeks ago #6

Thanks for your help guys, i got it working now :cheer:
The administrator has disabled public write access.