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

Post Reply
  • Author
  • Message
Offline
Posts: 9
Joined: 27 Sep 2023, 23:45

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

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;
}

Offline
User avatar
*blah-blah-blah maniac*
Posts: 17444
Joined: 27 Dec 2011, 08:53
Location: Rather not to say

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

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;
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7

Offline
Posts: 9
Joined: 27 Sep 2023, 23:45

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

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;
}

Offline
User avatar
*blah-blah-blah maniac*
Posts: 17444
Joined: 27 Dec 2011, 08:53
Location: Rather not to say

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

Already wrote how to do that.
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7
Post Reply