c# Code (csharp): function OnEnable () { camera.depthTextureMode = DepthTextureMode.Depth; }:confused: shader Code (csharp): sampler2D _CameraDepthTexture; v2f vert( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv = v.texcoord.xy; return o; } half4 fragThin (v2f i) : COLOR { half4 depth= tex2D (_CameraDepthTexture, i.uv); return depth; } But why the results of a white, can not see anything?
Code (csharp): sampler2D _CameraDepthTexture; v2f vert( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv = v.texcoord.xy; return o; } half4 fragThin (v2f i) : COLOR { half4 depth = half4(Linear01Depth(tex2D(_CameraDepthTexture, i.uv).r); return depth; }
Thank you very much to reply my post in the forum Why only use Linear01Depth, can not LinearEyeDepth? Only Linear01Depth in play mode to be effective, LinearEyeDepth nothing in game mode. uniform float4 _ZBufferParams; // Z buffer to linear 0..1 depth (0 at eye, 1 at far plane) inline float Linear01Depth( float z ) { return 1.0 / (_ZBufferParams.x * z + _ZBufferParams.y); } // Z buffer to linear depth inline float LinearEyeDepth( float z ) { return 1.0 / (_ZBufferParams.z * z + _ZBufferParams.w); }
Also, I want to ask can depthTexture to gui draw on it? For example rendertexture. GUI.DrawTexture (new Rect(0, 0, 128, 128), m_ReflectionTexture, ScaleMode.StretchToFill, false); This will not find _CameraDepthTexture GUI.DrawTexture (new Rect(0, 0, 128, 128), _CameraDepthTexture, ScaleMode.StretchToFill, false);?
is the _CameraDepthTexture only usable in vert and frag shaders ? not in surface shaders ? Cause I can't get this to work in a surface shader
since this thread has been reanimated: can i copy the "clearing-texture"(dont know if this even exists) from one viewport to another? http://forum.unity3d.com/threads/16...Mask-Texture?p=1109426&viewfull=1#post1109426