6
2012
Radial Blur Shader
Using the same godrays shader, you get nice radial blur effect for images. This one is also modified to use objectUV, instead of screenUV,
so you can rotate the plane around..
Webplayer:
http://unitycoder.com/upload/demos/Radial_Blur_shader_unity/ *webplayer broken in current unity webplayer version?
Shader source:
// FakeRadialBlur shader for Unity (v1.0)
// based on this shader: http://unitycoder.com/blog/2012/10/02/fake-godrays-shader/
// which is converted/based on this webgl shader: http://demo.bkcore.com/threejs/webgl_tron_godrays.html
Shader "UnityCoder/FakeRadialBlur"
{
Properties
{
tDiffuse ("Base (RGB)", 2D) = "white" {}
fX ("fX", Float) = 0.5
fY ("fY", Float) = 0.5
fExposure ("fExposure", Float) = 0.6
fDecay ("fDecay", Float) = 0.93
fDensity ("fDensity", Float) = 0.96
fWeight ("fWeight", Float) = 0.4
fClamp ("fClamp", Float) = 1.0
//iSamples ("iSamples", Int) = 20
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
Cull Off
CGPROGRAM
#pragma target 3.0
#pragma surface surf Lambert
sampler2D tDiffuse;
float fX,fY,fExposure,fDecay,fDensity,fWeight,fClamp,iSamples;
struct Input {
float2 uvtDiffuse;
float4 screenPos;
};
void surf (Input IN, inout SurfaceOutput o)
{
int iSamples=100;
float2 vUv = IN.uvtDiffuse;
//vUv *= float2(1,1); // repeat?
float2 deltaTextCoord = float2(vUv - float2(fX,fY));
deltaTextCoord *= 1.0 / float(iSamples) * fDensity;
float2 coord = vUv;
float illuminationDecay = 1.0;
float4 FragColor = float4(0.0);
for(int i=0; i < iSamples ; i++)
{
coord -= deltaTextCoord;
float4 texel = tex2D(tDiffuse, coord);
texel *= illuminationDecay * fWeight;
FragColor += texel;
illuminationDecay *= fDecay;
}
FragColor *= fExposure;
FragColor = clamp(FragColor, 0.0, fClamp);
float4 c = FragColor;
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
3 Comments + Add Comment
Leave a comment
Recent posts
- Adding Real World Location to Ice Fishing Prototype
- [web tool] Image Channel Inspector : AlphaScope
- Editor Tool: Smart Recompile (don’t recompile if edit comments)
- Editor Tool: Scene Size Analyzer
- LudumDare 60: Old Tech
- uBasic Scripting Language for Unity
- GreaseMonkey+Editor Plugin: 1-Click Copy script from ChatGPT (Web) to Unity Editor (as script)
- Editor Tool: Property Watcher
- .unityignore : Hide files from Project window
- PostBuild Script to Create Single exe Standalone File
- Game Loop Designer
- Favorites in PackageManager
Recent Comments
Coin:
CUgDSbRqFcAumDSAcdKDvuXsw26VdkJe8C8WGUQHBAGS
An article by













Very nice!!! Wish I had found this site earlier, but from now on I’ll come back always looking for new shaders 🙂
Thank you very much.
^ shader source added
Thanks for this, helped a lot.
I had to make some changes for this to work for WebGL builds.