Blur Filter Not Working in Certain OS/Browser Combinations

In trying to figure out how to use the blur filter, I’ve discovered some conditions where it doesn’t work properly. You can see in the screen captures it works in Unity, but draws random bits of the screen when run in the web player in certain browser/OS combinations. In the sample, that’s part of my dock being drawn where the blurred image should be.

On my Mac and another in the office, both OS 10.6.8 and Safari 5.1.2, it has the same problem. Likewise in Firefox 9.0.1 on those machines.

However for a colleague running Safari 5.0.5 on Mac OS it works correctly. It also works correctly on Win XP in FF and IE. Not sure what to make of this. But at this point, testing is impossible.

Here’s the URL if you’d like to see if it works for you: Lens Sim

After wasting a few days on this, I’ve found the solution: DON’T USE THE BUILT-IN IMAGE EFFECT. I found some blur code online and it produces even better results than the Unity code. And it works in the web player. So now I’m a bit upset about springing for the Pro version. At least I can now use my own splash screen.

One suggestion, perhaps these should not be called “image effects,” since they don’t appear to work on images. It looks like they only work if applied full screen. Maybe they should be called “full-screen-only camera effects.”

could you tell us where you found this alternative blur stuff?
thx!

This is what I ended up using:

// http://www.blackpawn.com/texts/blur/default.html

//------------------------------------------------

function Blur (source: Texture2D, dest: Texture2D, rad: int) {
	
	var temp: Texture2D;
	
	temp = new Texture2D(source.width, source.height, TextureFormat.RGB24, false);
	
	BlurHorizontal(source, temp, rad);
	BlurVertical(temp, dest, rad);
	dest.Apply();
	Destroy(temp);
}

//------------------------------------------------

function BlurHorizontal (source: Texture2D, dest: Texture2D, rad: int) {
	var xx: int;
	var yy: int;
	var kx: int;
	var total: Color;
	var tColor: Color;
	
	for (yy = 0; yy < source.height; ++yy) {
		total = Color(0.0, 0.0, 0.0);
		
		// Process entire window for first pixel
		for (kx = -rad; kx <= rad; ++kx) {
			tColor = source.GetPixel(kx, yy);
			total.r += tColor.r;
			total.g += tColor.g;
			total.b += tColor.b;
		}
			
		dest.SetPixel(0, yy, total / (rad * 2 + 1));
		
		// Subsequent pixels just update window total
		for (xx = 1; xx < source.width; ++xx) {
			// Subtract pixel leaving window
			tColor = source.GetPixel(xx - rad - 1, yy);
			total.r -= tColor.r;
			total.g -= tColor.g;
			total.b -= tColor.b;
			
			// Add pixel entering window
			tColor = source.GetPixel(xx + rad, yy);
			total.r += tColor.r;
			total.g += tColor.g;
			total.b += tColor.b;
			
			dest.SetPixel(xx, yy, total / (rad * 2 + 1));
		}
	}
}

//------------------------------------------------

function BlurVertical (source: Texture2D, dest: Texture2D, rad: int) {
	var xx: int;
	var yy: int;
	var ky: int;
	var total: Color;
	var tColor: Color;
	
	for (xx = 0; xx < source.width; ++xx) {
		total = Color(0.0, 0.0, 0.0);
		
		// Process entire window for first pixel
		for (ky = -rad; ky <= rad; ++ky) {
			tColor = source.GetPixel(xx, ky);
			total.r += tColor.r;
			total.g += tColor.g;
			total.b += tColor.b;
		}
			
		dest.SetPixel(xx, 0, total / (rad * 2 + 1));
		
		// Subsequent pixels just update window total
		for (yy = 1; yy < source.height; ++yy) {
			// Subtract pixel leaving window
			tColor = source.GetPixel(xx, yy - rad - 1);
			total.r -= tColor.r;
			total.g -= tColor.g;
			total.b -= tColor.b;
			
			// Add pixel entering window
			tColor = source.GetPixel(xx, yy + rad);
			total.r += tColor.r;
			total.g += tColor.g;
			total.b += tColor.b;
			
			dest.SetPixel(xx, yy, total / (rad * 2 + 1));
		}
	}
}

//------------------------------------------------

That code is horrifically slow though. Are your problems with flash output? if so please submit a bug.

This is the best I could find that I could successfully translate to Unity/JS. It’s fast enough for this particular app. If you have faster code, I’d be very happy to see it.

I’m not sure what you mean about flash output. If it’s not flash output, then it’s not a bug? The problem I had with the blur filter is described in the original post in this thread.