Ported ReShade 2.x effects
- crosire
Please Log in or Create an account to join the conversation.
- mbah.primbon
Please Log in or Create an account to join the conversation.
First one is SSDO from Euda's PPFX, it works amazingly on all renderers. However, i don't think it has any advantage over other AO methods posted here.
#include "ReShade.fxh"
uniform float ssdoIntensity <
ui_type = "drag";
ui_min = 0.001;
ui_max = 20.000;
ui_step = 0.001;
ui_label = "SSDO Intensity";
> = 2.000;
uniform float ssdoAmount <
ui_type = "drag";
ui_min = 0.001;
ui_max = 20.000;
ui_step = 0.001;
ui_label = "SSDO Amount";
> = 1.000;
uniform float ssdoAOMix <
ui_type = "drag";
ui_min = 0.000;
ui_max = 1.000;
ui_step = 0.001;
ui_label = "SSDO Ambient Occlusion Mix";
> = 1.000;
uniform float ssdoILMix <
ui_type = "drag";
ui_min = 0.000;
ui_max = 1.000;
ui_step = 0.001;
ui_label = "SSDO Indirect Lighting Mix";
> = 1.000;
uniform float ssdoBounceMultiplier <
ui_type = "drag";
ui_min = 0.000;
ui_max = 1.000;
ui_step = 0.001;
ui_label = "SSDO Indirect Bounce Color Multiplier";
> = 1.000;
uniform float ssdoBounceSaturation <
ui_type = "drag";
ui_min = 0.000;
ui_max = 20.000;
ui_step = 0.001;
ui_label = "SSDO Indirect Bounce Color Saturation";
> = 3.000;
uniform int ssdoSampleAmount <
ui_type = "drag";
ui_min = 2;
ui_max = 250;
ui_step = 1;
ui_label = "SSDO Sample Amount";
> = 16;
uniform float ssdoSampleRange <
ui_type = "drag";
ui_min = 4.000;
ui_max = 400.000;
ui_step = 0.001;
ui_label = "SSDO Sample Range";
> = 50.5;
uniform float ssdoFilterScale <
ui_type = "drag";
ui_min = 0.1;
ui_max = 4.0;
ui_step = 0.1;
ui_label = "SSDO Filter Scale Factor";
> = 1.0;
uniform int ssdoFilterRadius <
ui_type = "drag";
ui_min = 2;
ui_max = 100;
ui_step = 1;
ui_label = "SSDO Filter Radius";
> = 12;
uniform int ssdoFilterStep <
ui_type = "drag";
ui_min = 1;
ui_max = 16;
ui_step = 1;
ui_label = "SSDO Filter Step";
> = 1;
uniform float3 ssdoLightPos <
ui_type = "drag";
ui_min = 0.0;
ui_max = 1.0;
ui_step = 0.001;
ui_label = "SSDO Light Pos";
> = float3(0.0,0.2,0.8);
uniform int ssdoMixMode <
ui_type = "drag";
ui_min = 1;
ui_max = 2;
ui_step = 1;
ui_label = "SSDO Mix Mode";
> = 1;
uniform int ssdoDebugMode <
ui_type = "combo";
ui_items = "Off\0Filtered SSDO\0Raw SSDO\0";
ui_label = "SSDO Debug Mode";
> = 0;
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef ssdoSourceLOD
#define ssdoSourceLOD 0 // SSDO Source LOD - The Mipmap-level of the source texture used to calculate the occlusion/indirect light. 0 = full resolution, 1 = half-axis resolution, 2 = quarter-axis resolution etc. Combined with high SampleRange-values, this may improve performance with a slight loss of quality | 0 - 3
#endif
#ifndef ssdoBounceLOD
#define ssdoBounceLOD 3 // SSDO Source LOD - The Mipmap-level of the color texture used to calculate the light bounces. 0 = full resolution, 1 = half-axis resolution, 2 = quarter-axis resolution etc. Combined with high SampleRange-values, this may improve performance with a slight loss of quality | 0 - 3
#endif
#ifndef ssdoLOD
#define ssdoLOD 0 // SSDO LOD - The resolution which the effect is calculated in. 0 = full-screen, 1 = half, 2 = quarter, 3 = one-eighth
#endif
static const float2 pxSize = float2(BUFFER_RCP_WIDTH,BUFFER_RCP_HEIGHT);
static const float3 lumaCoeff = float3(0.2126f,0.7152f,0.0722f);
#ifndef ZNEAR
#define ZNEAR 0.3
#endif
#ifndef ZFAR
#define ZFAR 50.0
#endif
#define NOISE_SCREENSCALE float2((BUFFER_WIDTH/pow(2.0,ssdoLOD))/256.0,(BUFFER_HEIGHT/pow(2.0,ssdoLOD))/256.0)
texture texColorHDRA { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA16F; };
texture texColorHDRB { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA16F; };
texture texColorLOD { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA8; MipLevels = 4; };
texture texViewSpace
{
Width = BUFFER_WIDTH;
Height = BUFFER_HEIGHT;
Format = RGBA16F;
MipLevels = 4;
};
texture texSSDOA
{
Width = BUFFER_WIDTH/pow(2.0,ssdoLOD);
Height = BUFFER_HEIGHT/pow(2.0,ssdoLOD);
Format = RGBA16;
};
texture texSSDOB
{
Width = BUFFER_WIDTH*1;
Height = BUFFER_HEIGHT*1;
Format = RGBA16;
};
texture texSSDOC
{
Width = BUFFER_WIDTH*1;
Height = BUFFER_HEIGHT*1;
Format = RGBA16;
};
texture texNoise < source = "ppfx_noise.png"; >
{
Width = 256;
Height = 256;
};
////////////////////////////////////////////////////////////////////
sampler SamplerColorHDRA
{
Texture = texColorHDRA;
AddressU = BORDER;
AddressV = BORDER;
MinFilter = LINEAR;
MagFilter = LINEAR;
};
sampler SamplerColorHDRB
{
Texture = texColorHDRB;
AddressU = BORDER;
AddressV = BORDER;
MinFilter = LINEAR;
MagFilter = LINEAR;
};
sampler SamplerColorLOD
{
Texture = texColorLOD;
};
sampler SamplerViewSpace
{
Texture = texViewSpace;
MipFilter = NONE;
};
sampler SamplerSSDOA
{
Texture = texSSDOA;
};
sampler SamplerSSDOB
{
Texture = texSSDOB;
};
sampler SamplerSSDOC
{
Texture = texSSDOC;
};
sampler SamplerNoise
{
Texture = texNoise;
MipFilter = NONE;
MinFilter = NONE;
MagFilter = NONE;
};
////////////////////////////////////////////////////////////////////////////////////////////////
struct VS_OUTPUT_POST
{
float4 vpos : SV_Position;
float2 txcoord : TEXCOORD0;
};
struct VS_INPUT_POST
{
uint id : SV_VertexID;
};
VS_OUTPUT_POST VS_PostProcess(VS_INPUT_POST IN)
{
VS_OUTPUT_POST OUT;
OUT.txcoord.x = (IN.id == 2) ? 2.0 : 0.0;
OUT.txcoord.y = (IN.id == 1) ? 2.0 : 0.0;
OUT.vpos = float4(OUT.txcoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
return OUT;
}
//////////////////////////////////////////////////////////////////////////////////////////////////
float3 threshold(float3 pxInput, float colThreshold)
{
return pxInput*max(0.0,sign(max(pxInput.x,max(pxInput.y,pxInput.z))-colThreshold));
}
float3 GetPosition(float2 coords)
{
float EyeDepth = ReShade::GetLinearizedDepth(coords.xy)*RESHADE_DEPTH_LINEARIZATION_FAR_PLANE;
return float3((coords.xy * 2.0 - 1.0)*EyeDepth,EyeDepth);
}
float3 GetNormalFromDepth(float2 coords)
{
float3 centerPos = GetPosition(coords.xy);
float2 offs = ReShade::PixelSize;
float3 ddx1 = GetPosition(coords.xy + float2(offs.x, 0)) - centerPos;
float3 ddx2 = centerPos - GetPosition(coords.xy + float2(-offs.x, 0));
float3 ddy1 = GetPosition(coords.xy + float2(0, offs.y)) - centerPos;
float3 ddy2 = centerPos - GetPosition(coords.xy + float2(0, -offs.y));
ddx1 = lerp(ddx1, ddx2, abs(ddx1.z) > abs(ddx2.z));
ddy1 = lerp(ddy1, ddy2, abs(ddy1.z) > abs(ddy2.z));
float3 normal = cross(ddy1, ddx1);
return normalize(normal);
}
#define SSDO_CONTRIB_RANGE (ssdoSampleRange*pxSize.y)
#define SSDO_BLUR_DEPTH_DISCONTINUITY_THRESH_MULTIPLIER 0.05
// SSDO - Scatter Illumination
float4 FX_ssdoScatter( float2 txCoords )
{
float sourceAxisDiv = pow(2.0,ssdoSourceLOD);
float2 texelSize = pxSize*pow(2.0,ssdoSourceLOD);
float4 vsOrig = tex2D(SamplerViewSpace,txCoords);
float3 ssdo = 0.0;
float2 randomDir = tex2D(SamplerNoise,frac(txCoords*NOISE_SCREENSCALE)).xy;
[loop]
for (float offs=1.0;offs<=ssdoSampleAmount;offs++)
{
float2 fetchCoords = txCoords+(frac(randomDir*11.139795*offs)*2.0-1.0)*offs*(ssdoSampleRange/(ssdoSampleAmount*sourceAxisDiv))*texelSize;
float4 vsFetch = tex2Dlod(SamplerViewSpace,float4(fetchCoords,0,ssdoSourceLOD));
float3 albedoFetch = tex2Dlod(SamplerColorLOD,float4(fetchCoords,0,ssdoBounceLOD)).xyz;
albedoFetch = lerp(dot(albedoFetch,lumaCoeff),albedoFetch,ssdoBounceSaturation);
albedoFetch /= max(1.0,max(albedoFetch.x,max(albedoFetch.y,albedoFetch.z)));
float3 dirVec = float3(fetchCoords.x-txCoords.x,txCoords.y-fetchCoords.y,vsOrig.w-vsFetch.w);
float illuminationFact = dot(normalize(dirVec),ssdoLightPos);
float visibility = (illuminationFact > 0.0) ? max(0.0,sign(dot(normalize(float3(dirVec.xy,abs(dirVec.z))),vsOrig.xyz))) : 1.0;
float normalDiff = length(vsFetch.xyz-vsOrig.xyz);
if (illuminationFact < 0.0) albedoFetch = 1.0-albedoFetch;
ssdo += clamp(sign(illuminationFact),-ssdoILMix,ssdoAOMix) * (1.0-albedoFetch*ssdoBounceMultiplier) * visibility * (max(0.0,SSDO_CONTRIB_RANGE-length(dirVec))/SSDO_CONTRIB_RANGE) * sign(max(0.0,normalDiff-0.3));
}
return float4(saturate(0.5-(ssdo/ssdoSampleAmount*ssdoAmount)*smoothstep(0.1,0.3,1.0-vsOrig.w)),vsOrig.w);
}
// Depth-Bilateral Gaussian Blur - Horizontal
float4 FX_BlurBilatH( float2 txCoords, float radius )
{
float texelSize = pxSize.x/ssdoFilterScale;
float4 pxInput = tex2D(SamplerSSDOB,txCoords);
pxInput.xyz *= 0.5;
float sampleSum = 0.5;
float weightDiv = 1.0+2.0/radius;
for (float hOffs=1.5; hOffs<radius; hOffs+=2.0*ssdoFilterStep)
{
float weight = 1.0/pow(weightDiv,hOffs*hOffs/radius);
float2 fetchCoords = txCoords;
fetchCoords.x += texelSize * hOffs;
float4 fetch = tex2Dlod(SamplerSSDOB,float4(fetchCoords,0,0));
float contribFact = max(0.0,sign(SSDO_CONTRIB_RANGE*SSDO_BLUR_DEPTH_DISCONTINUITY_THRESH_MULTIPLIER-abs(pxInput.w-fetch.w))) * weight;
pxInput.xyz+=fetch.xyz * contribFact;
sampleSum += contribFact;
fetchCoords = txCoords;
fetchCoords.x -= texelSize * hOffs;
fetch = tex2Dlod(SamplerSSDOB,float4(fetchCoords,0,0));
contribFact = max(0.0,sign(SSDO_CONTRIB_RANGE*SSDO_BLUR_DEPTH_DISCONTINUITY_THRESH_MULTIPLIER-abs(pxInput.w-fetch.w))) * weight;
pxInput.xyz+=fetch.xyz * contribFact;
sampleSum += contribFact;
}
pxInput.xyz /= sampleSum;
return pxInput;
}
// Depth-Bilateral Gaussian Blur - Vertical
float3 FX_BlurBilatV( float2 txCoords, float radius )
{
float texelSize = pxSize.y/ssdoFilterScale;
float4 pxInput = tex2D(SamplerSSDOC,txCoords);
pxInput.xyz *= 0.5;
float sampleSum = 0.5;
float weightDiv = 1.0+2.0/radius;
for (float vOffs=1.5; vOffs<radius; vOffs+=2.0*ssdoFilterStep)
{
float weight = 1.0/pow(weightDiv,vOffs*vOffs/radius);
float2 fetchCoords = txCoords;
fetchCoords.y += texelSize * vOffs;
float4 fetch = tex2Dlod(SamplerSSDOC,float4(fetchCoords,0,0));
float contribFact = max(0.0,sign(SSDO_CONTRIB_RANGE*SSDO_BLUR_DEPTH_DISCONTINUITY_THRESH_MULTIPLIER-abs(pxInput.w-fetch.w))) * weight;
pxInput.xyz+=fetch.xyz * contribFact;
sampleSum += contribFact;
fetchCoords = txCoords;
fetchCoords.y -= texelSize * vOffs;
fetch = tex2Dlod(SamplerSSDOC,float4(fetchCoords,0,0));
contribFact = max(0.0,sign(SSDO_CONTRIB_RANGE*SSDO_BLUR_DEPTH_DISCONTINUITY_THRESH_MULTIPLIER-abs(pxInput.w-fetch.w))) * weight;
pxInput.xyz+=fetch.xyz * contribFact;
sampleSum += contribFact;
}
pxInput /= sampleSum;
return pxInput.xyz;
}
float4 PS_SetOriginal(VS_OUTPUT_POST IN) : COLOR
{
return float4(tex2D(ReShade::BackBuffer,IN.txcoord.xy).xyz,1.0);
}
float3 PS_ssdoViewSpace(VS_OUTPUT_POST IN) : COLOR
{
return GetNormalFromDepth(IN.txcoord.xy);
}
float4 PS_ssdoScatter(VS_OUTPUT_POST IN) : COLOR
{
return FX_ssdoScatter(IN.txcoord.xy);
}
float4 PS_ssdoBlurScale(VS_OUTPUT_POST IN) : COLOR
{
return tex2D(SamplerSSDOA,IN.txcoord.xy);
}
float4 PS_ssdoBlurH(VS_OUTPUT_POST IN) : COLOR
{
return FX_BlurBilatH(IN.txcoord.xy,ssdoFilterRadius/ssdoFilterStep*ssdoFilterScale);
}
float4 PS_ssdoBlurV(VS_OUTPUT_POST IN) : COLOR
{
return float4(FX_BlurBilatV(IN.txcoord.xy,ssdoFilterRadius/ssdoFilterStep*ssdoFilterScale).xyz,1.0);
}
float4 PS_ssdoMix(VS_OUTPUT_POST IN) : COLOR
{
if (ssdoMixMode != 2 && ssdoDebugMode == 0){
return float4(saturate(tex2D(ReShade::BackBuffer,IN.txcoord.xy).xyz*pow(tex2D(SamplerSSDOB,IN.txcoord.xy).xyz*2.0,ssdoIntensity)),1.0);
} else if (ssdoMixMode == 2 && ssdoDebugMode == 0){
return float4(saturate(tex2D(ReShade::BackBuffer,IN.txcoord.xy).xyz+pow(tex2D(SamplerSSDOB,IN.txcoord.xy).xyz*2.0,ssdoIntensity)-1.0),1.0);
} else if (ssdoMixMode != 2 && ssdoDebugMode == 1){
return float4(saturate(0.5*pow(tex2D(SamplerSSDOB,IN.txcoord.xy).xyz*2.0,ssdoIntensity)),1.0);
} else if (ssdoMixMode == 2 && ssdoDebugMode == 1){
return float4(saturate(0.5+pow(tex2D(SamplerSSDOB,IN.txcoord.xy).xyz*2.0,ssdoIntensity)-1.0),1.0);
} else if (ssdoDebugMode == 2 && ssdoMixMode != 0){
return float4(tex2D(SamplerSSDOA,IN.txcoord.xy).xyz,1.0);
} else {
return float4(tex2D(SamplerSSDOA,IN.txcoord.xy).xyz,1.0);
}
}
technique SSDO {
pass setOriginal
{
VertexShader = VS_PostProcess;
PixelShader = PS_SetOriginal;
RenderTarget0 = texColorLOD;
}
pass ssdoViewSpace
{
VertexShader = VS_PostProcess;
PixelShader = PS_ssdoViewSpace;
RenderTarget0 = texViewSpace;
}
pass ssdoScatter
{
VertexShader = VS_PostProcess;
PixelShader = PS_ssdoScatter;
RenderTarget0 = texSSDOA;
}
pass ssdoBlurScale
{
VertexShader = VS_PostProcess;
PixelShader = PS_ssdoBlurScale;
RenderTarget0 = texSSDOB;
}
pass ssdoBlurH
{
VertexShader = VS_PostProcess;
PixelShader = PS_ssdoBlurH;
RenderTarget0 = texSSDOC;
}
pass ssdoBlurV
{
VertexShader = VS_PostProcess;
PixelShader = PS_ssdoBlurV;
RenderTarget0 = texSSDOB;
}
pass ssdoMix
{
VertexShader = VS_PostProcess;
PixelShader = PS_ssdoMix;
}
}
Second one is Martinsh's DoF, i know it is present on the main DOF shader, but since it was one of the first ever reshade shaders made, i tought it would be cool to have the original one restored.
This one now only has a problem with the depth buffer.
#include "ReShade.fxh"
/*
DoF with bokeh GLSL shader v2.4
by Martins Upitis (martinsh) (devlog-martinsh.blogspot.com)
ported to ReShade by Crosire
----------------------
The shader is Blender Game Engine ready, but it should be quite simple to adapt for your engine.
This work is licensed under a Creative Commons Attribution 3.0 Unported License.
So you are free to share, modify and adapt it for your needs, and even use it for commercial use.
I would also love to hear about a project you are using it.
Have fun,
Martins
----------------------
changelog:
2.4:
- physically accurate DoF simulation calculated from "focalDepth" ,"focalLength", "f-stop" and "CoC" parameters.
- option for artist controlled DoF simulation calculated only from "focalDepth" and individual controls for near and far blur
- added "circe of confusion" (CoC) parameter in mm to accurately simulate DoF with different camera sensor or film sizes
- cleaned up the code
- some optimization
2.3:
- new and physically little more accurate DoF
- two extra input variables - focal length and aperture iris diameter
- added a debug visualization of focus point and focal range
2.1:
- added an option for pentagonal bokeh shape
- minor fixes
2.0:
- variable sample count to increase quality/performance
- option to blur depth buffer to reduce hard edges
- option to dither the samples with noise or pattern
- bokeh chromatic aberration/fringing
- bokeh bias to bring out bokeh edges
- image thresholding to bring out highlights when image is out of focus
*/
//------------------------------------------
//user variables
/*
make sure that these two values are the same for your camera, otherwise distances will be wrong.
*/
uniform float znear <
ui_type = "drag";
ui_min = 0.01;
ui_max = 999.0;
ui_step = 0.01;
ui_label = "Camera Clipping Start [MartinshDoF]";
> = 0.1;
uniform float zfar <
ui_type = "drag";
ui_min = 0.01;
ui_max = 999.0;
ui_step = 0.01;
ui_label = "Camera Clipping End [MartinshDoF]";
> = 100.0;
uniform int samples <
ui_type = "drag";
ui_min = 1;
ui_max = 20;
ui_step = 1;
ui_label = "Samples on the first ring [MartinshDoF]";
> = 3;
uniform int rings <
ui_type = "drag";
ui_min = 1;
ui_max = 25;
ui_label = "Ring Count [MartinshDoF]";
> = 3;
uniform bool MANUALDOF <
ui_type = "boolean";
ui_label = "Enable Manual Depth of Field [MartinshDoF]";
> = false;
uniform float ndofstart <
ui_type = "drag";
ui_min = 0.01;
ui_max = 5.0;
ui_step = 0.01;
ui_label = "Near DoF Blur Start [MartinshDoF~]";
> = 1.0;
uniform float ndofdist <
ui_type = "drag";
ui_min = 0.01;
ui_max = 20.0;
ui_step = 0.01;
ui_label = "Near DoF Blur Falloff Distance [MartinshDoF]";
> = 2.0;
uniform float fdofstart <
ui_type = "drag";
ui_min = 0.001;
ui_max = 15.0;
ui_step = 0.001;
ui_label = "Far DoF Blur Start [MartinshDoF]";
> = 1.0;
uniform float fdofdist <
ui_type = "drag";
ui_min = 0.001;
ui_max = 20.0;
ui_step = 0.001;
ui_label = "Far DoF Blur Falloff Distance [MartinshDoF]";
> = 3.0;
uniform float CoC <
ui_type = "drag";
ui_min = 0.01;
ui_max = 1.00;
ui_step = 0.01;
ui_label = "Circle of Confusion [MartinshDoF]";
ui_tooltip = "Size in mm (35mm = 0.03)";
> = 0.03;
uniform bool VIGNETTING <
ui_type = "boolean";
ui_label = "Enable Lens Vignetting [MartinshDoF]";
> = false;
uniform float vignout <
ui_type = "drag";
ui_min = 0.0;
ui_max = 5.0;
ui_step = 0.001;
ui_label = "Vignetting Outer Border [MartinshDoF]";
> = 1.3;
uniform float vignin <
ui_type = "drag";
ui_min = 0.0;
ui_max = 10.0;
ui_step = 0.01;
ui_label = "Vignetting Inner Border [MartinshDoF]";
> = 0.0;
uniform float vignfade <
ui_type = "drag";
ui_min = 1.0;
ui_max = 100.0;
ui_step = 0.01;
ui_label = "Vignette Fade [MartinshDoF]";
ui_tooltip = "F-Stops until Vignette Fades";
> = 22.0;
uniform bool AUTOFOCUS <
ui_type = "boolean";
ui_label = "Enable Autofocus [MartinshDoF]";
ui_tooltip = "Disable if you use external focalDepth value";
> = true;
uniform float2 focus <
ui_type = "drag";
ui_min = 0.1;
ui_max = 1.0;
ui_step = 0.1;
ui_label = "Autofocus Point on Screen [MartinshDoF]";
> = float2(0.5,0.5);
uniform float maxblur <
ui_type = "drag";
ui_min = 0.0;
ui_max = 1.0;
ui_step = 0.1;
ui_label = "Clamp Value of Max. Blur [MartinshDoF]";
> = 1.0;
uniform float focalDepth <
ui_type = "drag";
ui_min = 0.0;
ui_max = 3.0;
ui_step = 0.1;
ui_label = "Focal Distance Value (in Meters) [MartinshDoF]";
> = 0;
uniform float focalLength <
ui_type = "drag";
ui_min = 10.0;
ui_max = 120.0;
ui_label = "Focal Length in MM [MartinshDoF]";
> = 35;
uniform float fstop <
ui_type = "drag";
ui_min = 0.0;
ui_max = 2.0;
ui_label = "F-Stop Value [MartinshDoF]";
> = 0.9;
uniform float threshold <
ui_type = "drag";
ui_min = 0.1;
ui_max = 10.0;
ui_step = 0.1;
ui_label = "Highlight Threshold [MartinshDoF]";
> = 0.5;
uniform float gain <
ui_type = "drag";
ui_min = 0.1;
ui_max = 5.0;
ui_step = 0.1;
ui_label = "Highlight Gain [MartinshDoF]";
> = 2.0;
uniform float bias <
ui_type = "drag";
ui_min = 0.0;
ui_max = 2.0;
ui_step = 0.1;
ui_label = "Bokeh Edge Bias [MartinshDoF]";
> = 0.5;
uniform float fringe <
ui_type = "drag";
ui_min = 0.0;
ui_max = 5.0;
ui_step = 0.01;
ui_label = "Bokeh Chromatic Aberration / Fringing [MartinshDoF]";
> = 0.7;
uniform bool NOISE <
ui_type = "boolean";
ui_label = "Enable Noise [MartinshDoF]";
> = 1;
uniform float namount <
ui_type = "drag";
ui_min = 0.0001;
ui_max = 0.001;
ui_step = 0.0001;
ui_label = "Dither Amount [MartinshDoF]";
> = 0.0001;
uniform bool depthblur <
ui_type = "boolean";
ui_label = "Blur the Depth Buffer";
> = false;
uniform float dbsize <
ui_type = "drag";
ui_min = 0.1;
ui_max = 3.0;
ui_step = 0.1;
ui_label = "Depth Blur Size [MartinshDoF]";
> = 1.25;
uniform bool DEBUG <
ui_type = "boolean";
ui_label = "Enable DoF Debug Output [MartinshDoF]";
> = false;
/*
next part is experimental
not looking good with small sample and ring count
looks okay starting from samples = 4, rings = 4
*/
uniform bool pentagon <
ui_type = "boolean";
ui_label = "Enable Pentagon Shape [MartinshDoF]";
> = false;
uniform float feather <
ui_type = "drag";
ui_min = 0.0;
ui_max = 2.0;
ui_step = 0.1;
ui_label = "Pentagon Shape Feather [MartinshDoF]";
> = 0.4;
//------------------------------------------
#define PI 3.14159265
#define width BUFFER_WIDTH //texture width - ScreenSize X
#define height BUFFER_HEIGHT //texture height - ScreenSize Y
#define texel float2(BUFFER_RCP_WIDTH,BUFFER_RCP_HEIGHT) //Pixel Size
float penta(float2 coords) //pentagonal shape
{
float scale = float(rings) - 1.3;
float4 HS0 = float4( 1.0, 0.0, 0.0, 1.0);
float4 HS1 = float4( 0.309016994, 0.951056516, 0.0, 1.0);
float4 HS2 = float4(-0.809016994, 0.587785252, 0.0, 1.0);
float4 HS3 = float4(-0.809016994,-0.587785252, 0.0, 1.0);
float4 HS4 = float4( 0.309016994,-0.951056516, 0.0, 1.0);
float4 HS5 = float4( 0.0 ,0.0 , 1.0, 1.0);
float4 one = float4( 1.0, 1.0, 1.0, 1.0 );
float4 P = float4((coords),float2(scale, scale));
float4 dist = float4(0.0, 0.0, 0.0, 0.0);
float inorout = -4.0;
dist.x = dot( P, HS0 );
dist.y = dot( P, HS1 );
dist.z = dot( P, HS2 );
dist.w = dot( P, HS3 );
dist = smoothstep( -feather, feather, dist );
inorout += dot( dist, one );
dist.x = dot( P, HS4 );
dist.y = HS5.w - abs( P.z );
dist = smoothstep( -feather, feather, dist );
inorout += dist.x;
return clamp( inorout, 0.0, 1.0 );
}
float bdepth(float2 coords) //blurring depth
{
float d = 0.0;
float kernel[9];
float2 offset[9];
float2 wh = float2(ReShade::PixelSize.x, ReShade::PixelSize.y) * dbsize;
offset[0] = float2(-wh.x,-wh.y);
offset[1] = float2( 0.0, -wh.y);
offset[2] = float2( wh.x, -wh.y);
offset[3] = float2(-wh.x, 0.0);
offset[4] = float2( 0.0, 0.0);
offset[5] = float2( wh.x, 0.0);
offset[6] = float2(-wh.x, wh.y);
offset[7] = float2( 0.0, wh.y);
offset[8] = float2( wh.x, wh.y);
kernel[0] = 1.0/16.0; kernel[1] = 2.0/16.0; kernel[2] = 1.0/16.0;
kernel[3] = 2.0/16.0; kernel[4] = 4.0/16.0; kernel[5] = 2.0/16.0;
kernel[6] = 1.0/16.0; kernel[7] = 2.0/16.0; kernel[8] = 1.0/16.0;
for( int i=0; i<9; i++ )
{
float tmp = tex2Dlod(ReShade::DepthBuffer, float4(coords + offset[i],coords + offset[i])).r;
d += tmp * kernel[i];
}
return d;
}
float3 color(float2 coords,float blur) //processing the sample
{
float3 col = float3(0.0, 0.0, 0.0);
col.r = tex2Dlod(ReShade::BackBuffer,float4(coords + float2(0.866,-0.5)*ReShade::PixelSize*fringe*blur,coords + float2(0.866,-0.5)*ReShade::PixelSize*fringe*blur)).r;
col.g = tex2Dlod(ReShade::BackBuffer,float4(coords + float2(0.866,-0.5)*ReShade::PixelSize*fringe*blur,coords + float2(0.866,-0.5)*ReShade::PixelSize*fringe*blur)).g;
col.b = tex2Dlod(ReShade::BackBuffer,float4(coords + float2(0.866,-0.5)*ReShade::PixelSize*fringe*blur,coords + float2(0.866,-0.5)*ReShade::PixelSize*fringe*blur)).b;
float3 lumcoeff = float3(0.299,0.587,0.114);
float lum = dot(col.rgb, lumcoeff);
float thresh = max((lum-threshold)*gain, 0.0);
return col+lerp(float3(0.0, 0.0, 0.0),col,thresh*blur);
}
float2 rand(float2 coord) //generating noise/pattern texture for dithering
{
float noiseX = ((frac(1.0-coord.s*(ReShade::ScreenSize.x/2.0))*0.25)+(frac(coord.t*(ReShade::ScreenSize.y/2.0))*0.75))*2.0-1.0;
float noiseY = ((frac(1.0-coord.s*(ReShade::ScreenSize.x/2.0))*0.75)+(frac(coord.t*(ReShade::ScreenSize.y/2.0))*0.25))*2.0-1.0;
if (NOISE){
noiseX = clamp(frac(sin(dot(coord ,float2(12.9898,78.233))) * 43758.5453),0.0,1.0)*2.0-1.0;
noiseY = clamp(frac(sin(dot(coord ,float2(12.9898,78.233)*2.0)) * 43758.5453),0.0,1.0)*2.0-1.0;
}
return float2(noiseX,noiseY);
}
float3 debugFocus(float3 col, float blur, float depth)
{
float edge = 0.002*depth; //distance based edge smoothing
float m = clamp(smoothstep(0.0,edge,blur),0.0,1.0);
float e = clamp(smoothstep(1.0-edge,1.0,blur),0.0,1.0);
col = lerp(col,float3(1.0,0.5,0.0),(1.0-m)*0.6);
col = lerp(col,float3(0.0,0.5,1.0),((1.0-e)-(1.0-m))*0.2);
return col;
}
float vignette(float coords)
{
float dist = distance(coords, float2(0.5,0.5));
dist = smoothstep(vignout+(fstop/vignfade), vignin+(fstop/vignfade), dist);
return clamp(dist,0.0,1.0);
}
float4 PS_MartinshDOF(in float4 pos : SV_Position, in float2 texcoord : TEXCOORD) : SV_Target
{
//scene depth calculation
float depth = ReShade::GetLinearizedDepth(texcoord.x);
if (depthblur)
{
depth = ReShade::GetLinearizedDepth(bdepth(texcoord));
}
float fDepth = focalDepth;
//focal plane calculation
if (AUTOFOCUS) {
fDepth = ReShade::GetLinearizedDepth(focus.x);
}
//dof blur factor calculation
float blur = 0.0;
float f = focalLength; //focal length in mm
float d = fDepth*1000.0; //focal plane in mm
float o = depth*1000.0; //depth in mm
float a = (o*f)/(o-f);
float b = (d*f)/(d-f);
float c = (d-f)/(d*fstop*CoC);
blur = abs(a-b)*c;
if (MANUALDOF) {
a = depth-fDepth; //focal plane
b = (a-fdofstart)/fdofdist; //far DoF
c = (-a-ndofstart)/ndofdist; //near Dof
blur = (a>0.0)?b:c;
}
blur = clamp(blur,0.0,1.0);
// calculation of pattern for ditering
float2 noise = rand(texcoord)*namount*blur;
// getting blur x and y step factor
float w = (1.0/ReShade::ScreenSize.x)*blur*maxblur+noise.x;
float h = (1.0/ReShade::ScreenSize.y)*blur*maxblur+noise.y;
// calculation of final color
float3 col = float3(0.0, 0.0, 0.0);
col = tex2D(ReShade::BackBuffer, texcoord).rgb;
float s = 1.0;
int ringsamples;
for (int i = 1; i <= rings; i += 1)
{
ringsamples = i * samples;
for (int j = 0 ; j < ringsamples ; j += 1)
{
float step = PI*2.0 / float(ringsamples);
float pw = (cos(float(j)*step)*float(i));
float ph = (sin(float(j)*step)*float(i));
float p = 1.0;
if (pentagon)
{
p = penta(float2(pw,ph));
}
col += color(texcoord + float2(pw*w,ph*h),blur)*lerp(1.0,(float(i))/(float(rings)),bias)*p;
s += 1.0*lerp(1.0,(float(i))/(float(rings)),bias)*p;
}
}
col /= s; //divide by sample count
if (DEBUG){
col = debugFocus(col, blur, depth);
}
if (VIGNETTING){
col *= vignette(texcoord);
}
return float4(col, 1.0);
}
technique MartinshDOF
{
pass
{
VertexShader = PostProcessVS;
PixelShader = PS_MartinshDOF;
}
}
I've done successful ports before aswell so, if you have a request, lemme know and i'll do my best to bring it with no bugs (unlike those 2, im just posting them here because they are probably easily fixable but i don't have much time to debug them)
Please Log in or Create an account to join the conversation.
- mbah.primbon
it was tested on Spintires MudRunner game, with DX9 API.
Please Log in or Create an account to join the conversation.
- crosire
Uhm ...:mbah.primbon wrote: I got error X3511 when using SSDO.
it was tested on Spintires MudRunner game, with DX9 API.
matsilagi wrote: First one is SSDO from Euda's PPFX, it doesn't compile on DX9 and crashes DX10, 11, untested in OpenGL
As for why:
It's illegal to unroll a loop with a non-constant condition/step expression. The DX9 compiler correctly errors, the DX11 compiler apparently crashes after too many iterations.
Remove the "[unroll]" specifiers and replace the "tex2D" calls in the loop body with "tex2Dlod" (can't use gradient expressions in a dynamic loop) and it works. Same is true for the second shader.
Please Log in or Create an account to join the conversation.
- kingeric1992
Please Log in or Create an account to join the conversation.
- crosire
Please Log in or Create an account to join the conversation.
The DoF from Martinsh is still broken, it is something on the depth buffer but i don't know what yet.
Please Log in or Create an account to join the conversation.
- kaicooper
is there anyway to port Motion Focus?
Please Log in or Create an account to join the conversation.
- Iddqd
/**
* Maded by Ganossa ([email protected]) ported by IDDQD
*/
uniform bool mfDebug <
ui_type = "combo";
ui_items = "Off\0On";
ui_tooltip = "Activates debug mode of MF";
> = false;
uniform float mfFocusStrength <
ui_type = "drag";
ui_min = 0.0; ui_max = 1.0;
ui_tooltip = "The intensity with which the camera will follow motion";
> = 1.0;
uniform float mfZoomStrength <
ui_type = "drag";
ui_min = 0.0; ui_max = 1.0;
ui_tooltip = "The intensity of camera zoom to objects in motion";
> = 0.60;
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#include "ReShade.fxh"
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#define Ganossa_MF_BUFFERX BUFFER_WIDTH/2
#define Ganossa_MF_BUFFERY BUFFER_HEIGHT/2
#define Ganossa_MF_BUFFERXHalf Ganossa_MF_BUFFERX/2
#define Ganossa_MF_BUFFERYHalf Ganossa_MF_BUFFERY/2
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
texture2D Ganossa_MF_NormTex { Width = Ganossa_MF_BUFFERX; Height = Ganossa_MF_BUFFERY; Format = RGBA8; };
texture2D Ganossa_MF_PrevTex { Width = Ganossa_MF_BUFFERX; Height = Ganossa_MF_BUFFERY; Format = RGBA8; };
texture2D Ganossa_MF_QuadFullTex { Width = Ganossa_MF_BUFFERX; Height = Ganossa_MF_BUFFERY; Format = RGBA8; };
texture2D Ganossa_MF_QuadFullPrevTex { Width = Ganossa_MF_BUFFERX; Height = Ganossa_MF_BUFFERY; Format = RGBA8; };
texture2D Ganossa_MF_QuadTex { Width = Ganossa_MF_BUFFERX; Height = Ganossa_MF_BUFFERY; Format = RGBA16F; };
sampler2D Ganossa_MF_NormColor { Texture = Ganossa_MF_NormTex; };
sampler2D Ganossa_MF_PrevColor { Texture = Ganossa_MF_PrevTex; };
sampler2D Ganossa_MF_QuadFullColor { Texture = Ganossa_MF_QuadFullTex; };
sampler2D Ganossa_MF_QuadFullPrevColor { Texture = Ganossa_MF_QuadFullPrevTex; };
sampler2D Ganossa_MF_QuadColor { Texture = Ganossa_MF_QuadTex; };
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#define xSprint BUFFER_WIDTH/192f
#define ySprint BUFFER_HEIGHT/108f
void PS_MotionFocusNorm(float4 vpos : SV_Position, float2 texcoord : TEXCOORD, out float4 normR : SV_Target0)
{
normR = tex2D(ReShade::BackBuffer, texcoord);
}
void PS_MotionFocusQuadFull(float4 vpos : SV_Position, float2 texcoord : TEXCOORD, out float4 quadFullR : SV_Target0)
{
float3 orig = tex2D(Ganossa_MF_NormColor, texcoord).rgb;
float3 prev = tex2D(Ganossa_MF_PrevColor, texcoord).rgb;
float diff = (abs(orig.r-prev.r)+abs(orig.g-prev.g)+abs(orig.b-prev.b))/3f;
float3 quadFullPrev = tex2D(Ganossa_MF_QuadFullPrevColor,texcoord).rgb;
float3 quadFull = 0.968*quadFullPrev + float3(diff,diff,diff);
float3 quadFulldiff = float3(abs(quadFull.r-quadFullPrev.r),abs(quadFull.g-quadFullPrev.g),abs(quadFull.b-quadFullPrev.b));
quadFullR = float4((0.978-0.2*max(1.0f-pow(1.0f-quadFulldiff,2)*100000f,0))*quadFullPrev + float3(diff,diff,diff),1);
}
void PS_MotionFocusStorage(float4 vpos : SV_Position, float2 texcoord : TEXCOORD, out float4 prevR : SV_Target0, out float4 prevQuadFullR : SV_Target1)
{
prevR = tex2D(Ganossa_MF_NormColor, texcoord);
prevQuadFullR = tex2D(Ganossa_MF_QuadFullColor, texcoord);
}
void PS_MotionFocus(float4 vpos : SV_Position, float2 texcoord : TEXCOORD, out float4 quadR : SV_Target0)
{
quadR = float4(0,0,0,0);
if (!(texcoord.x <= BUFFER_RCP_WIDTH*2 && texcoord.y <= BUFFER_RCP_HEIGHT*2))
discard;
float2 coord = float2(0.0,0.0);
for (float i = 2.0f; i < Ganossa_MF_BUFFERX; i=i+xSprint)
{
coord.x = BUFFER_RCP_WIDTH*i*2;
for (float j = 2.0f; j < Ganossa_MF_BUFFERY; j=j+ySprint )
{
coord.y = BUFFER_RCP_HEIGHT*j*2;
float3 quadFull = tex2D(Ganossa_MF_QuadFullColor, coord).xyz;
float quadFullPow = quadFull.x+quadFull.y+quadFull.z;
if(i < Ganossa_MF_BUFFERXHalf && j < Ganossa_MF_BUFFERYHalf)
quadR.x += quadFullPow;
else if(i > Ganossa_MF_BUFFERXHalf && j < Ganossa_MF_BUFFERYHalf)
quadR.y += quadFullPow;
else if(i < Ganossa_MF_BUFFERXHalf && j > Ganossa_MF_BUFFERYHalf)
quadR.z += quadFullPow;
else
quadR.w += quadFullPow;
}
}
quadR.xyzw /= 5184f;
}
float4 PS_MotionFocusDisplay(float4 vpos : SV_Position, float2 texcoord : TEXCOORD) : SV_Target
{
float4 Ganossa_MF_Quad = max(0,tex2D(Ganossa_MF_QuadColor, float2(BUFFER_RCP_WIDTH, BUFFER_RCP_HEIGHT))-0.1f);
if (mfDebug)
{
//debug
if(texcoord.y < 0.01f) if(texcoord.x > Ganossa_MF_Quad.x-0.01f && texcoord.x < Ganossa_MF_Quad.x+0.01f) return float4(1,0,0,0);
if(texcoord.y > 0.01f && texcoord.y < 0.02f) if(texcoord.x > Ganossa_MF_Quad.y-0.01f && texcoord.x < Ganossa_MF_Quad.y+0.01f) return float4(0,1,0,0);
if(texcoord.y > 0.02f && texcoord.y < 0.03f) if(texcoord.x > Ganossa_MF_Quad.z-0.01f && texcoord.x < Ganossa_MF_Quad.z+0.01f) return float4(0,0,1,0);
if(texcoord.y > 0.03f && texcoord.y < 0.04f) if(texcoord.x > Ganossa_MF_Quad.w-0.01f && texcoord.x < Ganossa_MF_Quad.w+0.01f) return float4(1,1,0,0);
//debug
}
float2 focus = 0.5f + float2(max(min(0.5,(Ganossa_MF_Quad.y + Ganossa_MF_Quad.w - Ganossa_MF_Quad.x - Ganossa_MF_Quad.z)/2f),-1.0),max(min(0.5,(Ganossa_MF_Quad.z + Ganossa_MF_Quad.w - Ganossa_MF_Quad.x - Ganossa_MF_Quad.y)/2f),-0.5));
float focusPow = max(Ganossa_MF_Quad.x,max(Ganossa_MF_Quad.y,max(Ganossa_MF_Quad.z,Ganossa_MF_Quad.w)));
float focusPowDiff = 1.0f;
if (focusPow == Ganossa_MF_Quad.x) focusPowDiff += Ganossa_MF_Quad.x-(Ganossa_MF_Quad.y + Ganossa_MF_Quad.z + Ganossa_MF_Quad.w)/3f;
else if(focusPow == Ganossa_MF_Quad.y) focusPowDiff += Ganossa_MF_Quad.y-(Ganossa_MF_Quad.x + Ganossa_MF_Quad.z + Ganossa_MF_Quad.w)/3f;
else if(focusPow == Ganossa_MF_Quad.z) focusPowDiff += Ganossa_MF_Quad.z-(Ganossa_MF_Quad.x + Ganossa_MF_Quad.y + Ganossa_MF_Quad.w)/3f;
else focusPowDiff += Ganossa_MF_Quad.w-(Ganossa_MF_Quad.y + Ganossa_MF_Quad.z + Ganossa_MF_Quad.x)/3f;
float focusPowFull = 0.5f*max(1.0f,min(2.0f - pow((Ganossa_MF_Quad.x + Ganossa_MF_Quad.y + Ganossa_MF_Quad.z + Ganossa_MF_Quad.w)/4f,3),1.0f));
if (mfDebug)
{
//debug
if(texcoord.x < 0.5025f && texcoord.x > 0.4975f && texcoord.y < 0.505f && texcoord.y > 0.495f) return float4(0,1,0,0);
if(texcoord.x > pow(focus.x,2)+0.25f-0.0025f && texcoord.x < pow(focus.x,2)+0.25f+0.0025f && texcoord.y > pow(focus.y,2)+0.25f-0.005f && texcoord.y < pow(focus.y,2)+0.25f+0.005f) return float4(1,0,0,0);
//debug
}
float2 finalZoom = focusPow*focusPowDiff*focusPowFull*mfZoomStrength;
float2 finalFocus = focus*focusPow*pow(focusPowDiff,3)*focusPowFull*mfFocusStrength;
float2 focusCorrection = min(0,float2(1,1)-(float2(1,1)*(1.0f-finalZoom)+finalFocus*min(0.55,0.6*mfZoomStrength)));
return tex2D(ReShade::BackBuffer, texcoord*(1.0f-finalZoom)+finalFocus*min(0.55,0.6*mfZoomStrength)+focusCorrection);
}
technique GanossaMotionFocus
{
pass MotionFocusNormPass
{
VertexShader = PostProcessVS;
PixelShader = PS_MotionFocusNorm;
RenderTarget0 = Ganossa_MF_NormTex;
}
pass MotionFocusQuadFullPass
{
VertexShader = PostProcessVS;
PixelShader = PS_MotionFocusQuadFull;
RenderTarget0 = Ganossa_MF_QuadFullTex;
}
pass MotionFocusPass
{
VertexShader = PostProcessVS;
PixelShader = PS_MotionFocus;
RenderTarget0 = Ganossa_MF_QuadTex;
}
pass MotionFocusDisplayPass
{
VertexShader = PostProcessVS;
PixelShader = PS_MotionFocusDisplay;
}
pass MotionFocusStoragePass
{
VertexShader = PostProcessVS;
PixelShader = PS_MotionFocusStorage;
RenderTarget0 = Ganossa_MF_PrevTex;
RenderTarget1 = Ganossa_MF_QuadFullPrevTex;
}
}
Please Log in or Create an account to join the conversation.
- Amarx
Please Log in or Create an account to join the conversation.
- mbah.primbon
Well, here you go. pain in the ass writing those UI params. thank you will be niceAmarx wrote: Can you port the HSV shader from CustomFX.cfg? It was my favorite.
Hue Saturation Value Adjustment
/**
* Hue Saturation Value Adjustment
* by Marty McFly
*
*
* Ported from ReShade Framework
* to ReShade 3.0+ by mbah.primbon
*
*/
//-------------------- GUI Settings ----------------------
//HSV Settings
uniform float fColorHueMod <
ui_type = "drag";
ui_min = -1.00; ui_max = 1.00; ui_step = 0.01;
ui_label = "Color Hue Strength";
ui_tooltip = "Adds to the overall color hue (color shifting).";
> = 0.0;
uniform float fColorHueMult <
ui_type = "drag";
ui_min = 0.00; ui_max = 5.00; ui_step = 0.01;
ui_label = "Color Hue Multipler";
ui_tooltip = "Multiplies the color hue (color shifting).";
> = 1.0;
uniform float fColorHuePow <
ui_type = "drag";
ui_min = 0.00; ui_max = 5.00; ui_step = 0.01;
ui_label = "Color Hue Curve";
ui_tooltip = "Curves the color hue.";
> = 1.0;
uniform float fColorSaturationMod <
ui_type = "drag";
ui_min = -1.00; ui_max = 1.00; ui_step = 0.01;
ui_label = "Color Saturation Strength";
ui_tooltip = "Adds to the overall color saturation.";
> = 0.0;
uniform float fColorSaturationMult <
ui_type = "drag";
ui_min = 0.00; ui_max = 5.00; ui_step = 0.01;
ui_label = "Color Saturation Multipler";
ui_tooltip = "Multiplies the color saturation.";
> = 1.0;
uniform float fColorSaturationPow <
ui_type = "drag";
ui_min = 0.00; ui_max = 5.00; ui_step = 0.01;
ui_label = "Color Saturation Curve";
ui_tooltip = "Curves the color saturation.";
> = 1.0;
uniform float fColorIntensityMod <
ui_type = "drag";
ui_min = -1.00; ui_max = 1.00; ui_step = 0.01;
ui_label = "Color Value Strength";
ui_tooltip = "Adds to the overall brightness.";
> = 0.0;
uniform float fColorIntensityMult <
ui_type = "drag";
ui_min = 0.00; ui_max = 5.00; ui_step = 0.01;
ui_label = "Color Value Multipler";
ui_tooltip = "Multiplies the overall brightness.";
> = 1.0;
uniform float fColorIntensityPow <
ui_type = "drag";
ui_min = 0.00; ui_max = 5.00; ui_step = 0.01;
ui_label = "Color Value Curve";
ui_tooltip = "Curves the overall brightness.";
> = 1.0;
//Addition/Strength Settings
uniform float fSaturationModRed <
ui_type = "drag";
ui_min = -1.00; ui_max = 1.00; ui_step = 0.01;
ui_label = "Red Saturation Strength";
ui_tooltip = "Adds to the color saturation of red hues only.";
> = 0.0;
uniform float fSaturationModOrange <
ui_type = "drag";
ui_min = -1.00; ui_max = 1.00; ui_step = 0.01;
ui_label = "Orange Saturation Strength";
ui_tooltip = "Adds to the color saturation of orange hues only.";
> = 0.0;
uniform float fSaturationModYellow <
ui_type = "drag";
ui_min = -1.00; ui_max = 1.00; ui_step = 0.01;
ui_label = "Yellow Saturation Strength";
ui_tooltip = "Adds to the color saturation of yellow hues only.";
> = 0.0;
uniform float fSaturationModGreen <
ui_type = "drag";
ui_min = -1.00; ui_max = 1.00; ui_step = 0.01;
ui_label = "Green Saturation Strength";
ui_tooltip = "Adds to the color saturation of green hues only.";
> = 0.0;
uniform float fSaturationModCyan <
ui_type = "drag";
ui_min = -1.00; ui_max = 1.00; ui_step = 0.01;
ui_label = "Cyan Saturation Strength";
ui_tooltip = "Adds to the color saturation of cyan hues only.";
> = 0.0;
uniform float fSaturationModBlue <
ui_type = "drag";
ui_min = -1.00; ui_max = 1.00; ui_step = 0.01;
ui_label = "Blue Saturation Strength";
ui_tooltip = "Adds to the color saturation of blue hues only.";
> = 0.0;
uniform float fSaturationModMagenta <
ui_type = "drag";
ui_min = -1.00; ui_max = 1.00; ui_step = 0.01;
ui_label = "Magenta Saturation Strength";
ui_tooltip = "Adds to the color saturation of magenta hues only.";
> = 0.0;
//Multipler Settings
uniform float fSaturationMultRed <
ui_type = "drag";
ui_min = 0.00; ui_max = 5.00; ui_step = 0.01;
ui_label = "Red Saturation Multipler";
ui_tooltip = "Multiplies the color saturation of red hues only.";
> = 0.0;
uniform float fSaturationMultOrange <
ui_type = "drag";
ui_min = 0.00; ui_max = 5.00; ui_step = 0.01;
ui_label = "Orange Saturation Multipler";
ui_tooltip = "Multiplies the color saturation of orange hues only.";
> = 0.0;
uniform float fSaturationMultYellow <
ui_type = "drag";
ui_min = 0.00; ui_max = 5.00; ui_step = 0.01;
ui_label = "Yellow Saturation Multipler";
ui_tooltip = "Multiplies the color saturation of yellow hues only.";
> = 0.0;
uniform float fSaturationMultGreen <
ui_type = "drag";
ui_min = 0.00; ui_max = 5.00; ui_step = 0.01;
ui_label = "Green Saturation Multipler";
ui_tooltip = "Multiplies the color saturation of green hues only.";
> = 0.0;
uniform float fSaturationMultCyan <
ui_type = "drag";
ui_min = 0.00; ui_max = 5.00; ui_step = 0.01;
ui_label = "Cyan Saturation Multipler";
ui_tooltip = "Multiplies the color saturation of cyan hues only.";
> = 0.0;
uniform float fSaturationMultBlue <
ui_type = "drag";
ui_min = 0.00; ui_max = 5.00; ui_step = 0.01;
ui_label = "Blue Saturation Multipler";
ui_tooltip = "Multiplies the color saturation of blue hues only.";
> = 0.0;
uniform float fSaturationMultMagenta <
ui_type = "drag";
ui_min = 0.00; ui_max = 5.00; ui_step = 0.01;
ui_label = "Magenta Saturation Multipler";
ui_tooltip = "Multiplies the color saturation of magenta hues only.";
> = 0.0;
//Curve Settings
uniform float fSaturationPowRed <
ui_type = "drag";
ui_min = -1.00; ui_max = 5.00; ui_step = 0.01;
ui_label = "Red Saturation Curve";
ui_tooltip = "Curves the color saturation of red hues only.";
> = 0.0;
uniform float fSaturationPowOrange <
ui_type = "drag";
ui_min = -1.00; ui_max = 5.00; ui_step = 0.01;
ui_label = "Orange Saturation Curve";
ui_tooltip = "Curves the color saturation of orange hues only.";
> = 0.0;
uniform float fSaturationPowYellow <
ui_type = "drag";
ui_min = -1.00; ui_max = 5.00; ui_step = 0.01;
ui_label = "Yellow Saturation Curve";
ui_tooltip = "Curves the color saturation of yellow hues only.";
> = 0.0;
uniform float fSaturationPowGreen <
ui_type = "drag";
ui_min = -1.00; ui_max = 5.00; ui_step = 0.01;
ui_label = "Green Saturation Curve";
ui_tooltip = "Curves the color saturation of green hues only.";
> = 0.0;
uniform float fSaturationPowCyan <
ui_type = "drag";
ui_min = -1.00; ui_max = 5.00; ui_step = 0.01;
ui_label = "Cyan Saturation Curve";
ui_tooltip = "Curves the color saturation of cyan hues only.";
> = 0.0;
uniform float fSaturationPowBlue <
ui_type = "drag";
ui_min = -1.00; ui_max = 5.00; ui_step = 0.01;
ui_label = "Blue Saturation Curve";
ui_tooltip = "Curves the color saturation of blue hues only.";
> = 0.0;
uniform float fSaturationPowMagenta <
ui_type = "drag";
ui_min = -1.00; ui_max = 5.00; ui_step = 0.01;
ui_label = "Magenta Saturation Curve";
ui_tooltip = "Curves the color saturation of magenta hues only.";
> = 0.0;
//------------------------------------------------------------------------
#include "ReShade.fxh"
// Functions
float ColorEqualizerMod(in float H)
{
float SMod = 0.0;
SMod += fSaturationModRed * ( 1.0 - min( 1.0, abs( H / 0.08333333 ) ) );
SMod += fSaturationModOrange * ( 1.0 - min( 1.0, abs( ( 0.08333333 - H ) / ( - 0.08333333 ) ) ) );
SMod += fSaturationModYellow * ( 1.0 - min( 1.0, abs( ( 0.16666667 - H ) / ( - 0.16666667 ) ) ) );
SMod += fSaturationModGreen * ( 1.0 - min( 1.0, abs( ( 0.33333333 - H ) / 0.16666667 ) ) );
SMod += fSaturationModCyan * ( 1.0 - min( 1.0, abs( ( 0.5 - H ) / 0.16666667 ) ) );
SMod += fSaturationModBlue * ( 1.0 - min( 1.0, abs( ( 0.66666667 - H ) / 0.16666667 ) ) );
SMod += fSaturationModMagenta * ( 1.0 - min( 1.0, abs( ( 0.83333333 - H ) / 0.16666667 ) ) );
SMod += fSaturationModRed * ( 1.0 - min( 1.0, abs( ( 1.0 - H ) / 0.16666667 ) ) );
return SMod;
}
float ColorEqualizerMult(in float H)
{
float SMult = 1.0;
SMult += fSaturationMultRed * ( 1.0 - min( 1.0, abs( H / 0.08333333 ) ) );
SMult += fSaturationMultOrange * ( 1.0 - min( 1.0, abs( ( 0.08333333 - H ) / ( - 0.08333333 ) ) ) );
SMult += fSaturationMultYellow * ( 1.0 - min( 1.0, abs( ( 0.16666667 - H ) / ( - 0.16666667 ) ) ) );
SMult += fSaturationMultGreen * ( 1.0 - min( 1.0, abs( ( 0.33333333 - H ) / 0.16666667 ) ) );
SMult += fSaturationMultCyan * ( 1.0 - min( 1.0, abs( ( 0.5 - H ) / 0.16666667 ) ) );
SMult += fSaturationMultBlue * ( 1.0 - min( 1.0, abs( ( 0.66666667 - H ) / 0.16666667 ) ) );
SMult += fSaturationMultMagenta * ( 1.0 - min( 1.0, abs( ( 0.83333333 - H ) / 0.16666667 ) ) );
SMult += fSaturationMultRed * ( 1.0 - min( 1.0, abs( ( 1.0 - H ) / 0.16666667 ) ) );
return SMult;
}
float ColorEqualizerPow(in float H)
{
float SPow = 1.0;
SPow += fSaturationPowRed * ( 1.0 - min( 1.0, abs( H / 0.08333333 ) ) );
SPow += fSaturationPowOrange * ( 1.0 - min( 1.0, abs( ( 0.08333333 - H ) / ( - 0.08333333 ) ) ) );
SPow += fSaturationPowYellow * ( 1.0 - min( 1.0, abs( ( 0.16666667 - H ) / ( - 0.16666667 ) ) ) );
SPow += fSaturationPowGreen * ( 1.0 - min( 1.0, abs( ( 0.33333333 - H ) / 0.16666667 ) ) );
SPow += fSaturationPowCyan * ( 1.0 - min( 1.0, abs( ( 0.5 - H ) / 0.16666667 ) ) );
SPow += fSaturationPowBlue * ( 1.0 - min( 1.0, abs( ( 0.66666667 - H ) / 0.16666667 ) ) );
SPow += fSaturationPowMagenta * ( 1.0 - min( 1.0, abs( ( 0.83333333 - H ) / 0.16666667 ) ) );
SPow += fSaturationPowRed * ( 1.0 - min( 1.0, abs( ( 1.0 - H ) / 0.16666667 ) ) );
return SPow;
}
float3 HUEtoRGB(in float H)
{
float R = abs(H * 6.0 - 3.0) - 1.0;
float G = 2.0 - abs(H * 6.0 - 2.0);
float B = 2.0 - abs(H * 6.0 - 4.0);
return saturate(float3(R,G,B));
}
float RGBCVtoHUE(in float3 RGB, in float C, in float V)
{
float3 Delta = (V - RGB) / C;
Delta.rgb -= Delta.brg;
Delta.rgb += float3(2.0,4.0,6.0);
Delta.brg = step(V, RGB) * Delta.brg;
float H;
H = max(Delta.r, max(Delta.g, Delta.b));
return frac(H / 6.0);
}
float3 HSVtoRGB(in float3 HSV)
{
float3 RGB = HUEtoRGB(HSV.x);
return ((RGB - 1) * HSV.y + 1) * HSV.z;
}
float3 RGBtoHSV(in float3 RGB)
{
float3 HSV = 0.0;
HSV.z = max(RGB.r, max(RGB.g, RGB.b));
float M = min(RGB.r, min(RGB.g, RGB.b));
float C = HSV.z - M;
if (C != 0.0)
{
HSV.x = RGBCVtoHUE(RGB, C, HSV.z);
HSV.y = C / HSV.z;
}
return HSV;
}
// Pixel shaders
void HueSaturationValue(float4 vpos : SV_Position, float2 texcoord : TEXCOORD, out float4 color : SV_Target)
{
color = tex2D(ReShade::BackBuffer, texcoord.xy);
float3 hsvcolor = RGBtoHSV(color.rgb);
//global adjustments
hsvcolor.x = fColorHueMod + (fColorHueMult * pow(hsvcolor.x, fColorHuePow));
hsvcolor.y = fColorSaturationMod + (fColorSaturationMult * pow(hsvcolor.y, fColorSaturationPow));
hsvcolor.z = fColorIntensityMod + (fColorIntensityMult * pow(hsvcolor.z, fColorIntensityPow));
//hue specific adjustments. Yes, hue. huehuehuehuehue.
hsvcolor.y = ColorEqualizerMod(hsvcolor.x) + (ColorEqualizerMult(hsvcolor.x) * pow(hsvcolor.y, ColorEqualizerPow(hsvcolor.x)));
hsvcolor.yz = max(hsvcolor.yz, 0.0);
color.rgb = HSVtoRGB(hsvcolor);
}
// Rendering passes
technique HSV
{
pass
{
VertexShader = PostProcessVS;
PixelShader = HueSaturationValue;
}
}
Please Log in or Create an account to join the conversation.
- USteppin
Iddqd wrote: Not shure if it works correctly but
Awesome! Thanks for the Motion Focus plugin, it works but unfortunately it breaks the Reshade overlay from functioning, any ideas on how to solve that? Testing in RaceRoom DX9.
Please Log in or Create an account to join the conversation.
- Tojkar
Please Log in or Create an account to join the conversation.
- kaicooper
- mbah.primbon
Please Log in or Create an account to join the conversation.
- StyleMaster
i tried some of the gauss.fx files here & there but it is hard
any help appriciated
Please Log in or Create an account to join the conversation.
- AssassinsDecree
Just wanted to thank you so much for porting these over. FisheyeHorizontal is my everything now. I put it in every new preset I release just about.
Please Log in or Create an account to join the conversation.
- WangWei
Please Log in or Create an account to join the conversation.
- Insomnia
- Topic Author
WangWei wrote: Hey there's an issue with HPD I the editor seems to not be able to find HPD, I cannot edit its values how do I lower its strength?
A few of the older shaders didn't come with any tweakable settings.
Please Log in or Create an account to join the conversation.