Can someone port details.yfx from freestyle to reshade
- odikzz2
-
Topic Author
Please Log in or Create an account to join the conversation.
- YF
-
Please Log in or Create an account to join the conversation.
- odikzz2
-
Topic Author
Code for Details.fx
Details.yaml
samplerstates:
SamplerLinear:
filter: MIN_MAG_MIP_LINEAR
addressU: CLAMP
addressV: CLAMP
type: RGBA8_uint
constant-buffers:
globalParams: {screenSize: SCREEN_SIZE, captureState: CAPTURE_STATE, tileUV: TILE_UV_RANGE}
controlBuf: {g_sldSharpen: sharpenSlider, g_sldClarity : claritySlider, g_sldHDR : hdrSlider, g_sldBloom : bloomSlider}
typical_slider1:
type: float
minimum-value: -1.0
maximum-value: 1.0
default-value: 0.0
ui-sticky-region: 0.01
ui-value-unit: "%"
ui-value-min: -100
ui-value-max: 100
ui-value-step: 5
typical_slider2:
type: float
minimum-value: 0.0
maximum-value: 1.0
default-value: 0.0
ui-sticky-region: 0.01
ui-value-unit: "%"
ui-value-min: 0
ui-value-max: 100
ui-value-step: 5
user-constants:
- name: sharpenSlider
ui-label: "Sharpen"
ui-label-localized:
ru-RU: "Резкость"
fr-FR: "Accentuation"
it-IT: "Messa a fuoco"
de-DE: "Schärfen"
es-ES: "Nitidez"
es-MX: "Enfoque"
zh-CHS: "锐化"
zh-CHT: "銳化"
ja-JP: "シャープにする"
cs-CZ: "Zaostřit"
da-DK: "Gør skarpere"
el-GR: "Αύξηση ευκρίνειας"
en-UK: "Sharpen"
fi-FI: "Terävöitä"
hu: "Élesítés"
ko-KR: "선명도"
nl-NL: "Scherper maken"
nb-NO: "Gjør skarpere"
pl: "Wyostrzanie"
pt-PT: "Nitidez"
pt-BR: "Nitidez"
sl-SI: "Ostrenje"
sk-SK: "Zostriť"
sv-SE: "Skärpa"
th-TH: "ทำให้คมชัดขึ้น"
tr-TR: "Keskinleştirme"
default-value: 0.0
ui-sticky-value: 0.0
import: [typical_slider2]
- name: claritySlider
ui-label: "Clarity"
ui-label-localized:
ru-RU: "Четкость"
fr-FR: "Clarté"
it-IT: "Nitidezza"
de-DE: "Klarheit"
es-ES: "Claridad"
es-MX: "Claridad"
zh-CHS: "清晰度"
zh-CHT: "清晰度"
ja-JP: "鮮明さ"
cs-CZ: "Čirost"
da-DK: "Klarhed"
el-GR: "Καθαρότητα"
en-UK: "Clarity"
fi-FI: "Selkeys"
hu: "Tisztaság"
ko-KR: "투명도"
nl-NL: "Helderheid"
nb-NO: "Klarhet"
pl: "Przejrzystość"
pt-PT: "Claridade"
pt-BR: "Claridade"
sl-SI: "Jasnost"
sk-SK: "Jasnosť"
sv-SE: "Klarhet"
th-TH: "ความชัดเจน"
tr-TR: "Netlik"
default-value: 0.0
ui-sticky-value: 0.0
import: [typical_slider1]
- name: hdrSlider
ui-label: "HDR Toning"
ui-label-localized:
ru-RU: "Тонирование HDR"
fr-FR: "Tonalité HDR"
it-IT: "HDR"
de-DE: "HDR-Toning"
es-ES: "Tono HDR"
es-MX: "Tono de HDR"
zh-CHS: "高动态范围 (HDR) 调色"
zh-CHT: "HDR 色調"
ja-JP: "HDRトーニング"
cs-CZ: "Tónování HDR"
da-DK: "HDR-toning"
el-GR: "Τόνος HDR"
en-UK: "HDR toning"
fi-FI: "HDR-sävytys"
hu: "HDR árnyalatok"
ko-KR: "HDR 조색"
nl-NL: "HDR-toning"
nb-NO: "HDR-toning"
pl: "Tonowanie HDR"
pt-PT: "Tonalidade HDR"
pt-BR: "Tonalização do HDR"
sl-SI: "Toniranje HDR"
sk-SK: "Tónovanie HDR"
sv-SE: "HDR-toning"
th-TH: "HDR โทนนิ่ง"
tr-TR: "HDR tonlama"
default-value: 0.0
ui-sticky-value: 0.0
import: [typical_slider1]
- name: bloomSlider
ui-label: "Bloom"
ui-label-localized:
ru-RU: "Размытие"
fr-FR: "Flou"
it-IT: "Patinatura"
de-DE: "Überstrahleffekte"
es-ES: "Bloom (resplandor)"
es-MX: "Brillo de iluminación"
zh-CHS: "全屏泛光"
zh-CHT: "光暈"
ja-JP: "ブルーム"
cs-CZ: "Záře"
da-DK: "Bloom"
el-GR: "Bloom"
en-UK: "Bloom"
fi-FI: "Bloom-tehoste"
hu: "Virág"
ko-KR: "블룸"
nl-NL: "Bloom-effect"
nb-NO: "Bloom"
pl: "Rozświetlenie"
pt-PT: "Brilho"
pt-BR: "Bloom"
sl-SI: "Žarenje"
sk-SK: "Žiara"
sv-SE: "Bloom"
th-TH: "บลูม"
tr-TR: "Bloom"
default-value: 0.0
ui-sticky-value: 0.0
import: [typical_slider2]
blur1:
import: [pass_template]
shader: PS_LargeBlur1@Details.yfx
textures:
texOriginalColor:
channel: PIPE_INPUTS_COLOR
main:
import: [pass_template]
shader: PS_SharpenClarity@Details.yfx
textures:
texBlurred:
import: [blur1]
texOriginalColor:
channel: PIPE_INPUTS_COLOR
Details.yfx
// Shader file for NVIDIA Ansel
//
//
// Constants
//
#define PixelSize float2(1.0 / screenSize.x, 1.0 / screenSize.y) //x = Pixel width, y = Pixel height
cbuffer globalParams
{
float2 screenSize; //x = screen width, y = screen height
int captureState; //unused, my math works without using specific cases
float4 tileUV; //xy - top left tile coordinate, zw - bottom right tile coordinate
}
cbuffer controlBuf
{
float g_sldSharpen;
float g_sldClarity;
float g_sldHDR;
float g_sldBloom;
}
struct VSOut
{
float4 position : SV_POSITION;
float2 txcoord : TEXCOORD;
};
//
// Textures, Samplers
//
Texture2D texOriginalColor;
Texture2D texBlurred;
//
SamplerState SamplerLinear;
//
// Functions
//
float4 ScaleableGaussianBlurLinear(Texture2D tex,
float2 texcoord,
int nSteps,
float2 axis,
float2 texelsize)
{
float norm = -1.35914091423/(nSteps*nSteps);
float4 accum = tex.Sample(SamplerLinear,texcoord.xy);
float2 offsetinc = axis * texelsize;
float divisor = 0.5; //exp(0) * 0.5
[loop]
for(float iStep = 1; iStep <= nSteps; iStep++)
{
float2 tapOffsetD = iStep * 2.0 + float2(-1.0,0.0);
float2 tapWeightD = exp(tapOffsetD*tapOffsetD*norm);
float tapWeightL = dot(tapWeightD,1.0);
float tapOffsetL = dot(tapOffsetD,tapWeightD)/tapWeightL;
accum += tex.SampleLevel(SamplerLinear,texcoord.xy + offsetinc * tapOffsetL,0) * tapWeightL;
accum += tex.SampleLevel(SamplerLinear,texcoord.xy - offsetinc * tapOffsetL,0) * tapWeightL;
divisor += tapWeightL;
}
accum /= 2.0 * divisor;
return accum;
}
float4 BoxBlur(Texture2D tex, float2 texcoord, float2 texelsize)
{
float3 blurData[8] =
{
float3( 0.5, 1.5,1.50),
float3( 1.5,-0.5,1.50),
float3(-0.5,-1.5,1.50),
float3(-1.5, 0.5,1.50),
float3( 2.5, 1.5,1.00),
float3( 1.5,-2.5,1.00),
float3(-2.5,-1.5,1.00),
float3(-1.5, 2.5,1.00),
};
float4 blur = 0.0;
for(int i=0; i<8; i++) { blur += tex.SampleLevel(SamplerLinear,texcoord.xy + blurData.xy * texelsize.xy,0) * blurData.z; }
blur /= (4 * 1.5) + (4 * 1.0);
return blur;
}
//
// Pixel Shaders
//
float4 PS_LargeBlur1( VSOut IN ): SV_Target
{
return ScaleableGaussianBlurLinear(texOriginalColor,IN.txcoord.xy,15,float2(1,0),PixelSize.xy);
}
//
float4 PS_SharpenClarity( VSOut IN ): SV_Target
{
float4 color = texOriginalColor.Sample(SamplerLinear,IN.txcoord.xy);
float4 largeblur = ScaleableGaussianBlurLinear(texBlurred,IN.txcoord.xy,15,float2(0,1),PixelSize.xy);
float4 smallblur = BoxBlur(texOriginalColor,IN.txcoord.xy,PixelSize);
float a = dot(color.rgb,float3(0.299,0.587,0.114));
float sqrta = sqrt(a);
float b = dot(largeblur.rgb,float3(0.299,0.587,0.114));
float c = dot(smallblur.rgb,float3(0.299,0.587,0.114));
//HDR Toning
float HDRToning = sqrta * lerp(sqrta*(2*a*b-a-2*b+2.0), (2*sqrta*b-2*b+1), b > 0.5); //modified soft light v1
color = color / (a+1e-6) * lerp(a,HDRToning,g_sldHDR);
//sharpen
//float Sharpen = (a-c)/(g_sldSharpen*2.0+1e-6); //clamp to +- 1.0 / SHARPEN_AMOUNT with smooth falloff
//Sharpen = sign(Sharpen)*(pow(Sharpen,6)-abs(Sharpen))/(pow(Sharpen,6)-1);
//color += Sharpen*color*g_sldSharpen*2.0;
float Sharpen = dot(color.rgb - smallblur.rgb,float3(0.299,0.587,0.114));
float sharplimit = lerp(0.25,0.6,g_sldSharpen);
Sharpen = clamp(Sharpen,-sharplimit,sharplimit);
color.rgb = color.rgb / a * lerp(a,a+Sharpen,g_sldSharpen);
//clarity
float Clarity = (0.5 + a - b);
Clarity = lerp(2*Clarity + a*(1-2*Clarity), 2*(1-Clarity)+(2*Clarity-1)*rsqrt(a), a > b); //modified soft light v2
color.rgb *= lerp(1.0,Clarity,g_sldClarity);
//bloom
color.rgb = 1-(1-color.rgb)*(1-largeblur.rgb * g_sldBloom);
return color;
}
Please Log in or Create an account to join the conversation.
- YF
-
Please Log in or Create an account to join the conversation.
- YF
-
uniform float g_sldSharpen <
ui_label = "g_sldSharpen";
ui_type = "slider";
ui_min = 0.0; ui_max = 1.0;
ui_step = 0.01;
> = 0.0;
uniform float g_sldClarity <
ui_label = "g_sldClarity";
ui_type = "slider";
ui_min = 0.0; ui_max = 1.0;
ui_step = 0.01;
> = 0.0;
uniform float g_sldHDR <
ui_label = "g_sldHDR";
ui_type = "slider";
ui_min = 0.0; ui_max = 1.0;
ui_step = 0.01;
> = 0.0;
uniform float g_sldBloom <
ui_label = "g_sldBloom";
ui_type = "slider";
ui_min = 0.0; ui_max = 1.0;
ui_step = 0.01;
> = 0.0;
texture texOri
{
Width = BUFFER_WIDTH;
Height = BUFFER_HEIGHT;
Format = RGBA16F;
};
sampler samplerOri { Texture = texOri; };
static const float2 PixelSize = float2(BUFFER_RCP_WIDTH, BUFFER_RCP_HEIGHT);
//#define vec2 float2
//#define vec3 float3
//#define vec4 float4
//#define mix lerp
float4 ScaleableGaussianBlurLinear(sampler SamplerLinear,
float2 texcoord,
int nSteps,
float2 axis,
float2 texelsize)
{
float norm = -1.35914091423/(nSteps*nSteps);
float4 accum = tex2D(SamplerLinear,texcoord.xy);
float2 offsetinc = axis * texelsize;
float divisor = 0.5; //exp(0) * 0.5
[loop]
for(float iStep = 1; iStep <= nSteps; iStep++)
{
float2 tapOffsetD = iStep * 2.0 + float2(-1.0,0.0);
float2 tapWeightD = exp(tapOffsetD*tapOffsetD*norm);
float tapWeightL = dot(tapWeightD,1.0);
float tapOffsetL = dot(tapOffsetD,tapWeightD)/tapWeightL;
accum += tex2D(SamplerLinear,texcoord.xy + offsetinc * tapOffsetL) * tapWeightL;
accum += tex2D(SamplerLinear,texcoord.xy - offsetinc * tapOffsetL) * tapWeightL;
divisor += tapWeightL;
}
accum /= 2.0 * divisor;
return accum;
}
float4 BoxBlur(sampler SamplerLinear, float2 texcoord, float2 texelsize)
{
float3 blurData[8] =
{
float3( 0.5, 1.5,1.50),
float3( 1.5,-0.5,1.50),
float3(-0.5,-1.5,1.50),
float3(-1.5, 0.5,1.50),
float3( 2.5, 1.5,1.00),
float3( 1.5,-2.5,1.00),
float3(-2.5,-1.5,1.00),
float3(-1.5, 2.5,1.00),
};
float4 blur = 0.0;
for(int i=0; i<8; i++)
{
blur += tex2D(SamplerLinear,texcoord.xy + blurData.xy * texelsize.xy) * blurData.z;
}
blur /= (4 * 1.5) + (4 * 1.0);
return blur;
}
float4 PS_LargeBlur1(float4 position : SV_Position, float2 texcoord : TexCoord) : SV_Target
{
return ScaleableGaussianBlurLinear(ReShade::BackBuffer,texcoord.xy,15,float2(1,0),PixelSize.xy);
}
//
float4 PS_SharpenClarity(float4 position : SV_Position, float2 texcoord : TexCoord) : SV_Target
{
float4 color = tex2D(ReShade::BackBuffer,texcoord.xy);
float4 largeblur = ScaleableGaussianBlurLinear(samplerOri,texcoord.xy,15,float2(0,1),PixelSize.xy);
float4 smallblur = BoxBlur(ReShade::BackBuffer,texcoord.xy,PixelSize);
float a = dot(color.rgb,float3(0.299,0.587,0.114));
float sqrta = sqrt(a);
float b = dot(largeblur.rgb,float3(0.299,0.587,0.114));
float c = dot(smallblur.rgb,float3(0.299,0.587,0.114));
//HDR Toning
float HDRToning = sqrta * lerp(sqrta*(2*a*b-a-2*b+2.0), (2*sqrta*b-2*b+1), b > 0.5); //modified soft light v1
color = color / (a+1e-6) * lerp(a,HDRToning,g_sldHDR);
//sharpen
//float Sharpen = (a-c)/(g_sldSharpen*2.0+1e-6); //clamp to +- 1.0 / SHARPEN_AMOUNT with smooth falloff
//Sharpen = sign(Sharpen)*(pow(Sharpen,6)-abs(Sharpen))/(pow(Sharpen,6)-1);
//color += Sharpen*color*g_sldSharpen*2.0;
float Sharpen = dot(color.rgb - smallblur.rgb,float3(0.299,0.587,0.114));
float sharplimit = lerp(0.25,0.6,g_sldSharpen);
Sharpen = clamp(Sharpen,-sharplimit,sharplimit);
color.rgb = color.rgb / a * lerp(a,a+Sharpen,g_sldSharpen);
//clarity
float Clarity = (0.5 + a - b);
Clarity = lerp(2*Clarity + a*(1-2*Clarity), 2*(1-Clarity)+(2*Clarity-1)*rsqrt(a), a > b); //modified soft light v2
color.rgb *= lerp(1.0,Clarity,g_sldClarity);
//bloom
color.rgb = 1-(1-color.rgb)*(1-largeblur.rgb * g_sldBloom);
return color;
}
technique Nvida_HDRToning
{
pass
{
VertexShader = PostProcessVS;
PixelShader = PS_LargeBlur1;
RenderTarget = texOri;
}
pass
{
VertexShader = PostProcessVS;
PixelShader = PS_SharpenClarity;
}
}
Please Log in or Create an account to join the conversation.
- YF
-
Please Log in or Create an account to join the conversation.
- sanek7814
-
Please Log in or Create an account to join the conversation.
- sanek7814
-
Please Log in or Create an account to join the conversation.
- YF
-
#include "ReShade.fxh"
uniform float g_sldSharpen <
ui_label = "g_sldSharpen";
ui_type = "slider";
ui_min = 0.0; ui_max = 1.0;
ui_step = 0.01;
> = 0.0;
uniform float g_sldClarity <
ui_label = "g_sldClarity";
ui_type = "slider";
ui_min = 0.0; ui_max = 1.0;
ui_step = 0.01;
> = 0.0;
uniform float g_sldHDR <
ui_label = "g_sldHDR";
ui_type = "slider";
ui_min = 0.0; ui_max = 1.0;
ui_step = 0.01;
> = 0.0;
uniform float g_sldBloom <
ui_label = "g_sldBloom";
ui_type = "slider";
ui_min = 0.0; ui_max = 1.0;
ui_step = 0.01;
> = 0.0;
texture texOri
{
Width = BUFFER_WIDTH;
Height = BUFFER_HEIGHT;
Format = RGBA16F;
};
sampler samplerOri { Texture = texOri; };
static const float2 PixelSize = float2(BUFFER_RCP_WIDTH, BUFFER_RCP_HEIGHT);
//#define vec2 float2
//#define vec3 float3
//#define vec4 float4
//#define mix lerp
float4 ScaleableGaussianBlurLinear(sampler SamplerLinear,
float2 texcoord,
int nSteps,
float2 axis,
float2 texelsize)
{
float norm = -1.35914091423/(nSteps*nSteps);
float4 accum = tex2D(SamplerLinear,texcoord.xy);
float2 offsetinc = axis * texelsize;
float divisor = 0.5; //exp(0) * 0.5
[loop]
for(float iStep = 1; iStep <= nSteps; iStep++)
{
float2 tapOffsetD = iStep * 2.0 + float2(-1.0,0.0);
float2 tapWeightD = exp(tapOffsetD*tapOffsetD*norm);
float tapWeightL = dot(tapWeightD,1.0);
float tapOffsetL = dot(tapOffsetD,tapWeightD)/tapWeightL;
accum += tex2D(SamplerLinear,texcoord.xy + offsetinc * tapOffsetL) * tapWeightL;
accum += tex2D(SamplerLinear,texcoord.xy - offsetinc * tapOffsetL) * tapWeightL;
divisor += tapWeightL;
}
accum /= 2.0 * divisor;
return accum;
}
float4 BoxBlur(sampler SamplerLinear, float2 texcoord, float2 texelsize)
{
float3 blurData[8] =
{
float3( 0.5, 1.5,1.50),
float3( 1.5,-0.5,1.50),
float3(-0.5,-1.5,1.50),
float3(-1.5, 0.5,1.50),
float3( 2.5, 1.5,1.00),
float3( 1.5,-2.5,1.00),
float3(-2.5,-1.5,1.00),
float3(-1.5, 2.5,1.00),
};
float4 blur = 0.0;
for(int j=0; j<8; j++)
{
blur += tex2D(SamplerLinear,texcoord.xy + blurData[j].xy * texelsize.xy) * blurData[j].z;
}
blur /= (4 * 1.5) + (4 * 1.0);
return blur;
}
float4 PS_LargeBlur1(float4 position : SV_Position, float2 texcoord : TexCoord) : SV_Target
{
return ScaleableGaussianBlurLinear(ReShade::BackBuffer,texcoord.xy,15,float2(1,0),PixelSize.xy);
}
//
float4 PS_SharpenClarity(float4 position : SV_Position, float2 texcoord : TexCoord) : SV_Target
{
float4 color = tex2D(ReShade::BackBuffer,texcoord.xy);
float4 largeblur = ScaleableGaussianBlurLinear(samplerOri,texcoord.xy,15,float2(0,1),PixelSize.xy);
float4 smallblur = BoxBlur(ReShade::BackBuffer,texcoord.xy,PixelSize);
float a = dot(color.rgb,float3(0.299,0.587,0.114));
float sqrta = sqrt(a);
float b = dot(largeblur.rgb,float3(0.299,0.587,0.114));
float c = dot(smallblur.rgb,float3(0.299,0.587,0.114));
//HDR Toning
float HDRToning = sqrta * lerp(sqrta*(2*a*b-a-2*b+2.0), (2*sqrta*b-2*b+1), b > 0.5); //modified soft light v1
color = color / (a+1e-6) * lerp(a,HDRToning,g_sldHDR);
//sharpen
//float Sharpen = (a-c)/(g_sldSharpen*2.0+1e-6); //clamp to +- 1.0 / SHARPEN_AMOUNT with smooth falloff
//Sharpen = sign(Sharpen)*(pow(Sharpen,6)-abs(Sharpen))/(pow(Sharpen,6)-1);
//color += Sharpen*color*g_sldSharpen*2.0;
float Sharpen = dot(color.rgb - smallblur.rgb,float3(0.299,0.587,0.114));
float sharplimit = lerp(0.25,0.6,g_sldSharpen);
Sharpen = clamp(Sharpen,-sharplimit,sharplimit);
color.rgb = color.rgb / a * lerp(a,a+Sharpen,g_sldSharpen);
//clarity
float Clarity = (0.5 + a - b);
Clarity = lerp(2*Clarity + a*(1-2*Clarity), 2*(1-Clarity)+(2*Clarity-1)*rsqrt(a), a > b); //modified soft light v2
color.rgb *= lerp(1.0,Clarity,g_sldClarity);
//bloom
color.rgb = 1-(1-color.rgb)*(1-largeblur.rgb * g_sldBloom);
return color;
}
technique Nvida_HDRToning
{
pass
{
VertexShader = PostProcessVS;
PixelShader = PS_LargeBlur1;
RenderTarget = texOri;
}
pass
{
VertexShader = PostProcessVS;
PixelShader = PS_SharpenClarity;
}
}
Please Log in or Create an account to join the conversation.
- YF
-
Please Log in or Create an account to join the conversation.
- sanek7814
-
Please Log in or Create an account to join the conversation.
- sanek7814
-
Please Log in or Create an account to join the conversation.
- YF
-
Please Log in or Create an account to join the conversation.
- b1es
-
Please Log in or Create an account to join the conversation.
- odikzz2
-
Topic Author
Please Log in or Create an account to join the conversation.