- Home /
How can I apply a blur effect to planes or textures in Unity Free?
Hi, I'm developing a small game using planes in parallax and would like to fake a DOF effect to simulate depth. I've seen free effects but I'm not really happy with them. I really wanted to be able to apply some sort of gaussian blur on the planes or textures according to their distance from the camera. I don't need true DOF in this case.
Answer by GraviterX · Aug 27, 2014 at 11:57 PM
I've used this and it works for what you need: http://forum.unity3d.com/threads/indieeffects-bringing-almost-aaa-quality-post-process-fx-to-unity-indie.198568/
Answer by AlwaysSunny · Aug 27, 2014 at 11:36 PM
Short answer: You probably shouldn't.
Long answer: Assuming you're only going to do this once per image at Start() time - as opposed to once per frame which will melt your computer - the method is this:
Copy the texture into a new texture object
Read the pixel data into an array of pixels
Perform a box or gaussian blur operation on that array
Write the array back into the texture object you created
Apply the change using myTexture.Apply();
Box and gaussian blur algorithms are around here and there. Note that it'd be best to do this in your graphics editing program unless you absolutely have no choice. This is a very expensive operation.
Reading and rewriting a texture every frame is very expensive. Though I've managed to do it on a scene with only a few textures involved for an overlay effect.
This is not my area of expertise, but shouldn't a shader be able to achieve this effect?
If he wanted it to update every frame, yeah, I think a shader approach exists. But even on the GPU, blurring is too expensive to perform on multiple objects.
Your answer
Follow this Question
Related Questions
Depth of Field with Shader Replacement? 1 Answer
Unity corrupted; textures missing on run, letters missing in editor. 1 Answer
Blurred textures 0 Answers
Depth of field problem with transparent objects 1 Answer
How to blur my background 2 Answers