-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathRenderFisheye.cs
47 lines (41 loc) · 1.28 KB
/
RenderFisheye.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright Massachusetts Institute of Technology 2018
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
public class RenderFisheye : MonoBehaviour {
public RenderCubemap cubemap_script;
public Shader shader;
public float alpha = 4.0f;
public float chi = 0.0f;
public float focalLength = 1.0f;
private Material _material;
private Material material {
get {
if (_material == null) {
_material = new Material(shader);
_material.hideFlags = HideFlags.HideAndDontSave;
}
return _material;
}
}
void Start () {
}
private void OnDisable() {
if (_material != null)
DestroyImmediate(_material);
}
void OnRenderImage(RenderTexture source, RenderTexture destination)
{
Debug.Log("OnRenderImage: Fisheye");
if (shader != null) {
material.SetTexture("_Cube", cubemap_script.cubemap);
material.SetFloat("_Alpha", alpha);
material.SetFloat("_Chi", chi);
material.SetFloat("_FocalLength", focalLength);
Graphics.Blit(source, destination, material);
} else {
Graphics.Blit(source, destination);
}
}
}