|
|
|
|
|
|
using System.Collections; |
|
|
|
using System.Collections.Generic; |
|
|
|
using UnityEngine; |
|
|
|
using UnityEngine.XR.ARFoundation; |
|
|
|
using UnityEngine; |
|
|
|
public class CameraGrain: MonoBehaviour |
|
|
|
public class CameraGrain : MonoBehaviour |
|
|
|
get { return m_CameraManager; } |
|
|
|
set { m_CameraManager = value; } |
|
|
|
get => m_CameraManager; |
|
|
|
set => m_CameraManager = value; |
|
|
|
} |
|
|
|
|
|
|
|
Renderer m_Renderer; |
|
|
|
|
|
|
if(m_CameraManager == null) |
|
|
|
if (m_CameraManager == null) |
|
|
|
m_CameraManager = FindObjectOfType (typeof(ARCameraManager)) as ARCameraManager; |
|
|
|
m_CameraManager = FindObjectOfType<ARCameraManager>(); |
|
|
|
} |
|
|
|
|
|
|
|
m_Renderer = GetComponent<Renderer>(); |
|
|
|
|
|
|
m_CameraManager.frameReceived -= OnReceivedFrame; |
|
|
|
} |
|
|
|
|
|
|
|
void OnReceivedFrame(ARCameraFrameEventArgs eventArgs){ |
|
|
|
if(m_Renderer != null && eventArgs.cameraGrainTexture != null) |
|
|
|
void OnReceivedFrame(ARCameraFrameEventArgs eventArgs) |
|
|
|
{ |
|
|
|
if (m_Renderer && eventArgs.cameraGrainTexture) |
|
|
|
{ |
|
|
|
m_Renderer.material.SetTexture("_NoiseTex", eventArgs.cameraGrainTexture); |
|
|
|
m_Renderer.material.SetFloat("_NoiseIntensity", eventArgs.noiseIntensity); |
|
|
|
|
|
|
} |
|
|
|
} |