                 const float4 col = float4((diffuse + ambient) * _Color.rgb + specular, _Color.a);
 #endif  // _ENABLE_REFLECTION_PROBE
 
-                pout o;
-                o.color = col;
-                const float4 projectionPos = UnityObjectToClipPos(float4(finalPos, 1.0));
-                o.depth = projectionPos.z / projectionPos.w;
-
-                return o;
+                fout fo;
+                fo.color = col;
+                fo.depth = getDepth(finalPos);
+
+                return fo;
             }
 
 

            }

            /*!
             * @brief Get color of reflection probe.
             * @param [in] refDir  Reflect direction.
             * @return Color of reflection probe.


            /*!
             * @brief Fragment shader function.
             * @param [in] fi  Input data from vertex shader
             * @return Output of each texels (fout).
             */
            fout frag(v2f fi)
            {
                // Define ray direction by finding the direction of the local coordinates
                // of the mesh from the local coordinates of the viewpoint.
                const float3 rayDir = normalize(fi.pos.xyz - fi.localSpaceCameraPos);
                const float invScale = 1.0 / _Scale;

                // Distance.
