- Home /
Linearized Depth Buffer - always black output
Hi! There is article on the internet, talking 'bout how to linearize depth buffer. (I want always to have it full colors from 0 to 255)
http://www.mvps.org/directx/articles/linear_z/linearz.htm
The code sniper in there is:
float4 vPos = mul(Input.Pos,worldViewProj);
vPos.z = vPos.z * vPos.w / Far;
Output.Pos = vPos;
I thought of Unity equivivalent as:
Input vert (float4 vertex : POSITION)
{
Input o;
float4 oPos = mul(o.pos,UNITY_MATRIX_MVP);
o.Z = oPos.z * oPos.w / _ProjectionParams.z;
return o;
}
But, I always get black output!
void surf (Input IN, inout SurfaceOutput o) {
float4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = IN.Z.r;
}
Am I wrong somewhere? if I use 1f - o.Albedo = IN.Z.r, zbuffer is always (51,51,51) color. HMMMM.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612093912im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Text mesh (font material) renders on top of everything, any way to change that? 7 Answers
Shader - Don't render parts at certain distance 1 Answer
Unity 5 Standard Shader Transparent render order issues 1 Answer
2.5D perspective rendering order challenges 2 Answers
Custom Surface Shader vs Unity Standard Shader - Performance 0 Answers