Created
December 12, 2015 18:29
-
-
Save MattRix/3ecec4325db2712efd7e to your computer and use it in GitHub Desktop.
Basic depth texture rendering
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Shader "----------/Edger" | |
| { | |
| SubShader | |
| { | |
| Tags { "RenderType"="Opaque" } | |
| Pass | |
| { | |
| CGPROGRAM | |
| #pragma vertex vert | |
| #pragma fragment frag | |
| #include "UnityCG.cginc" | |
| sampler2D _CameraDepthNormalsTexture; | |
| struct appdata | |
| { | |
| float4 pos : POSITION; | |
| float2 uv : TEXCOORD0; | |
| }; | |
| struct v2f | |
| { | |
| float4 pos : SV_POSITION; | |
| float2 uv:TEXCOORD0; | |
| }; | |
| //Vertex Shader | |
| v2f vert (appdata v) | |
| { | |
| v2f o; | |
| o.pos = mul (UNITY_MATRIX_MVP, v.pos); | |
| #if defined (UNITY_UV_STARTS_AT_TOP) | |
| o.uv = float2(v.uv.x,1-v.uv.y); | |
| #else | |
| o.uv = v.uv; | |
| #endif | |
| return o; | |
| } | |
| //Fragment Shader | |
| half4 frag (v2f i) : COLOR | |
| { | |
| return tex2D(_CameraDepthNormalsTexture, i.uv); | |
| } | |
| ENDCG | |
| } | |
| } | |
| FallBack "Diffuse" | |
| } |
Author
I found your code from William's site: http://williamchyr.com/2013/11/unity-shaders-depth-and-normal-textures/. I am trying to use depth information. And can't run his example. Do you know how I can code camera component or any related source?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ahhh github's indenting drives me nuts