I thought I’d share my Radial Blur Post Process Material.
This simplest Version of it:
Radial Blur with fixed number of equally weighted samples
This is the setup of the Material in der Material Editor. The Node named “Radial Blur” is actually just a Custom Node with HLSL code.
The HLSL Code for this Node is:
float2 ScreenMult = View.ViewSizeAndSceneTexelSize.xy / View.RenderTargetSize;
int TexIndex = 14;
float samples[10] = {-0.08,-0.05,-0.03,-0.02,-0.01,0.01,0.02,0.03,0.05,0.08};
float2 dir = ScreenMult * float2(0.5,0.5) - UV;
float4 sum = SceneTextureLookup(UV, TexIndex, false);
float2 pos = float2(0.0,0.0);
for(int i = 0; i<10; i++)
{
pos = UV + dir * samples* * sampleDist;
max(min(pos, ScreenMult * float2(1.0, 1.0)), float2(0.0,0.0));
sum += SceneTextureLookup(pos, TexIndex, false);
}
sum *= 1.0/11.0;
return sum;
A couple of explanations:
ScreenMult is a factor that is needed to convert the 0-1 range UVs that go into the UV Input to the range that is needed to Align the effect properly on the screen.
TexIndex is the index that corresponds PostProcessInput0 in SceneTextureLookup().
After that the lookup-distances are defined in the samples array and the direction of the lookup (line from the current UV coordinate and the center). The loop then iterates though all of the samples. Basically it just calculates the average of the looked up values and the original value.
The Scene Texture Node in the Material is needed to have access to the SceneTextureLookup function. The “Tex” Input of my CustomNode is actually not needed, but I kept it to remind myself that I need to create a SceneTexture Node in order to make it work.
This is the result of this effect:
I also have a version of this effect where I have weighted the samples and added the functionality to have a dynamic amount of them and a dynamic center coodinate. But since it’s just a matter of adding more parameters to this code and some simple changes, I don’t think it’s necessary to post it here. It’s also very unoptimzed because of the limitations I experienced with the current Custom Node’s functionality.
I’m also not very proficient in HLSL coding, so there might be a lot of points to improve on this effect.