• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by paulaceccon · Nov 15, 2012 at 05:02 PM · backgroundblur

Blur Effect

There is a "easy" way to blur a background, a behind window, with Unity Indie?

I would like to blur the background when the player pause the game. But it not just a background (if it was I guess I could have two images and change between them), that are buttons, objects and all kind of things... So, I don't know how could I do this.

I know that it's easier with the Unity Pro -- http://answers.unity3d.com/questions/21699/unity-blur-behind-window.html, but I just have the Unity Indie...

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image fafase · Nov 30, 2012 at 10:01 PM 0
Share

I have never tried but what about a simple blurred texture. Gimp has some plug-ins to be done in 5$$anonymous$$, simply have a blurred layer with like 20 or 30% opacity. You display the result in front of your camera behind the GUI and that should blur the back. Again, maybe that is totally retarded...

4 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by cregox · Nov 30, 2012 at 10:27 AM

Easy answer is: not possible.

Long answer below...

I can think of only two ways, very much like your linked answer:

  1. camera script. set up two cameras, with proper clear flags and culling masks, one will blur all.

  2. post processing a captured image. no idea how to go here.

I'm not sure how Unity's indie limitations work, how they prevent every image effect to work for instance. I'm sure there's something that can be done in Windows with DLLs, or even Mac... Not so positive if it's possible on any other medium.

But the point here is: if it's easy to do in Unity Pro, why bother trying to do it in Unity Indie? The whole point of unity indie is making things work, not look good. You only need them to look good if you're selling them, to which point you should be making money to buy such "cheap" licenses.

Edit

I got on my email an ingenious solution from Jessespike that, oddly, I can't see here or "get permission to see" it when I click on the link. So, here it is:

Just force the texture to draw a smaller mipmap. this.gameObject.renderer.material.mainTexture.mipMapBias = 3;

If you can do that on every "background" texture in scene (just use tags), then maybe you achieve a satisfying effect...

Yet another idea I thought after that, which is probably the best you can get:

  • (4) Using the two cameras setup from item 1, add in the front of the blurring one a transparent object with a transparent shader. Then you can either leave it at that (for simplicity) or animate its texture with a sequence of "blurring" getting stronger images (which can all be in one file) and a script from unify community, such as Animating Tiled Texture or SpriteManager

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image paulaceccon · Nov 30, 2012 at 09:42 PM 0
Share

The thing is that I love to work with games. I'm taking my master right now, but I don't have many games made, so I am developing some so that are have a portfolio. I really want to work with gams, but everybody asks for portfolio. So, I'm doing another independent game, and I would like it to be cool, well presented, but I can afford for a Unity Pro yet. ;)

avatar image paulaceccon · Nov 30, 2012 at 09:54 PM 0
Share

I know that this doesn't really matter in a game built with this mean. It's just that I am kind of perfectionist. :X

avatar image cregox · Nov 30, 2012 at 10:02 PM 0
Share

It does really matter in a game, just not for portfolio. Show your perfectionism with the tools you got, much better than wasting time developing something that's done already.

avatar image cregox · Dec 01, 2012 at 11:06 AM 0
Share

@paulaceccon In any case, just added a couple of ideas

avatar image
1

Answer by paulaceccon · Feb 19, 2013 at 10:21 AM

Recently I've found this.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image cregox · Apr 09, 2013 at 07:32 PM 0
Share

fucking awesome! did it work with unity free? have you accomplished your question with it? you should accept this! :)

avatar image HarryGodden · Nov 17, 2013 at 07:21 PM 0
Share

"IF YOU ARE SEEING THE DEFAULT PIN$$anonymous$$ SHADER: This Shader uses GrabPass for taking the image behind it. GrabPass internally uses RenderTextures, which are a Unity Pro feature. So unless you have Unity Pro, I’m afraid you will not be able to use this shader."

Information taken from the authors desciption

avatar image
1

Answer by Bryan-Legend · Apr 23, 2017 at 07:31 PM

Here's a nice shader that works well.

From: https://forum.unity3d.com/threads/solved-dynamic-blurred-background-on-ui.345083/#post-2853442

 Shader "Unlit/FrostedGlass"
 {
     Properties
     {
         _Radius("Radius", Range(1, 255)) = 1
     }
  
     Category
     {
         Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Opaque" }
      
         SubShader
         {
             GrabPass
             {
                 Tags{ "LightMode" = "Always" }
             }
  
             Pass
             {
                 Tags{ "LightMode" = "Always" }
  
                 CGPROGRAM
                 #pragma vertex vert
                 #pragma fragment frag
                 #pragma fragmentoption ARB_precision_hint_fastest
                 #include "UnityCG.cginc"
  
                 struct appdata_t
                 {
                     float4 vertex : POSITION;
                     float2 texcoord: TEXCOORD0;
                 };
  
                 struct v2f
                 {
                     float4 vertex : POSITION;
                     float4 uvgrab : TEXCOORD0;
                 };
  
                 v2f vert(appdata_t v)
                 {
                     v2f o;
                     o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
                     #if UNITY_UV_STARTS_AT_TOP
                     float scale = -1.0;
                     #else
                     float scale = 1.0;
                     #endif
                     o.uvgrab.xy = (float2(o.vertex.x, o.vertex.y*scale) + o.vertex.w) * 0.5;
                     o.uvgrab.zw = o.vertex.zw;
                     return o;
                 }
  
                 sampler2D _GrabTexture;
                 float4 _GrabTexture_TexelSize;
                 float _Radius;
  
                 half4 frag(v2f i) : COLOR
                 {
                     half4 sum = half4(0,0,0,0);
  
                     #define GRABXYPIXEL(kernelx, kernely) tex2Dproj( _GrabTexture, UNITY_PROJ_COORD(float4(i.uvgrab.x + _GrabTexture_TexelSize.x * kernelx, i.uvgrab.y + _GrabTexture_TexelSize.y * kernely, i.uvgrab.z, i.uvgrab.w)))
  
                     sum += GRABXYPIXEL(0.0, 0.0);
                     int measurments = 1;
  
                     for (float range = 0.1f; range <= _Radius; range += 0.1f)
                     {
                         sum += GRABXYPIXEL(range, range);
                         sum += GRABXYPIXEL(range, -range);
                         sum += GRABXYPIXEL(-range, range);
                         sum += GRABXYPIXEL(-range, -range);
                         measurments += 4;
                     }
  
                     return sum / measurments;
                 }
                 ENDCG
             }
             GrabPass
             {
                 Tags{ "LightMode" = "Always" }
             }
  
             Pass
             {
                 Tags{ "LightMode" = "Always" }
  
                 CGPROGRAM
                 #pragma vertex vert
                 #pragma fragment frag
                 #pragma fragmentoption ARB_precision_hint_fastest
                 #include "UnityCG.cginc"
  
                 struct appdata_t
                 {
                     float4 vertex : POSITION;
                     float2 texcoord: TEXCOORD0;
                 };
  
                 struct v2f
                 {
                     float4 vertex : POSITION;
                     float4 uvgrab : TEXCOORD0;
                 };
  
                 v2f vert(appdata_t v)
                 {
                     v2f o;
                     o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
                     #if UNITY_UV_STARTS_AT_TOP
                     float scale = -1.0;
                     #else
                     float scale = 1.0;
                     #endif
                     o.uvgrab.xy = (float2(o.vertex.x, o.vertex.y*scale) + o.vertex.w) * 0.5;
                     o.uvgrab.zw = o.vertex.zw;
                     return o;
                 }
  
                 sampler2D _GrabTexture;
                 float4 _GrabTexture_TexelSize;
                 float _Radius;
  
                 half4 frag(v2f i) : COLOR
                 {
  
                     half4 sum = half4(0,0,0,0);
                     float radius = 1.41421356237 * _Radius;
  
                     #define GRABXYPIXEL(kernelx, kernely) tex2Dproj( _GrabTexture, UNITY_PROJ_COORD(float4(i.uvgrab.x + _GrabTexture_TexelSize.x * kernelx, i.uvgrab.y + _GrabTexture_TexelSize.y * kernely, i.uvgrab.z, i.uvgrab.w)))
  
                     sum += GRABXYPIXEL(0.0, 0.0);
                     int measurments = 1;
  
                     for (float range = 1.41421356237f; range <= radius * 1.41; range += 1.41421356237f)
                     {
                         sum += GRABXYPIXEL(range, 0);
                         sum += GRABXYPIXEL(-range, 0);
                         sum += GRABXYPIXEL(0, range);
                         sum += GRABXYPIXEL(0, -range);
                         measurments += 4;
                     }
  
                     return sum / measurments;
                 }
                 ENDCG
             }
         }
     }
 }
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image tanoshimi · Apr 23, 2017 at 07:38 PM 1
Share

The question was asked nearly 5 years ago; ever since Unity 5.x came out, the answer is simply "apply a blur image effect to the camera that renders the background"...

avatar image
0

Answer by flyingbanana · Aug 05, 2015 at 12:28 AM

Improved version giving a better blur with higher strength. Came up with this after a while.

Gaussian Blur

alt text

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

14 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to blur my background 2 Answers

Fading Blur 1 Answer

Unity 5.6 splash screen tool: Blurry background image 0 Answers

How do you place a smaller background over the previous background on a new state. 0 Answers

Changing render time (framerate) of a shader 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges