title: Cg: omit depth write
body: <p>I am outputting depth in Cg in a branch, like so:</p>
  
  <pre><code>ZWrite On
  ..
  void frag(v2f IN, out color : COLOR, out depth : DEPTH) {
   if (statement) {
    color = float4(1);
   } else {
    color = float4(0);
    depth = 0;
   }
  }
  </code></pre>
  
  <p>However as you see I omit writing the depth in the first condition. This results in undefined behaviour, but I believe this is common practice in GLSL (omitting writing to glFragDepth will result in the original depth).</p>
  
  <p>What should I do to get the original depth in the first condition in Cg when having a depth value for output?</p>