unity3d shader ar任意門(傳送門)通道遮罩 ColorMask

通道遮罩 ColorMask可以讓我們制定渲染結(jié)果的輸出通道,而不是通常情況下的RGBA這4個通道全部寫入??蛇x參數(shù)是 RGBA 的任意組合以及 0, 這將意味著不會寫入到任何通道,可以用來單獨做一次Z測試,而不將結(jié)果寫入顏色通道

Shader "DepthMask" {

    SubShader {
        // Render the mask after regular geometry, but before masked geometry and
        // transparent things.

        Tags {"Queue" = "Geometry-10" }

        // Turn off lighting, because it's expensive and the thing is supposed to be
        // invisible anyway.

        Lighting Off

        // Draw into the depth buffer in the usual way.  This is probably the default,
        // but it doesn't hurt to be explicit.

        ZTest LEqual
        ZWrite On

        // Don't draw anything into the RGBA channels. This is an undocumented
        // argument to ColorMask which lets us avoid writing to anything except
        // the depth buffer.

        ColorMask 0

        // Do nothing specific in the pass:

        Pass {}
    }
}

實現(xiàn)如圖效果,前面的cube改為DepthMask的shader,實現(xiàn)在前面的cube透明,但是仍然擋住了后面cube的效果


fdd904b67e934e24b10e5c9c84392fc2[1].jpg
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容