Skip to content

Shader1

daao edited this page Aug 5, 2018 · 2 revisions

What Is Shader

ShaderLab Structure

ShaderLab Syntax

Shader "name" { [Properties] Subshaders [Fallback] [CustomEditor] }

ShaderLab: SubShader

Subshader { [Tags] [CommonState] Passdef [Passdef ...] }

// ...
SubShader {
    Tags { "Queue" = "Transparent" } //Note that the following tags recognized by Unity must be inside  SubShader section and not inside Pass!
    
    Lighting Off //Any statements that are allowed in a Pass definition can also appear in Subshader block. This will make all passes use this “shared” state.
    
    Pass {
    }
}

ShaderLab: SubShader Pass

Pass { [Name and Tags] [RenderSetup] }

// ...
SubShader{
    Pass {
        Name "TestPass"
        Tags { "LightMode" = "ForwardBase" }
    }
}
// ...

ShaderLab: other commands => Category

Category {
    Tags { 
        "Queue"="Transparent" 
    }
    Blend SrcAlpha One
    SubShader {
        Pass {
            .......
        }
    }
}

ShaderLab Format

surface / vetex&fragment / fixed function

unity 对于旧平台的不支持 导致对 fixed function 的维护兴趣大大降低, 并且把现阶段的 fixed fuction 代码在导入阶段就开始转换了 http://aras-p.info/blog/2015/04/27/optimizing-unity-renderer-3-fixed-function-removal/

https://docs.unity3d.com/Manual/UpgradeGuide5-Shaders.html

https://forum.unity3d.com/threads/official-removing-some-fixed-function-shader-functions-for-5-0.250107/

So Just use vetex&fragment

ShaderLab RenderPath

Note: Deferred rendering is not supported when using Orthographic projection. If the camera’s projection mode is set to Orthographic, these values are overridden, and the camera will always use Forward rendering.

RenderQueue

http://blog.csdn.net/candycat1992/article/details/46228771

https://qxsoftware.github.io/Unity-Rendering-Order.html

Clone this wiki locally