UnityMol  0.9.6-875
UnityMol viewer / In developement
ImageEffects.cs
Go to the documentation of this file.
1 using System;
2 using UnityEngine;
3 
4 namespace UnityStandardAssets.ImageEffects
5 {
7  [AddComponentMenu("")]
8  public class ImageEffects
9  {
10  public static void RenderDistortion(Material material, RenderTexture source, RenderTexture destination, float angle, Vector2 center, Vector2 radius)
11  {
12  bool invertY = source.texelSize.y < 0.0f;
13  if (invertY)
14  {
15  center.y = 1.0f - center.y;
16  angle = -angle;
17  }
18 
19  Matrix4x4 rotationMatrix = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0, 0, angle), Vector3.one);
20 
21  material.SetMatrix("_RotationMatrix", rotationMatrix);
22  material.SetVector("_CenterRadius", new Vector4(center.x, center.y, radius.x, radius.y));
23  material.SetFloat("_Angle", angle*Mathf.Deg2Rad);
24 
25  Graphics.Blit(source, destination, material);
26  }
27 
28 
29  [Obsolete("Use Graphics.Blit(source,dest) instead")]
30  public static void Blit(RenderTexture source, RenderTexture dest)
31  {
32  Graphics.Blit(source, dest);
33  }
34 
35 
36  [Obsolete("Use Graphics.Blit(source, destination, material) instead")]
37  public static void BlitWithMaterial(Material material, RenderTexture source, RenderTexture dest)
38  {
39  Graphics.Blit(source, dest, material);
40  }
41  }
42 }
A Utility class for performing various image based rendering tasks.
Definition: ImageEffects.cs:8
static void RenderDistortion(Material material, RenderTexture source, RenderTexture destination, float angle, Vector2 center, Vector2 radius)
Definition: ImageEffects.cs:10
static void Blit(RenderTexture source, RenderTexture dest)
Definition: ImageEffects.cs:30
static void BlitWithMaterial(Material material, RenderTexture source, RenderTexture dest)
Definition: ImageEffects.cs:37