Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by Griffo · Dec 15, 2012 at 02:42 PM · lerpblur

lerp blur effect unity pro

Hi,

Is it possible to have the blur effect on the camera slowly lerp in when called, as its in C# I have no idea where to start as I'm doing all my work in .js

Any advice or help would be appreciated, thanks.

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

2 Replies

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

Answer by clunk47 · Dec 17, 2012 at 03:27 AM

Well, I have modified the blur effect script to have a fade in option along with fade in speed, and max blur. You would need to create a new C# Script and name it Blur_MOD and place it in the Image effects folder. I have a public static int i for iterations if "Fade In" is enabled, and the effect's "Blur Spread" equals i if fade is enabled. I'm not so sure about UnityScript, but if you wanted to disable automatic fade, just uncheck "Fade In" and access "i" from another script by using Blur_MOD.i

I'm not sure if it will work the same way since I'm not as good at UnityScript as I am C#. Here is Blur_MOD.cs

Hope this at least gets you somewhere with your concern.

 using UnityEngine;
 using System.Collections;
 
 [ExecuteInEditMode]
 [AddComponentMenu("Image Effects/Blur_MOD")]
 public class Blur_MOD : MonoBehaviour
 {    
     public int iterations = 2;
     public static float i = 0;
     public bool fadeIn = false;
     public float fadeInSpeed = 2.0f;
     public float maxBlur = 3.0f;
     public float blurSpread = 0.0f;
     public Shader blurShader = null;    
     static Material m_Material = null;
     protected Material material {
         get {
             if (m_Material == null) {
                 m_Material = new Material(blurShader);
                 m_Material.hideFlags = HideFlags.DontSave;
             }
             return m_Material;
         } 
     }
     protected void OnDisable() {
         if( m_Material ) {
             DestroyImmediate( m_Material );
         }
     }    
     void FixedUpdate()
     {
         if(fadeIn)
         {
             blurSpread = i;
             i+= fadeInSpeed * Time.smoothDeltaTime;
         }
         if(i >= maxBlur)
             i = maxBlur;
     }
     protected void Start()
     {
         if (!SystemInfo.supportsImageEffects) {
             enabled = false;
             return;
         }
         if (!blurShader || !material.shader.isSupported) {
             enabled = false;
             return;
         }
     }
     public void FourTapCone (RenderTexture source, RenderTexture dest, int iteration)
     {
         float off = 0.5f + iteration*blurSpread;
         Graphics.BlitMultiTap (source, dest, material,
             new Vector2(-off, -off),
             new Vector2(-off,  off),
             new Vector2( off,  off),
             new Vector2( off, -off)
         );
     }
     private void DownSample4x (RenderTexture source, RenderTexture dest)
     {
         float off = 1.0f;
         Graphics.BlitMultiTap (source, dest, material,
             new Vector2(-off, -off),
             new Vector2(-off,  off),
             new Vector2( off,  off),
             new Vector2( off, -off)
         );
     }
     void OnRenderImage (RenderTexture source, RenderTexture destination) {        
         RenderTexture buffer = RenderTexture.GetTemporary(source.width/4, source.height/4, 0);
         RenderTexture buffer2 = RenderTexture.GetTemporary(source.width/4, source.height/4, 0);
         
         DownSample4x (source, buffer);
         
         bool oddEven = true;
         for(int i = 0; i < iterations; i++)
         {
             if( oddEven )
                 FourTapCone (buffer, buffer2, i);
             else
                 FourTapCone (buffer2, buffer, i);
             oddEven = !oddEven;
         }
         if( oddEven )
             Graphics.Blit(buffer, destination);
         else
             Graphics.Blit(buffer2, destination);
         
         RenderTexture.ReleaseTemporary(buffer);
         RenderTexture.ReleaseTemporary(buffer2);
     }    
 }
 
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 Griffo · Dec 17, 2012 at 07:22 AM 2
Share

Thank you for doing this, much appreciated, does exactly what I wanted.

avatar image clunk47 · Dec 17, 2012 at 07:32 AM 1
Share

Thank you for asking the question, I never thought about doing this until you asked, this will really come in handy :) I voted up your question for being a good one. Have a nice day!

avatar image
0

Answer by shirish47 · May 25, 2017 at 02:53 PM

which shader to attach with it?? blur shader parameter..

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.

Follow this Question

Answers Answers and Comments

12 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

Related Questions

Can I blur only part of the objects on my scene? 1 Answer

Unable to access Blur 2 Answers

Lerping a color.a upon Player Death? 0 Answers

Swing an object back and forth 0 Answers

My Lerp() is not working 2 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