I’ve got the material working in a slightly different way using moadib’s code in 4.20.3, here’s the material, and a video workflow: UE4 Tutorial: Radial Blur (Request) - YouTube
Just in case anyone is interested
I’ve got the material working in a slightly different way using moadib’s code in 4.20.3, here’s the material, and a video workflow: UE4 Tutorial: Radial Blur (Request) - YouTube
Just in case anyone is interested
To use “MobileSceneTextureLookup()” instead of “SceneTextureLookup()”.
For Mobile Example:
const float2 ScreenMult = View.ViewSizeAndInvSize.xy * View.BufferSizeAndInvSize.zw;
const int TexIndex = 14;
const float Samples[11] = {-0.08,-0.05,-0.03,-0.02,-0.01,0,0.01,0.02,0.03,0.05,0.08};
float2 dir = float2(0.5,0.5) - ScreenUV;
float4 sum = float4(0.0, 0.0, 0.0, 0.0);
for(int i = 0; i<11; i++)
{
float2 pos = ScreenUV + dir * Samples* * BlurDist;
pos = clamp(pos, float2(0.0,0.0), float2(1.0, 1.0));
#if (ES2_PROFILE || ES3_1_PROFILE || MOBILE_EMULATION)
sum += MobileSceneTextureLookup(Parameters, TexIndex, pos * ScreenMult);
#else
sum += SceneTextureLookup(pos * ScreenMult, TexIndex, false);
#endif
}
return sum / 11.0;
Works fine
Does any of you have a version of this that just blurs ? With no radial involved
does it work in 4.20, i heard there are problems with hlsl in ue4.20
I tried your sollution but it doesn’t work on 4.21
is there any change required ?
I was able to solve right and bottom edges.
Use “ViewportUVToSceneTextureUV”
const float2 ScreenMult = View.ViewSizeAndInvSize.xy * View.BufferSizeAndInvSize.zw;
const int TexIndex = 14;
const float Samples[11] = {-0.08,-0.05,-0.03,-0.02,-0.01,0,0.01,0.02,0.03,0.05,0.08};
float2 dir = float2(0.5,0.5) - ViewportUV;
float4 sum = float4(0.0, 0.0, 0.0, 0.0);
for(int i = 0; i<11; i++)
{
float2 pos = ViewportUV + dir * Samples* * BlurDist;
pos = clamp(pos, float2(0.0,0.0), float2(1.0, 1.0));
sum += SceneTextureLookup(ViewportUVToSceneTextureUV(pos * ScreenMult, TexIndex), TexIndex, false);
}
return sum / 11.0;
Has anyone managed to get this working on UE4.22?
Mine still works in 4.22
Custom node code is:
int TexIndex = 14;
float2 dir = ScreenMult * Center - UV + Distortion;
float4 sum = SceneTextureLookup(ViewportUVToSceneTextureUV(UV,TexIndex), TexIndex, false);
float2 pos = float2(0.0,0.0);
float delta = sampleDist/Samples;
float initial = Samples/2 * delta;
float currentValue = initial;
for(int i = 0; i<Samples; i++)
{
pos = UV + dir * currentValue;
pos = max(min(pos, ScreenMult * float2(1.0, 1.0)), float2(0.0,0.0));
sum += SceneTextureLookup(ViewportUVToSceneTextureUV(pos,TexIndex), TexIndex, false)* i*2/Samples ;
currentValue -= delta;
}
sum *= 1.0/((Samples/Gain)+1);
return sum;
Sorry for the long delay on responding everyone. I didn’t see any notifications via email! I shared a zip of a VR version a while back, don’t remember what engine version it was or if it will still work but here’s the link:
ColorVignette.zip (82.7 KB)
Does anyone know why it might not work in 4.11? I’ve followed along with the examples I’ve seen here, but…it just doesn’t DO anything. It doesn’t create any errors, it just doesn’t work.
Works in 4.25
For those who might need Gaussian blur on the mobile platform, here is the code work in 4.25.
float3 res = 0;
//new - get invSize from here
float2 invSize = View.ViewSizeAndInvSize.zw;
//new - we need to fix uv coordinates like this (still seems to be a bug in 4.21)
uv = ViewportUVToSceneTextureUV(uv,14);
int TexIndex = 14;
float weights] =
{
0.01, 0.02, 0.04, 0.02, 0.01,
0.02, 0.04, 0.08, 0.04, 0.02,
0.04, 0.08, 0.16, 0.08, 0.04,
0.02, 0.04, 0.08, 0.04, 0.02,
0.01, 0.02, 0.04, 0.02, 0.01
};
float offsets] = { -4, -2, 0, 4, 2 };
#if (ES2_PROFILE || ES3_1_PROFILE || MOBILE_EMULATION)
if(Mask <= 0.01) return MobileSceneTextureLookup(Parameters, TexIndex, uv);
#else
if(Mask <= 0.01) return SceneTextureLookup(uv, TexIndex, false);
#endif
uv *= 0.5;
[unroll(10)]for (int i = 0; i < 5; ++i) //add unroll keyword to solve the error. It helps hlsl code to expend when compile.
{
float v = uv.y + offsets* * invSize.y * Mask * BlurStrength;
int temp = i * 5;
for (int j = 0; j < 5; ++j)
{
float u = uv.x + offsets[j] * invSize.x * Mask * BlurStrength;
float2 uvShifted = uv + float2(u, v);
float weight = weights[temp + j];
#if (ES2_PROFILE || ES3_1_PROFILE || MOBILE_EMULATION)
float3 tex = MobileSceneTextureLookup(Parameters, TexIndex, uvShifted); //use MobileSceneTextureLookup function for mobile.
#else
float3 tex = SceneTextureLookup(uvShifted, TexIndex, false);
#endif
res += tex * weight;
}
}
return float4(res, 1);
Has anyone managed to get this working on UE4.26?
Works in 4.26
Here’s a code I found on the youtube video from user CCV334, which works with 4.26 for me:
const float2 ScreenMult = View.ViewSizeAndInvSize.xy *
View.BufferSizeAndInvSize.zw;
const int TexIndex = 14;
float samples[11] = {-0.08,-0.05,-0.03,-0.02,-0.01,0,0.01,0.02,0.03,0.05,0.08};
float2 dir = float2(0.5,0.5) - ScreenUV;
float4 sum = float4(0.0, 0.0, 0.0, 0.0);
for(int i = 0; i<11; i++)
{
float2 pos = ScreenUV + dir * samples[i] * BlurDist;
pos = clamp(pos, float2(0.0, 0.0), float2(1.0, 1.0));
sum += SceneTextureLookup(pos * ScreenMult, TexIndex, false);
}
return sum / 11.0;
Hi guys, does anyone know why my blur material stretches the viewport?
I used the same material in UE4.7 and it worked but in ue5 i get that effect.
Here’s the screenshot and shader setup including the code i’m using:
const int TexIndex = 14;
const float Samples[11] = {-0.08,-0.05,-0.03,-0.02,-0.01,0,0.01,0.02,0.03,0.05,0.08};
float2 dir = float2(0.5,0.5) - ScreenUV;
float4 sum = float4(0.0, 0.0, 0.0, 0.0);
for(int i = 0; i<11; i++)
{
float2 pos = ScreenUV + dir * Samples[i] * Blur;
pos = clamp(pos, float2(0.0,0.0), float2(1.0, 1.0));
sum += SceneTextureLookup(pos * ScreenMult, TexIndex, false);
}
return sum / 11.0;
Same issue here
I think it somehow related to screen percentage but I can’t figure out how to fix it
Bumping this as well, as I can’t seem to figure out what is breaking the HLSL code.
Hi!
Use ViewportUVToSceneTextureUV(pos,TexIndex)
instead of pos * ScreenMult
const int TexIndex = 14;
float samples[11] = {-0.08,-0.05,-0.03,-0.02,-0.01,0,0.01,0.02,0.03,0.05,0.08};
float2 dir = float2(0.5,0.5) - ScreenUV;
float4 sum = float4(0.0, 0.0, 0.0, 0.0);
for(int i = 0; i<11; i++)
{
float2 pos = ScreenUV + dir * samples[i] * BlurDist;
pos = clamp(pos, float2(0.0, 0.0), float2(1.0, 1.0));
sum += SceneTextureLookup(ViewportUVToSceneTextureUV(pos,TexIndex), TexIndex, false);
}
return sum / 11.0;