1. 程式人生 > >Unity3D Shader官方教程翻譯(十八)----Shader語法 另外一些命令(分類)

Unity3D Shader官方教程翻譯(十八)----Shader語法 另外一些命令(分類)

Category 分類

Category is a logical grouping of any commands below it. This is mostly used to "inherit" rendering state. For example, your shader might have multiplesubshaders, and each of them requires fog to be off, blending set to additive, etc. You can use Category for that:

Category 是一個分類邏輯組。它將具有相同操作的SubShader分組到一起。大多數情況下是用來繼承渲染狀態。舉例:

你的Shader可能含有多個SubShader, 每一個SubShader都需要關閉fog並且啟用blending。這種情況下你就可以使用分類:

Shader "example" {
Category {
    Fog { Mode Off }
    Blend One One
    SubShader {
        // ...
    }
    SubShader {
        // ...
    }
    // ...
}
}

Category block only affects shader parsing, it's exactly the same as "pasting" any state set inside Category into all blocks below it. It does not affect shader execution speed at all.

分類模組隻影響Shader的解析。它相當於貼上這些渲染狀態集到它裡面的所有模組(SubShader)中。它不會影響Shader的執行速度。