Page 1 of 1

How can i implement the Range Function from the Blur and Sharp effect?

Posted: 19 Mar 2024, 22:05
by Labont
I want to implement the range function from the Blur and Sharp effects that are in enbpostpass to a Chromatic Abberation shader. I have made multiple tries but couldn't get it to work.

Chromatic Abberation Effect :

float3 PS_ChromaticAberration(VS_OUTPUT_POST IN, float4 vPos : SV_Position0) : SV_Target
{
float3 color, colorInput = TextureColor.Sample(Sampler0, IN.txcoord0.xy).rgb;
float2 pixeloffset = ScreenSize.y;
pixeloffset.y *= ScreenSize.z;

color.r = TextureColor.Sample(Sampler0, IN.txcoord0.xy + (pixeloffset * float2(ChromaticAberrationPositionX1, ChromaticAberrationPositionY1))).r;
color.g = colorInput.g;
color.b = TextureColor.Sample(Sampler0, IN.txcoord0.xy - (pixeloffset * float2(ChromaticAberrationPositionX1, ChromaticAberrationPositionY1))).b;

return lerp(colorInput, color, ChromaticAberrationIntensity1);
}

Blur Effect :

float4 PS_Blur(VS_OUTPUT_POST IN, float4 vPos : SV_Position0) : SV_Target
{
float4 res;
float4 color;
float4 centercolor;
float2 pixeloffset = ScreenSize.y;
pixeloffset.y *= ScreenSize.z;

centercolor = TextureColor.Sample(Sampler0, IN.txcoord0.xy);
color = 0.0;

float2 offsets[4]=
{
float2(-1.0,-1.0),
float2(-1.0, 1.0),
float2( 1.0,-1.0),
float2( 1.0, 1.0),
};
for (int i = 0; i < 4; i++)
{
float2 coord = offsets.xy * pixeloffset.xy * BlurRange1 + IN.txcoord0.xy;
color += TextureColor.Sample(Sampler1, coord.xy);
}

color.xyz += centercolor.xyz;
color *= 0.2;

res.xyz = lerp(centercolor.xyz, color, BlurIntensity1);

res.w = 1.0;
return res;
}

Re: How can i implement the Range Function from the Blur and Sharp effect?

Posted: 20 Mar 2024, 09:26
by ENBSeries
If i get it right what you want, need to multiply pixeloffset by range, that's enough. Add next line after pixeloffset.y *= ScreenSize.z; for this, like pixeloffset *= BlurRange1;

Re: How can i implement the Range Function from the Blur and Sharp effect?

Posted: 21 Mar 2024, 00:23
by Labont
ENBSeries wrote: 20 Mar 2024, 09:26 If i get it right what you want, need to multiply pixeloffset by range, that's enough. Add next line after pixeloffset.y *= ScreenSize.z; for this, like pixeloffset *= BlurRange1;
Sorry i didn't write properly, this is the actual CA code.

float3 PS_ChromaticAberration(VS_OUTPUT_POST IN, float4 vPos : SV_Position0) : SV_Target
{
float3 color, colorInput = TextureColor.Sample(Sampler0, IN.txcoord0.xy).rgb;

color.r = TextureColor.Sample(Sampler0, IN.txcoord0.xy + (pixeloffset * float2(ChromaticAberrationPositionX1, ChromaticAberrationPositionY1))).r;
color.g = colorInput.g;
color.b = TextureColor.Sample(Sampler0, IN.txcoord0.xy - (pixeloffset * float2(ChromaticAberrationPositionX1, ChromaticAberrationPositionY1))).b;

return lerp(colorInput, color, ChromaticAberrationIntensity1);
}

And i want to implement the range function from this one

float4 PS_Blur(VS_OUTPUT_POST IN, float4 vPos : SV_Position0) : SV_Target
{
float4 res;
float4 color;
float4 centercolor;
float2 pixeloffset = ScreenSize.y;
pixeloffset.y *= ScreenSize.z;

centercolor = TextureColor.Sample(Sampler0, IN.txcoord0.xy);
color = 0.0;

float2 offsets[4]=
{
float2(-1.0,-1.0),
float2(-1.0, 1.0),
float2( 1.0,-1.0),
float2( 1.0, 1.0),
};
for (int i = 0; i < 4; i++)
{
float2 coord = offsets.xy * pixeloffset.xy * BlurRange1 + IN.txcoord0.xy;
color += TextureColor.Sample(Sampler1, coord.xy);
}

color.xyz += centercolor.xyz;
color *= 0.2;

res.xyz = lerp(centercolor.xyz, color, BlurIntensity1);

res.w = 1.0;
return res;
}

Re: How can i implement the Range Function from the Blur and Sharp effect?

Posted: 21 Mar 2024, 07:51
by ENBSeries
Already wrote how to do that.