Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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
0
Question by 1ht1baron · Feb 01, 2018 at 12:23 AM · effectperformance optimizationblur

Blur (Optimized) Effect Has Very Slow Performance on Mobile Devices

I want to blur effect like Alto's Adventure (3:13). https://youtu.be/TLCFGXprM94?t=3m13s

Blur (optimized) works very well on PC but it has very bad performance on mobile devices. How can i boost blur effect's performance? https://docs.unity3d.com/500/Documentation/Manual/script-BlurOptimized.html

Comment
Add comment
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

4 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Nighfox · Feb 01, 2018 at 04:31 AM

Use OnPreRender() and OnPostRender() instead of OnRenderImage() in BlurOptimized.cs as described here:

Comment
Add comment · Show 3 · 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 1ht1baron · Feb 01, 2018 at 01:28 PM 0
Share

Thank you very much. But what should i select as targetTexture? I changed in BlurOptimized.cs. Is everything right in my script ? Also, Hidden/Fastblur is choosen as Blur Shader. Is this right ?

     public class BlurOptimized : PostEffectsBase
     {
         RenderTexture myRenderTexture;
         public RenderTexture targetTexture;
         Camera camera;
         private int width, height, postProcess$$anonymous$$aterialPassNum;
         private $$anonymous$$aterial postProcess$$anonymous$$aterial;
 
 
         [Range(0, 2)]
         public int downsample = 1;
 
         public enum BlurType {
             StandardGauss = 0,
             SgxGauss = 1,
         }
 
         [Range(0.0f, 10.0f)]
         public float blurSize;
 
         [Range(1, 4)]
         public int blurIterations = 2;
 
         public BlurType blurType= BlurType.StandardGauss;
 
         public Shader blurShader = null;
         private $$anonymous$$aterial blur$$anonymous$$aterial = null;
 

         public override bool CheckResources () {
             CheckSupport (false);
 
             blur$$anonymous$$aterial = CheckShaderAndCreate$$anonymous$$aterial (blurShader, blur$$anonymous$$aterial);
 
             if (!isSupported)
                 ReportAutoDisable ();
             return isSupported;
         }
 
         public void OnDisable () {
             if (blur$$anonymous$$aterial)
                 DestroyImmediate (blur$$anonymous$$aterial);
         }
 
         void OnPreRender()
         {
             myRenderTexture = RenderTexture.GetTemporary(width,height,16);
             camera.targetTexture = myRenderTexture;
 
 
         }
         void OnPostRender()
         {
             camera.targetTexture = null; //null means framebuffer
             Graphics.Blit(myRenderTexture,null as RenderTexture, postProcess$$anonymous$$aterial, postProcess$$anonymous$$aterialPassNum);
             RenderTexture.ReleaseTemporary(myRenderTexture);
         }
     }
avatar image Nighfox 1ht1baron · Feb 01, 2018 at 11:24 PM 0
Share

Yes, it's Hidden/Fastblur. Just create a Render Texture in your Project View and drag that to reference in your BlurOptimized script.

avatar image 1ht1baron Nighfox · Feb 02, 2018 at 12:18 PM 0
Share

Firstly, Thank you very much and i am sorry for spending your time. When i use above codes, i have "material is null" error. If i delete postProcess$$anonymous$$aterial, postProcess$$anonymous$$aterialPassNum in my codes, it is working without any error but blurring working only width and height. It is not using fastblur shader. So, it looks so bad like pixels. Would you help me about BlurOptimized script. Where should i fix it in my script?

         [Range(0, 2)]
         public int downsample = 1;
 
         public enum BlurType {
             StandardGauss = 0,
             SgxGauss = 1,
         }
 
         [Range(0.0f, 10.0f)]
         public float blurSize;
 
         [Range(1, 4)]
         public int blurIterations = 2;
 
         public BlurType blurType= BlurType.StandardGauss;
 
         public Shader blurShader = null;
         private $$anonymous$$aterial blur$$anonymous$$aterial = null;
 
         public override bool CheckResources () {
             CheckSupport (false);
 
             blur$$anonymous$$aterial = CheckShaderAndCreate$$anonymous$$aterial (blurShader, blur$$anonymous$$aterial);
 
             if (!isSupported)
                 ReportAutoDisable ();
             return isSupported;
         }
 
         public void OnDisable () {
             if (blur$$anonymous$$aterial)
                 DestroyImmediate (blur$$anonymous$$aterial);
         }
 
         RenderTexture myRenderTexture;
         public RenderTexture targetTexture;
         public Camera camera;
         public int width, height, postProcess$$anonymous$$aterialPassNum;
                 public $$anonymous$$aterial postProcess$$anonymous$$aterial;
 
         void OnPreRender()
         {
             myRenderTexture = RenderTexture.GetTemporary(width,height,16);
             camera.targetTexture = myRenderTexture;
         }
         void OnPostRender()
         {
             camera.targetTexture = null; //null means framebuffer
             Graphics.Blit(myRenderTexture,null as RenderTexture);
             RenderTexture.ReleaseTemporary(myRenderTexture, postProcess$$anonymous$$aterial, postProcess$$anonymous$$aterialPassNum);
         }

avatar image
0

Answer by Bale_txy · Feb 01, 2018 at 02:17 AM

You should use profiler to check your memory usage when running in Unity, it could be your game's optimization issue

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 1ht1baron · Feb 01, 2018 at 03:25 AM 0
Share

https://i.hizliresim.com/D7265v.jpg Game always runs 60 fps but when blur effect active, fps drops to 15-20. It is related to the blur effect.I want to be smooth when blur effect activate.

avatar image
0

Answer by Kronnect · Feb 01, 2018 at 10:52 PM

Try Beautify’s blur. It has two performances modes and a transition option that goes from crisp image to extremely blurred effect.

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
avatar image
0

Answer by 1ht1baron · Feb 09, 2018 at 02:08 AM

It is still very slow on mobile devices. Are there any fix ?

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 Kronnect · Feb 09, 2018 at 05:50 AM 0
Share

Which mobile device are you testing on?

avatar image 1ht1baron Kronnect · Feb 09, 2018 at 08:24 AM 0
Share

Samsung Galaxy J7 Prime.

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.

Follow this Question

Answers Answers and Comments

77 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to blur my background 2 Answers

Blur Effect on camera slice - How do I blur only only the rendered portion of a camera which clear flag is set to Depth only ? 1 Answer

motion blur without unity pro 1 Answer

Creating a Blur Effect on GUITexture 0 Answers

need help with javascript for underwater blur effect 1 Answer


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