using UnityEngine; using System.Collections; [ExecuteInEditMode] public class DepthNormals : MonoBehaviour { public Material mat; bool showNormalColors = true; void Start() { //GetComponent().depthTextureMode = DepthTextureMode.Depth; // 화면크기의 32비트(8비트/채널) 텍스처를, 뷰 공간 법선이 RG, 깊이가 BA 채널에 // 인코딩된 형태로 빌드한다. // 법선은 Stereographic Projection(스테레오 투영)을 사용하여 인코딩 되며 // 깊이는 두 8비트 채널로 압축된 16비트 값이다. // http://docs.unity3d.com/kr/current/Manual/SL-CameraDepthTexture.html GetComponent().depthTextureMode = DepthTextureMode.DepthNormals; } void Update() { if (Input.GetKeyDown(KeyCode.E)) { showNormalColors = !showNormalColors; } if (showNormalColors) { mat.SetFloat("_showNormalColors", 1.0f); } else { mat.SetFloat("_showNormalColors", 0.0f); } } // Called by the camera to apply the image effect void OnRenderImage(RenderTexture source, RenderTexture destination) { // material로 걍 뿌림 (Mgin/DepthRingPass) Graphics.Blit(source, destination, mat); } }