|
|
|
|
|
|
|
|
|
|
public class CameraGrain: MonoBehaviour |
|
|
|
{ |
|
|
|
[SerializeField] |
|
|
|
public ARCameraManager cameraManager |
|
|
|
{ |
|
|
|
get { return m_CameraManager; } |
|
|
|
set { m_CameraManager = value; } |
|
|
|
} |
|
|
|
|
|
|
|
m_CameraManager = FindObjectOfType (typeof(ARCameraManager)) as ARCameraManager; |
|
|
|
if(m_CameraManager == null) |
|
|
|
{ |
|
|
|
m_CameraManager = FindObjectOfType (typeof(ARCameraManager)) as ARCameraManager; |
|
|
|
} |
|
|
|
|
|
|
|
m_CameraManager.frameReceived += OnReceivedFrame; |
|
|
|
void Update() |
|
|
|
void OnDisable() |
|
|
|
if(m_Renderer != null && m_CameraManager.cameraGrainTexture != null) |
|
|
|
m_CameraManager.frameReceived -= OnReceivedFrame; |
|
|
|
} |
|
|
|
|
|
|
|
void OnReceivedFrame(ARCameraFrameEventArgs eventArgs){ |
|
|
|
if(m_Renderer != null && eventArgs.cameraGrainTexture != null) |
|
|
|
m_Renderer.material.SetTexture("_NoiseTex", m_CameraManager.cameraGrainTexture); |
|
|
|
m_Renderer.material.SetFloat("_NoiseIntensity", m_CameraManager.noiseIntensity); |
|
|
|
m_Renderer.material.SetTexture("_NoiseTex", eventArgs.cameraGrainTexture); |
|
|
|
m_Renderer.material.SetFloat("_NoiseIntensity", eventArgs.noiseIntensity); |
|
|
|
|
|
|
|
} |