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.
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.
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);
}
}
which shader to attach with it?? blur shader parameter…