Welcome, Guest.
Username: Password: Remember me

TOPIC: So..TAA with SMAA possible with shaders? Seems so!

So..TAA with SMAA possible with shaders? Seems so! 2 years 7 months ago #21

BlueSkyKnight wrote:
Any one here know a game that has bad crawling and flickering with the camera is in motion?

Elite: Dangerous features some of the worst cases of aliasing I've ever seen. There's pixel crawling even at 4k. It's ridiculously bad..
It has a supersampling feature but even with SS set at 2x, at 4k, there's still pixel crawling and aliasing, especially on space stations.
The administrator has disabled public write access.

So..TAA with SMAA possible with shaders? Seems so! 2 years 7 months ago #22

Insomnia wrote:
BlueSkyKnight wrote:
Any one here know a game that has bad crawling and flickering with the camera is in motion?

Elite: Dangerous features some of the worst cases of aliasing I've ever seen. There's pixel crawling even at 4k. It's ridiculously bad..
It has a supersampling feature but even with SS set at 2x, at 4k, there's still pixel crawling and aliasing, especially on space stations.

Ya that crawling can Be really bad in some games. I ended up testing with Fallout4. Here is a youtube video of this shader in action.

You people may want to watch at 1080p+

I ended up adjusting Takashi Imagire shader, so that it a bit stronger also changed a few things around.

Ya we need some one better then I. To be able to figure out a better way of doing this.

anyways here the updated shader. I was not sure what to call it. Other then what it seems to be doing. "Temporal Aliasing Reducing"

Make a Text File and rename it too. TAReducer.fx
 ////-----------------------------//
 ///**Temporal Aliasing Reducer**///
 //-----------------------------////
 
 
 //---------------------------------------------------------------------------------------------//
 // 	Temporal anti-aliasing Filter Made by Takashi Imagire 									//
 //		ported over to Reshade and moded by BSD													// 
 //		His website is http://t-pot.com/ 														//
 //		GitHub Link for source info https://github.com/imagire	  								//
 // 	Direct Link https://github.com/t-pot/TAA/blob/master/taa.hlsl  Thank You.	  			//
 //_____________________________________________________________________________________________//
 
 uniform float Adjust <
	ui_type = "drag";
	ui_min = 0.0; ui_max = 1;
	ui_label = "Four Point Adjust";
	ui_tooltip = "To fine tune Adjustment.";
> = 0.5;
 
uniform float Threshhold <
	ui_type = "drag";
	ui_min = 0.1; ui_max = 0.5;
	ui_label = "Threshhold";
	ui_tooltip = "Threshhold Adjustment.";
> = 0.250;

uniform float Power <
	ui_type = "drag";
	ui_min = 0.1; ui_max = 100;
	ui_label = "Median Power Slider";
	ui_tooltip = "Determines the Median Power.";
> = 4.0;

uniform int DebugOutput <
	ui_type = "combo";
	ui_items = "Off\0On\0";
	ui_label = "Debug Output";
> = false;

/////////////////////////////////////////////D3D Starts Here/////////////////////////////////////////////////////////////////

#define pix float2(BUFFER_RCP_WIDTH, BUFFER_RCP_HEIGHT)

texture BackBufferTex : COLOR;

sampler BackBuffer 
	{ 
		Texture = BackBufferTex;
	};
	
texture texCC  { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA32F;}; 

sampler SamplerCC
	{
		Texture = texCC;
		AddressU = CLAMP;
		AddressV = CLAMP;
		AddressW = CLAMP;
	};
	
float3 RGB2YCoCg(float3 c)//YCoCg seems to work better then YCbCr
{

	return float3(
			 c.x/4.0 + c.y/2.0 + c.z/4.0,
			 c.x/2.0 - c.z/2.0,
			-c.x/4.0 + c.y/2.0 - c.z/4.0
					);
	
}

float3 YCoCg2RGB(float3 c)
{	

	if(DebugOutput == 0)
	{
			return saturate(float3(
			c.x + c.y - c.z,
			c.x + c.z,
			c.x - c.y - c.z
		));
	}
	else
	{
	return float3(
			1,0,0
		);
	}
}

texture texMed { Width = BUFFER_WIDTH/2; Height = BUFFER_HEIGHT/2; Format = RGBA32F;};

sampler SamplerMed
	{
		Texture = texMed;
		AddressU = BORDER;
		AddressV = BORDER;
		AddressW = BORDER;
		MipFilter = Linear; 
		MinFilter = Linear; 
		MagFilter = Linear;
	};
	
#define s2(a, b)				temp = a; a = min(a, b); b = max(temp, b);
#define mn3(a, b, c)			s2(a, b); s2(a, c);
#define mx3(a, b, c)			s2(b, c); s2(a, c);

#define mnmx3(a, b, c)			mx3(a, b, c); s2(a, b);                                   // 3 exchanges
#define mnmx4(a, b, c, d)		s2(a, b); s2(c, d); s2(a, c); s2(b, d);                   // 4 exchanges
#define mnmx5(a, b, c, d, e)	s2(a, b); s2(c, d); mn3(a, c, e); mx3(b, d, e);           // 6 exchanges
#define mnmx6(a, b, c, d, e, f) s2(a, d); s2(b, e); s2(c, f); mn3(a, b, c); mx3(d, e, f); // 7 exchanges	

float4 Median(float4 position : SV_Position, float2 texcoord : TEXCOORD0) : SV_Target
{
	float2 ScreenCal;

    ScreenCal = float2(Power*pix.x,Power*pix.y);

	float2 FinCal = ScreenCal*0.6;

	float4 v[9];
	[unroll]
	for(int i = -1; i <= 1; ++i) 
	{
		for(int j = -1; j <= 1; ++j)
		{		
		  float2 offset = float2(float(i), float(j));

		  v[(i + 1) * 3 + (j + 1)] = tex2D(BackBuffer, texcoord + offset * FinCal);
		}
	}

	float4 temp;

	mnmx6(v[0], v[1], v[2], v[3], v[4], v[5]);
	mnmx5(v[1], v[2], v[3], v[4], v[6]);
	mnmx4(v[2], v[3], v[4], v[7]);
	mnmx3(v[3], v[4], v[8]);
	
	return v[4];
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void PS(float4 position : SV_Position, float2 texcoord : TEXCOORD0, out float4 color : SV_Target)
{
	const float2 XYoffset[4] = { float2( 0, 1 ), float2( 0, -1 ), float2(1, 0 ), float2(-1, 0) };

	float4 center_color = tex2D(SamplerMed, texcoord);

	float4 neighbor_sum = center_color;

	for (int i = 0; i < 4; i++)
	{
		//Take points in the vicinity
		float4 neighbor = tex2D(BackBuffer, texcoord + XYoffset[i] * pix * Adjust);
		
		float3 color_diff = abs(neighbor.xyz - center_color.xyz) ;
		
		float3 ycc = RGB2YCoCg(color_diff.xyz); //Watch the difference with the center with YCoCg
		
		const float cbcr_threshhold = Threshhold;
		
		float cbcr_len = length(color_diff.yz); 
		
		if (cbcr_threshhold < cbcr_len)
		{
			ycc = (cbcr_threshhold / cbcr_len) * ycc ; //When the hue component is largely different, the color is corrected to the range that falls within the threshold value and synthesized
			
			neighbor.rgb = center_color.rgb + YCoCg2RGB(ycc);
		}
		neighbor_sum += neighbor;
	}
	float4 Color = neighbor_sum / 5.0f;
	
color =  Color;
}

///////////////////////////////////////////////////////////ReShade.fxh///////////////////////////////////////////////////////////////

// Vertex shader generating a triangle covering the entire screen
void PostProcessVS(in uint id : SV_VertexID, out float4 position : SV_Position, out float2 texcoord : TEXCOORD)
{
	texcoord.x = (id == 2) ? 2.0 : 0.0;
	texcoord.y = (id == 1) ? 2.0 : 0.0;
	position = float4(texcoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
}

//*Rendering passes*//

technique Temporal_Aliasing_Reducer
{
	pass MedianPass
		{
			VertexShader = PostProcessVS;
			PixelShader = Median;
			RenderTarget = texMed;
		}

			pass TAOutputPass
		{
			VertexShader = PostProcessVS;
			PixelShader = PS;
		}
		


}
My GitHub page where you can get the Latest release of SuperDepth3D github.com/BlueSkyDefender/Depth3D

My PayPal Me Link If you like to donate paypal.me/BlueSkyDefender

Also my steam page steamcommunity.com/id/BlueSkyDefender

Discord Server discord.gg/W2f7YhX
Last Edit: 2 years 7 months ago by BlueSkyKnight.
The administrator has disabled public write access.
The following user(s) said Thank You: thrl, Gar Stazi

So..TAA with SMAA possible with shaders? Seems so! 2 years 7 months ago #23

Sorry to say but that video clip is set to private.. :P
The administrator has disabled public write access.

So..TAA with SMAA possible with shaders? Seems so! 2 years 7 months ago #24

Insomnia wrote:
Sorry to say but that video clip is set to private.. :P

Sorry I been really sick this whole week. now I'm at the stage a bad cough. I think I fixed that. video. So please excuse my mistakes.
My GitHub page where you can get the Latest release of SuperDepth3D github.com/BlueSkyDefender/Depth3D

My PayPal Me Link If you like to donate paypal.me/BlueSkyDefender

Also my steam page steamcommunity.com/id/BlueSkyDefender

Discord Server discord.gg/W2f7YhX
The administrator has disabled public write access.

So..TAA with SMAA possible with shaders? Seems so! 2 years 7 months ago #25

BlueSkyKnight wrote:
Insomnia wrote:
Sorry to say but that video clip is set to private.. :P

Sorry I been really sick this whole week. now I'm at the stage a bad cough. I think I fixed that. video. So please excuse my mistakes.
in most games ive tested this in it actually makes aliasing more visible and blurs everything else except the edges,anyway to detect color change say of brightness of a edge over a course of a few frames then use that to try and create some type of jitter the pixels to fix some of the shimmering that way then apply your normal post aa filter idk if reshade supports this but the detected pixels maybe could be supersampled over those frames then post aa as a last pass?
The administrator has disabled public write access.

So..TAA with SMAA possible with shaders? Seems so! 1 year 7 months ago #26

Ok, so Necroing this thread.

Temporal AA (aka Motion Blur) based on Epic Games' implementation:

de45xmedrsdbp.cloudfront.net/Resources/f...A_small-59732822.pdf

Originally written by yvt for www.shadertoy.com/view/4tcXD2

This one works....... well.... still needs work.

// Temporal AA (aka Motion Blur) based on Epic Games' implementation:
// https://de45xmedrsdbp.cloudfront.net/Resources/files/TemporalAA_small-59732822.pdf
// 
// Originally written by yvt for https://www.shadertoy.com/view/4tcXD2
// Feel free to use this in your shader!

uniform int Motion_Blur <
	ui_type = "combo";
	ui_items = "Off\0On\0";
	ui_label = "Motion Blur Max";
> = false;

/////////////////////////////////////////////D3D Starts Here/////////////////////////////////////////////////////////////////
texture BackBufferTex : COLOR;

sampler BackBuffer 
	{ 
		Texture = BackBufferTex;
	};
	
texture PastBackBuffer  { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA32F;}; 

sampler PastBB
	{
		Texture = PastBackBuffer;
	};
///////////////////////////////////////////////////////////TAA/////////////////////////////////////////////////////////////////////	
#define pix float2(BUFFER_RCP_WIDTH, BUFFER_RCP_HEIGHT)
#define iResolution float2(BUFFER_WIDTH, BUFFER_HEIGHT)

// YUV-RGB conversion routine from Hyper3D
float3 encodePalYuv(float3 rgb)
{
    return float3(
        dot(rgb, float3(0.299, 0.587, 0.114)),
        dot(rgb, float3(-0.14713, -0.28886, 0.436)),
        dot(rgb, float3(0.615, -0.51499, -0.10001))
    );
}

float3 decodePalYuv(float3 yuv)
{	

    return float3(
        dot(yuv, float3(1.0, 0., 1.13983)),
        dot(yuv, float3(1.0, -0.39465, -0.58060)),
        dot(yuv, float3(1.0, 2.03211, 0.))
    );
}

float4 TAA_Out(float4 position : SV_Position, float2 texcoord : TEXCOORD) : SV_Target
{
	float2 uv = texcoord;
    float4 lastColor = tex2D(PastBB, uv);//Past Back Buffer
    
    float3 antialiased = lastColor.xyz;
    float mixRate = min(lastColor.w, 0.5);
    
    float2 off = pix;
    float3 in0 = tex2D(BackBuffer, uv).xyz;
    
    antialiased = lerp(antialiased * antialiased, in0 * in0, mixRate);
    antialiased = sqrt(antialiased);
    
    float3 in1 = tex2D(BackBuffer, uv + float2(+off.x, 0.0)).xyz;
    float3 in2 = tex2D(BackBuffer, uv + float2(-off.x, 0.0)).xyz;
    float3 in3 = tex2D(BackBuffer, uv + float2(0.0, +off.y)).xyz;
    float3 in4 = tex2D(BackBuffer, uv + float2(0.0, -off.y)).xyz;
    float3 in5 = tex2D(BackBuffer, uv + float2(+off.x, +off.y)).xyz;
    float3 in6 = tex2D(BackBuffer, uv + float2(-off.x, +off.y)).xyz;
    float3 in7 = tex2D(BackBuffer, uv + float2(+off.x, -off.y)).xyz;
    float3 in8 = tex2D(BackBuffer, uv + float2(-off.x, -off.y)).xyz;
    
    antialiased = encodePalYuv(antialiased);
    in0 = encodePalYuv(in0);
    in1 = encodePalYuv(in1);
    in2 = encodePalYuv(in2);
    in3 = encodePalYuv(in3);
    in4 = encodePalYuv(in4);
    in5 = encodePalYuv(in5);
    in6 = encodePalYuv(in6);
    in7 = encodePalYuv(in7);
    in8 = encodePalYuv(in8);
    
    float MB;
    if(Motion_Blur)//Ugly hack
    MB = 1;
    
    float3 minColor = min(min(min(in0, in1), min(in2, in3)), in4) - MB;
    float3 maxColor = max(max(max(in0, in1), max(in2, in3)), in4) + MB;
    minColor = lerp(minColor, min(min(min(in5, in6), min(in7, in8)), minColor), 0.5);
    maxColor = lerp(maxColor, max(max(max(in5, in6), max(in7, in8)), maxColor), 0.5);
    
   	float3 preclamping = antialiased;
    antialiased = clamp(antialiased, minColor, maxColor);
    
    mixRate = 1.0 / (1.0 / mixRate + 1.0);
    
    float3 diff = antialiased - preclamping;
    float clampAmount = dot(diff, diff);
    
    mixRate += clampAmount * 4.0;
    mixRate = clamp(mixRate, 0.05, 0.5);
    
    antialiased = decodePalYuv(antialiased);
        
    return float4(antialiased, mixRate);
}

float4 Past_BackBuffer(float4 position : SV_Position, float2 texcoord : TEXCOORD) : SV_Target
{
	return tex2D(BackBuffer,texcoord);
}

///////////////////////////////////////////////////////////ReShade.fxh/////////////////////////////////////////////////////////////
// Vertex shader generating a triangle covering the entire screen
void PostProcessVS(in uint id : SV_VertexID, out float4 position : SV_Position, out float2 texcoord : TEXCOORD)
{
	texcoord.x = (id == 2) ? 2.0 : 0.0;
	texcoord.y = (id == 1) ? 2.0 : 0.0;
	position = float4(texcoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
}
technique TAA
	{
			pass TAAOut
		{
			VertexShader = PostProcessVS;
			PixelShader = TAA_Out;
		}
			pass PBB
		{
			VertexShader = PostProcessVS;
			PixelShader = Past_BackBuffer;
			RenderTarget = PastBackBuffer;
		}
	}

It makes a better Motion blur shader than anything else. I have a suspicion that the way I added the previous fame may be delayed too long.

Still, need to add Jitter and some other things. But, I listed this here because there are very talented Shader Devs here. So if they want to use this as a base Go ahead.

There still some Ghosting so.... Expect that. Ignore the old shader.... I was Veary sick when I made that lol..... :dry:
My GitHub page where you can get the Latest release of SuperDepth3D github.com/BlueSkyDefender/Depth3D

My PayPal Me Link If you like to donate paypal.me/BlueSkyDefender

Also my steam page steamcommunity.com/id/BlueSkyDefender

Discord Server discord.gg/W2f7YhX
Last Edit: 1 year 7 months ago by BlueSkyKnight.
The administrator has disabled public write access.

So..TAA with SMAA possible with shaders? Seems so! 1 year 7 months ago #27

BlueSkyKnight wrote:
Ok, so Necroing this thread.

Temporal AA (aka Motion Blur) based on Epic Games' implementation:

de45xmedrsdbp.cloudfront.net/Resources/f...A_small-59732822.pdf

Originally written by yvt for www.shadertoy.com/view/4tcXD2

This one works....... well.... still needs work.

// Temporal AA (aka Motion Blur) based on Epic Games' implementation:
// https://de45xmedrsdbp.cloudfront.net/Resources/files/TemporalAA_small-59732822.pdf
// 
// Originally written by yvt for https://www.shadertoy.com/view/4tcXD2
// Feel free to use this in your shader!

uniform int Motion_Blur <
	ui_type = "combo";
	ui_items = "Off\0On\0";
	ui_label = "Motion Blur Max";
> = false;

/////////////////////////////////////////////D3D Starts Here/////////////////////////////////////////////////////////////////
texture BackBufferTex : COLOR;

sampler BackBuffer 
	{ 
		Texture = BackBufferTex;
	};
	
texture PastBackBuffer  { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA32F;}; 

sampler PastBB
	{
		Texture = PastBackBuffer;
	};
///////////////////////////////////////////////////////////TAA/////////////////////////////////////////////////////////////////////	
#define pix float2(BUFFER_RCP_WIDTH, BUFFER_RCP_HEIGHT)
#define iResolution float2(BUFFER_WIDTH, BUFFER_HEIGHT)

// YUV-RGB conversion routine from Hyper3D
float3 encodePalYuv(float3 rgb)
{
    return float3(
        dot(rgb, float3(0.299, 0.587, 0.114)),
        dot(rgb, float3(-0.14713, -0.28886, 0.436)),
        dot(rgb, float3(0.615, -0.51499, -0.10001))
    );
}

float3 decodePalYuv(float3 yuv)
{	

    return float3(
        dot(yuv, float3(1.0, 0., 1.13983)),
        dot(yuv, float3(1.0, -0.39465, -0.58060)),
        dot(yuv, float3(1.0, 2.03211, 0.))
    );
}

float4 TAA_Out(float4 position : SV_Position, float2 texcoord : TEXCOORD) : SV_Target
{
	float2 uv = texcoord;
    float4 lastColor = tex2D(PastBB, uv);//Past Back Buffer
    
    float3 antialiased = lastColor.xyz;
    float mixRate = min(lastColor.w, 0.5);
    
    float2 off = pix;
    float3 in0 = tex2D(BackBuffer, uv).xyz;
    
    antialiased = lerp(antialiased * antialiased, in0 * in0, mixRate);
    antialiased = sqrt(antialiased);
    
    float3 in1 = tex2D(BackBuffer, uv + float2(+off.x, 0.0)).xyz;
    float3 in2 = tex2D(BackBuffer, uv + float2(-off.x, 0.0)).xyz;
    float3 in3 = tex2D(BackBuffer, uv + float2(0.0, +off.y)).xyz;
    float3 in4 = tex2D(BackBuffer, uv + float2(0.0, -off.y)).xyz;
    float3 in5 = tex2D(BackBuffer, uv + float2(+off.x, +off.y)).xyz;
    float3 in6 = tex2D(BackBuffer, uv + float2(-off.x, +off.y)).xyz;
    float3 in7 = tex2D(BackBuffer, uv + float2(+off.x, -off.y)).xyz;
    float3 in8 = tex2D(BackBuffer, uv + float2(-off.x, -off.y)).xyz;
    
    antialiased = encodePalYuv(antialiased);
    in0 = encodePalYuv(in0);
    in1 = encodePalYuv(in1);
    in2 = encodePalYuv(in2);
    in3 = encodePalYuv(in3);
    in4 = encodePalYuv(in4);
    in5 = encodePalYuv(in5);
    in6 = encodePalYuv(in6);
    in7 = encodePalYuv(in7);
    in8 = encodePalYuv(in8);
    
    float MB;
    if(Motion_Blur)//Ugly hack
    MB = 1;
    
    float3 minColor = min(min(min(in0, in1), min(in2, in3)), in4) - MB;
    float3 maxColor = max(max(max(in0, in1), max(in2, in3)), in4) + MB;
    minColor = lerp(minColor, min(min(min(in5, in6), min(in7, in8)), minColor), 0.5);
    maxColor = lerp(maxColor, max(max(max(in5, in6), max(in7, in8)), maxColor), 0.5);
    
   	float3 preclamping = antialiased;
    antialiased = clamp(antialiased, minColor, maxColor);
    
    mixRate = 1.0 / (1.0 / mixRate + 1.0);
    
    float3 diff = antialiased - preclamping;
    float clampAmount = dot(diff, diff);
    
    mixRate += clampAmount * 4.0;
    mixRate = clamp(mixRate, 0.05, 0.5);
    
    antialiased = decodePalYuv(antialiased);
        
    return float4(antialiased, mixRate);
}

float4 Past_BackBuffer(float4 position : SV_Position, float2 texcoord : TEXCOORD) : SV_Target
{
	return tex2D(BackBuffer,texcoord);
}

///////////////////////////////////////////////////////////ReShade.fxh/////////////////////////////////////////////////////////////
// Vertex shader generating a triangle covering the entire screen
void PostProcessVS(in uint id : SV_VertexID, out float4 position : SV_Position, out float2 texcoord : TEXCOORD)
{
	texcoord.x = (id == 2) ? 2.0 : 0.0;
	texcoord.y = (id == 1) ? 2.0 : 0.0;
	position = float4(texcoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
}
technique TAA
	{
			pass TAAOut
		{
			VertexShader = PostProcessVS;
			PixelShader = TAA_Out;
		}
			pass PBB
		{
			VertexShader = PostProcessVS;
			PixelShader = Past_BackBuffer;
			RenderTarget = PastBackBuffer;
		}
	}

It makes a better Motion blur shader than anything else. I have a suspicion that the way I added the previous fame may be delayed too long.

Still, need to add Jitter and some other things. But, I listed this here because there are very talented Shader Devs here. So if they want to use this as a base Go ahead.

There still some Ghosting so.... Expect that. Ignore the old shader.... I was Veary sick when I made that lol..... :dry:

What part of the shader controls the frame duration / motion blur intensity?

Just so i can add UI values for that here and play around with them.
The administrator has disabled public write access.

So..TAA with SMAA possible with shaders? Seems so! 1 year 7 months ago #28

matsilagi wrote:

What part of the shader controls the frame duration / motion blur intensity?

Just so i can add UI values for that here and play around with them.

I guess I can. I Hacked in an Ugly way of increasing the Motion Blur. I will just change it to a Slider. I didn't want to work on this too much it's just research I did into making a fast Cheap AA. Since I am looking for one that works on top of Line interlaced content.

I will do this tonight.

when Maxing it out it has this cool effect on people walking around in the game. Like people moving around like the flash. I guess it can be used for Machinima.
My GitHub page where you can get the Latest release of SuperDepth3D github.com/BlueSkyDefender/Depth3D

My PayPal Me Link If you like to donate paypal.me/BlueSkyDefender

Also my steam page steamcommunity.com/id/BlueSkyDefender

Discord Server discord.gg/W2f7YhX
Last Edit: 1 year 7 months ago by BlueSkyKnight.
The administrator has disabled public write access.

So..TAA with SMAA possible with shaders? Seems so! 1 year 7 months ago #29

BlueSkyKnight wrote:
matsilagi wrote:

What part of the shader controls the frame duration / motion blur intensity?

Just so i can add UI values for that here and play around with them.

I guess I can. I Hacked in an Ugly way of increasing the Motion Blur. I will just change it to a Slider. I didn't want to work on this too much it's just research I did into making a fast Cheap AA. Since I am looking for one that works on top of Line interlaced content.

I will do this tonight.

when Maxing it out it has this cool effect on people walking around in the game. Like people moving around like the flash. I guess it can be used for Machinima.

Thanks a lot, i need to make it a bit less intense (the frame time), so it blurs less.
In its current state, it kinda works nice as a Motion blur and AA method but, its hard to use in Racing Games.
The administrator has disabled public write access.

So..TAA with SMAA possible with shaders? Seems so! 1 year 7 months ago #30

Still working on Randomized Halton Jitter I probaly work on that tomorrow.
// Temporal AA (aka Motion Blur) -=WIP=- based on Epic Games' implementation:
// https://de45xmedrsdbp.cloudfront.net/Resources/files/TemporalAA_small-59732822.pdf
// 
// Originally written by yvt for https://www.shadertoy.com/view/4tcXD2
// Feel free to use this in your shader!

uniform float Motion_Blur <
	ui_type = "drag";
	ui_min = -0.005; ui_max = 1.0;
	ui_label = "Motion_Blur Adjust";
	ui_tooltip = "Adjust Motion Blur Power.\n" 
				 "Default is Zero.";
> = 0.0;

//uniform int BackBuffer_Selection <
	//ui_type = "combo";
	//ui_items = "Past Single BackBuffer\0Past BackBuffer\0";
	//ui_label = "Past BackBuffer Selector";
	//ui_tooltip = "Past texture selection for TAA Shader.";
//> = 0;

/////////////////////////////////////////////D3D Starts Here/////////////////////////////////////////////////////////////////
texture BackBufferTex : COLOR;

sampler BackBuffer 
	{ 
		Texture = BackBufferTex;
	};
	
texture CurrentBackBuffer  { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA32F;}; 

sampler CBackBuffer
	{
		Texture = CurrentBackBuffer;
	};
	
texture PastBackBuffer  { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA32F;}; 

sampler PBackBuffer
	{
		Texture = PastBackBuffer;
	};

texture PastSingleBackBuffer  { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA32F;}; 

sampler PSBackBuffer
	{
		Texture = PastSingleBackBuffer;
	};
	
///////////////////////////////////////////////////////////TAA/////////////////////////////////////////////////////////////////////	
#define pix float2(BUFFER_RCP_WIDTH, BUFFER_RCP_HEIGHT)
#define iResolution float2(BUFFER_WIDTH, BUFFER_HEIGHT)

// YUV-RGB conversion routine from Hyper3D
float3 encodePalYuv(float3 rgb)
{
    return float3(
        dot(rgb, float3(0.299, 0.587, 0.114)),
        dot(rgb, float3(-0.14713, -0.28886, 0.436)),
        dot(rgb, float3(0.615, -0.51499, -0.10001))
    );
}

float3 decodePalYuv(float3 yuv)
{	

    return float3(
        dot(yuv, float3(1.0, 0., 1.13983)),
        dot(yuv, float3(1.0, -0.39465, -0.58060)),
        dot(yuv, float3(1.0, 2.03211, 0.))
    );
}

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

float4 TAA_Out(float4 position : SV_Position, float2 texcoord : TEXCOORD) : SV_Target
{	
	//Randomized Halton Array WIP
	float HaltonNumArray[7] = {-1, 1, 2, 3, 0, 1, 2};
	
    float randomA = random(texcoord);
    float randomB = random(texcoord);
    int indexA = int(randomA);
    int indexB = int(randomB);
	float2 XY = float2(HaltonNumArray[indexA],HaltonNumArray[indexB]);
	// WIP
	
	float2 uv = texcoord;
    float4 lastColor = tex2D(PBackBuffer, uv);//Past Back Buffer
        
    //if(BackBuffer_Selection) 
    //lastColor = tex2D(PBackBuffer, uv);
    
    float3 antialiased = lastColor.xyz;
    float mixRate = min(lastColor.w, 0.5);
    
    float2 off = pix;
    float3 in0 = tex2D(BackBuffer, uv).xyz;
    
    antialiased = lerp(antialiased * antialiased, in0 * in0, mixRate);
    antialiased = sqrt(antialiased);
    
    float3 in1 = tex2D(BackBuffer, uv + float2(+off.x, 0.0)).xyz;
    float3 in2 = tex2D(BackBuffer, uv + float2(-off.x, 0.0)).xyz;
    float3 in3 = tex2D(BackBuffer, uv + float2(0.0, +off.y)).xyz;
    float3 in4 = tex2D(BackBuffer, uv + float2(0.0, -off.y)).xyz;
    float3 in5 = tex2D(BackBuffer, uv + float2(+off.x, +off.y)).xyz;
    float3 in6 = tex2D(BackBuffer, uv + float2(-off.x, +off.y)).xyz;
    float3 in7 = tex2D(BackBuffer, uv + float2(+off.x, -off.y)).xyz;
    float3 in8 = tex2D(BackBuffer, uv + float2(-off.x, -off.y)).xyz;
    
    antialiased = encodePalYuv(antialiased);
    in0 = encodePalYuv(in0);
    in1 = encodePalYuv(in1);
    in2 = encodePalYuv(in2);
    in3 = encodePalYuv(in3);
    in4 = encodePalYuv(in4);
    in5 = encodePalYuv(in5);
    in6 = encodePalYuv(in6);
    in7 = encodePalYuv(in7);
    in8 = encodePalYuv(in8);
    
    float MB = Motion_Blur; //Ugly hack
    
    float3 minColor = min(min(min(in0, in1), min(in2, in3)), in4) - MB;
    float3 maxColor = max(max(max(in0, in1), max(in2, in3)), in4) + MB;
    minColor = lerp(minColor, min(min(min(in5, in6), min(in7, in8)), minColor), 0.5);
    maxColor = lerp(maxColor, max(max(max(in5, in6), max(in7, in8)), maxColor), 0.5);
    
   	float3 preclamping = antialiased;
    antialiased = clamp(antialiased, minColor, maxColor);
    
    mixRate = 1.0 / (1.0 / mixRate + 1.0);
    
    float3 diff = antialiased - preclamping;
    float clampAmount = dot(diff, diff);
    
    mixRate += clampAmount * 4.0;
    mixRate = clamp(mixRate, 0.05, 0.5);
    
    antialiased = decodePalYuv(antialiased);
        
    return float4(antialiased, mixRate);
}

void Current_BackBuffer(float4 position : SV_Position, float2 texcoord : TEXCOORD, out float4 color : SV_Target)
{
	color = tex2D(BackBuffer,texcoord);
}

void Past_BackBuffer(float4 position : SV_Position, float2 texcoord : TEXCOORD, out float4 PastSingle : SV_Target0, out float4 Past : SV_Target1)
{
	PastSingle = tex2D(CBackBuffer,texcoord);
	Past = tex2D(BackBuffer,texcoord);
}

///////////////////////////////////////////////////////////ReShade.fxh/////////////////////////////////////////////////////////////
// Vertex shader generating a triangle covering the entire screen
void PostProcessVS(in uint id : SV_VertexID, out float4 position : SV_Position, out float2 texcoord : TEXCOORD)
{
	texcoord.x = (id == 2) ? 2.0 : 0.0;
	texcoord.y = (id == 1) ? 2.0 : 0.0;
	position = float4(texcoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
}
technique TAA
	{
			pass CBB
		{
			VertexShader = PostProcessVS;
			PixelShader = Current_BackBuffer;
			RenderTarget = CurrentBackBuffer;
		}
			pass TAAOut
		{
			VertexShader = PostProcessVS;
			PixelShader = TAA_Out;
		}
			pass PBB
		{
			VertexShader = PostProcessVS;
			PixelShader = Past_BackBuffer;
			RenderTarget0 = PastSingleBackBuffer;
			RenderTarget1 = PastBackBuffer;
			
		}
	}
My GitHub page where you can get the Latest release of SuperDepth3D github.com/BlueSkyDefender/Depth3D

My PayPal Me Link If you like to donate paypal.me/BlueSkyDefender

Also my steam page steamcommunity.com/id/BlueSkyDefender

Discord Server discord.gg/W2f7YhX
Last Edit: 1 year 7 months ago by BlueSkyKnight.
The administrator has disabled public write access.
The following user(s) said Thank You: andrew, alex, cbdeakin

So..TAA with SMAA possible with shaders? Seems so! 1 year 7 months ago #31

would be nice if you can make it work with less effect, even at the lowest value (-0.005) it gives headache when playing any fps but maybe at lower values could work. it also bugs out with everything becoming green if you go under the minimal -0.005.
Last Edit: 1 year 7 months ago by alex.
The administrator has disabled public write access.

So..TAA with SMAA possible with shaders? Seems so! 1 year 2 months ago #32

Hey BlueSkyKnight,

Is there any chance you could improve the shader?

Thanks!
The administrator has disabled public write access.

So..TAA with SMAA possible with shaders? Seems so! 1 year 2 months ago #33

hi.. I don´t know about shader code.. but vissually I see a big difference in shaders.. when mix TAA with the Kuwahara shaders I see an improvement; the motion blur almost gone.. I put the kuwahara at top of list and TAA to end.. could you revise this coincidence?
Last Edit: 1 year 2 months ago by Scorpio82CO.
The administrator has disabled public write access.

So..TAA with SMAA possible with shaders? Seems so! 1 year 2 months ago #34

Scorpio82CO wrote:
hi.. I don´t know about shader code.. but vissually I see a big difference in shaders.. when mix TAA with the Kuwahara shaders I see an improvement; the motion blur almost gone.. I put the kuwahara at top of list and TAA to end.. could you revise this coincidence?


It is really ? i think is strange.
The administrator has disabled public write access.

So..TAA with SMAA possible with shaders? Seems so! 1 year 2 months ago #35

well.. try it!.. I made it in assassins creed..! and I see that difference
The administrator has disabled public write access.

So..TAA with SMAA possible with shaders? Seems so! 1 year 2 months ago #36

and another games ?
The administrator has disabled public write access.

So..TAA with SMAA possible with shaders? Seems so! 1 year 2 months ago #37

BobMarkinson wrote:
Hey BlueSkyKnight,

Is there any chance you could improve the shader?

Thanks!


Here try this. What I did is make a mask to highlight where aliasing should be and used the AA part of the first code to fill that part in. It not pretty. Also, no promises.
// Temporal AA *Modded* (aka Motion Blur) -=WIP=- based on Epic Games' implementation:
// https://de45xmedrsdbp.cloudfront.net/Resources/files/TemporalAA_small-59732822.pdf
// 
// Originally written by yvt for https://www.shadertoy.com/view/4tcXD2
// Feel free to use this in your shader!

uniform float Jitter_Ammount <
	ui_type = "drag";
	ui_min = 0.0; ui_max = 1.0;
	ui_label = "Jitter Ammount";
	ui_tooltip = "Adjust Randomized Halton base(2,3) Jitter.\n" 
				 "Default is 0.5.";
> = 0.5;

uniform float Seeking <
	ui_type = "drag";
	ui_min = 0.025; ui_max = 0.250;
	ui_label = "Seeking";
	ui_tooltip = "Default is 0.150";
> = 0.150;

uniform int DebugOutput <
	ui_type = "combo";
	ui_items = "Off\0On\0";
	ui_label = "Debug Output";
> = false;

/////////////////////////////////////////////D3D Starts Here/////////////////////////////////////////////////////////////////
texture BackBufferTex : COLOR;

sampler BackBuffer 
	{ 
		Texture = BackBufferTex;
	};
		
texture PastBackBuffer  { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA8;}; 

sampler PBackBuffer
	{
		Texture = PastBackBuffer;
	};
	
texture TAABackBuffer  { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA8;}; 

sampler BackBufferTAA
	{
		Texture = TAABackBuffer;
	};	
///////////////////////////////////////////////////////////TAA/////////////////////////////////////////////////////////////////////	
#define pix float2(BUFFER_RCP_WIDTH, BUFFER_RCP_HEIGHT)
#define iResolution float2(BUFFER_WIDTH, BUFFER_HEIGHT)

// YUV-RGB conversion routine from Hyper3D
float3 encodePalYuv(float3 rgb)
{
	float3 RGB2Y =  float3( 0.299, 0.587, 0.114);
	float3 RGB2Cb = float3(-0.14713, -0.28886, 0.436);
	float3 RGB2Cr = float3(0.615,-0.51499,-0.10001);

	return float3(dot(rgb, RGB2Y), dot(rgb, RGB2Cb), dot(rgb, RGB2Cr));
}

float3 decodePalYuv(float3 ycc)
{	
	float3 YCbCr2R = float3( 1.000, 0.000, 1.13983);
	float3 YCbCr2G = float3( 1.000,-0.39465,-0.58060);
	float3 YCbCr2B = float3( 1.000, 2.03211, 0.000);
	return float3(dot(ycc, YCbCr2R), dot(ycc, YCbCr2G), dot(ycc, YCbCr2B));
}

//Randomized Halton
uniform int random < source = "random"; min = -128; max = 128; >;

float Halton(float i, float base)
{
  float x = 1.0f / base;
  float v = 0.0f;
  while (i > 0)
  {
    v += x * (i % base);
    i = floor(i / base);
    x /= base;
  }
  return v;
}

float4 TAA(float4 position : SV_Position, float2 texcoord : TEXCOORD) : SV_Target
{	

	float2 XY = float2(random,random);
	//Randomized Halton base(2,3)
	XY = float2(Halton(XY.x, 2),Halton(XY.y, 3));
	XY = XY * (pix * Jitter_Ammount);
	
    float4 PastColor = tex2D(PBackBuffer,texcoord + XY);//Past Back Buffer
    
    float3 antialiased = PastColor.xyz;
    float mixRate = min(PastColor.w, 0.5);
	
    float3 in0 = tex2D(BackBuffer, texcoord).xyz;
        
    antialiased = lerp(antialiased * antialiased, in0 * in0, mixRate);
    antialiased = sqrt(antialiased);
    antialiased = encodePalYuv(antialiased);
    
    float3 in1 = tex2D(BackBuffer, texcoord + float2(+pix.x, 0.0)).xyz;
    float3 in2 = tex2D(BackBuffer, texcoord + float2(-pix.x, 0.0)).xyz;
    float3 in3 = tex2D(BackBuffer, texcoord + float2(0.0, +pix.y)).xyz;
    float3 in4 = tex2D(BackBuffer, texcoord + float2(0.0, -pix.y)).xyz;
    float3 in5 = tex2D(BackBuffer, texcoord + float2(+pix.x, +pix.y)).xyz;
    float3 in6 = tex2D(BackBuffer, texcoord + float2(-pix.x, +pix.y)).xyz;
    float3 in7 = tex2D(BackBuffer, texcoord + float2(+pix.x, -pix.y)).xyz;
    float3 in8 = tex2D(BackBuffer, texcoord + float2(-pix.x, -pix.y)).xyz; 
    
    in0 = encodePalYuv(in0);
    in1 = encodePalYuv(in1);
    in2 = encodePalYuv(in2);
    in3 = encodePalYuv(in3);
    in4 = encodePalYuv(in4);
    in5 = encodePalYuv(in5);
    in6 = encodePalYuv(in6);
    in7 = encodePalYuv(in7);
    in8 = encodePalYuv(in8);
    
    float3 minColor = min(min(min(in0, in1), min(in2, in3)), in4);
    float3 maxColor = max(max(max(in0, in1), max(in2, in3)), in4);
    minColor = lerp(minColor, min(min(min(in5, in6), min(in7, in8)), minColor), 0.5);
    maxColor = lerp(maxColor, max(max(max(in5, in6), max(in7, in8)), maxColor), 0.5);

    antialiased = clamp(antialiased, minColor, maxColor);
    
    antialiased = decodePalYuv(antialiased);
      
	return float4(antialiased,0);
}

void Out(float4 position : SV_Position, float2 texcoord : TEXCOORD, out float4 color : SV_Target)
{   

    const float2 XYoffset[6] = { float2( 0, +1 ), float2( 0, -1 ), float2(+1,  0 ), float2(-1,  0),float2(-1,  -1),float2(+1,  +1)};

	float4 center_color = tex2D(BackBuffer, texcoord);

	float4 neighbor_sum = center_color;

	for (int i = 0; i < 6; i++)
	{
		float4 neighbor = tex2D(BackBuffer, texcoord + XYoffset[i] * pix );
		
		float3 color_diff = abs(neighbor.xyz - center_color.xyz);
		
		float3 ycc = encodePalYuv(color_diff.xyz);
		
		float cbcr_threshhold = Seeking;
		
		float cbcr_len = length(color_diff.yz);
		
		if (cbcr_threshhold < cbcr_len)
		{
			ycc = (cbcr_threshhold / cbcr_len) * ycc;
			
			neighbor.rgb = decodePalYuv(ycc);
		}
		
		neighbor_sum += neighbor;
	}
	float4 FinColor = neighbor_sum / 7.0f;
	
    FinColor = length(abs(FinColor-center_color));
    
    float Mask = 1-saturate(dot(FinColor,FinColor * 100)< 1);
    
    float4 Done;
	if(!DebugOutput)
	{
		Done = lerp(center_color,tex2D(BackBufferTAA,texcoord),Mask);
	}
	else
	{
		Done = Mask.xxxx;
	}
    
	color = Done;
}

void Past_BackBuffer(float4 position : SV_Position, float2 texcoord : TEXCOORD, out float4 Past : SV_Target)
{
	Past = tex2D(BackBuffer,texcoord);
}

///////////////////////////////////////////////////////////ReShade.fxh/////////////////////////////////////////////////////////////
// Vertex shader generating a triangle covering the entire screen
void PostProcessVS(in uint id : SV_VertexID, out float4 position : SV_Position, out float2 texcoord : TEXCOORD)
{
	texcoord.x = (id == 2) ? 2.0 : 0.0;
	texcoord.y = (id == 1) ? 2.0 : 0.0;
	position = float4(texcoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
}
technique TAA
	{
			pass TAA
		{
			VertexShader = PostProcessVS;
			PixelShader = TAA;
			RenderTarget = TAABackBuffer;
		}
			pass Out
		{
			VertexShader = PostProcessVS;
			PixelShader = Out;
		}
			pass PBB
		{
			VertexShader = PostProcessVS;
			PixelShader = Past_BackBuffer;
			RenderTarget = PastBackBuffer;
			
		}
	}

Turned out harder than expected. But, at least I did learn a bit about SSAA.
My GitHub page where you can get the Latest release of SuperDepth3D github.com/BlueSkyDefender/Depth3D

My PayPal Me Link If you like to donate paypal.me/BlueSkyDefender

Also my steam page steamcommunity.com/id/BlueSkyDefender

Discord Server discord.gg/W2f7YhX
Last Edit: 1 year 2 months ago by BlueSkyKnight.
The administrator has disabled public write access.

So..TAA with SMAA possible with shaders? Seems so! 1 year 2 months ago #38

Just tried it out, the mask works well! Yet the parts that get AA'ed seem to be quite blurred and the AA method is barely working on edges that are clearly aliased. Could you use the existing SMAA or FXAA code and adapt it to this? I really have no idea how this all works, sorry. :)
The administrator has disabled public write access.

So..TAA with SMAA possible with shaders? Seems so! 1 year 2 months ago #39

Hey @BlueSkyKnight :) , have you heard of "TSCMAA"?
I'm really curious what your thoughts/opinons of it are...

software.intel.com/en-us/articles/tempor...anti-aliasing-tscmaa
The administrator has disabled public write access.

So..TAA with SMAA possible with shaders? Seems so! 11 months 3 weeks ago #40

Well,, I see.. I was wrong, gives an interesting result with the hq4x filter shader in any lastest versions, gives better results of bleeding, can you check this?
Sorry for the mistake..!!
Last Edit: 11 months 3 weeks ago by Scorpio82CO.
The administrator has disabled public write access.