123456789101112131415161718192021222324 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- [RequireComponent(typeof(Camera))]
- public class Depth2 : MonoBehaviour
- {
- //material that's applied when doing postprocessing
- [SerializeField]
- private Material postprocessMaterial;
- private void Start()
- {
- Camera camera = GetComponent<Camera>();
- camera.depthTextureMode = camera.depthTextureMode | DepthTextureMode.Depth;
- }
- //method which is automatically called by unity after the camera is done rendering
- void OnRenderImage(RenderTexture source, RenderTexture destination)
- {
- //draws the pixels from the source texture to the destination texture
- Graphics.Blit(source, destination, postprocessMaterial);
- }
- }
|