Created
April 18, 2018 23:36
-
-
Save shole/06976f27ce9d965be16d25587a3a4a75 to your computer and use it in GitHub Desktop.
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 "Hidden/CopyDepth2Color" { | |
Properties { | |
_MainTex ("Texture", 2D) = "white" {} | |
} | |
SubShader { | |
Cull Off ZWrite On ZTest Always | |
Pass { | |
CGPROGRAM | |
#pragma vertex vert | |
#pragma fragment CopyDepthBufferFragmentShader | |
#include "UnityCG.cginc" | |
struct appdata { | |
float4 vertex : POSITION; | |
float2 uv : TEXCOORD0; | |
}; | |
struct v2f { | |
float2 uv : TEXCOORD0; | |
float4 vertex : SV_POSITION; | |
}; | |
v2f vert (appdata v) { | |
v2f o; | |
o.vertex = UnityObjectToClipPos(v.vertex); | |
o.uv = v.uv; | |
return o; | |
} | |
sampler2D_float _MainTex; | |
float CopyDepthBufferFragmentShader(v2f i) : COLOR { | |
float depth = SAMPLE_DEPTH_TEXTURE(_MainTex, i.uv); | |
depth = Linear01Depth(depth); | |
return depth; | |
} | |
ENDCG | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment