Version: Unity 6.0 (6000.0)
言語 : 日本語
シェーダーでの深度テストモードの設定
シェーダーでのステンシルバッファの確認または書き込み

シェーダーで深度バッファへの書き込みを無効にする

ZWrite は、レンダリング時に深度バッファのコンテンツを更新するかどうかを設定します。通常、ZWrite は不透明なオブジェクトに有効で、半透明なオブジェクトには無効です。

ZWrite を無効にすると、深度の順序付けが正しく行われないことがあります。このような場合は、CPU でジオメトリをソートする必要があります。

このコードサンプルでは、Pass ブロックでこのコマンドを使用するための構文を示しています。

Shader "Examples/CommandExample"
{
    SubShader
    {
         // The rest of the code that defines the SubShader goes here.

        Pass
        {    
              // Disables writing to the depth buffer for this Pass
              ZWrite Off
            
              // The rest of the code that defines the Pass goes here.
        }
    }
}

このサンプルコードでは、SubShader ブロックでこのコマンドを使用するための構文を示しています。

Shader "Examples/CommandExample"
{
    SubShader
    {
         // Disables writing to the depth buffer for this SubShader
         ZWrite Off

         // The rest of the code that defines the SubShader goes here.        

        Pass
        {    
              // The rest of the code that defines the Pass goes here.
        }
    }
}

その他の参考資料

シェーダーでの深度テストモードの設定
シェーダーでのステンシルバッファの確認または書き込み