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
- Favorites in PackageManager
- LudumDare59 : Signal
- Unity Editor: Tree Generator
- Leaf/Foliage Generator Tools (Runs in Browser)
- Testing Unity AI Beta
- Ways to Support UnityCoder Development
- Using UI Slider to Create 5-Star Rating Element
- Game Music Library For Unity (editor plugin)
- Fontastic : Easily Test Fonts in Unity Editor!
- GeoTiff Importer & Terrain Generator for Unity
- Create Baked DropShadow for UI images
- .JP2 Ortho Image Converter to PNG/JPG/TIFF
Recent Comments
- on Mesh Exploder (sources)
- on Sprite Sheet Flip Book Shader
- on Sprite Sheet Flip Book Shader
- on [Asset Store] PolygonCollider2D Optimizer
- on Trajectory Test Scene 2.0
- on Vector3 maths for dummies!
- on UnityHub 3.6.0: Remove Version Control & Cloud Dashboard columns
- on Using RenderDoc with Unity (graphics debugger)
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.