表面着色器的属性类型

作者:追风剑情 发布于:2015-6-25 22:02 分类:Shader

https://docs.unity3d.com/Manual/SL-Properties.html

  1. Shader "Custom/BasicDiffuse" {
  2. //http://docs.unity3d.com/Manual/SL-Properties.html
  3. Properties {
  4. //变量名 ("GUI Inspector面板上显示的名称", 变量类型) = 默认值
  5. _My2D ("My 2D", 2D) = "white" {}
  6. _My3D ("My 3D", 3D) = "white" {}
  7. _MyColor ("My Color", Color) = (1, 1, 1, 1)
  8. _MyRange ("My Range", Range(0, 10)) = 2.5
  9. _MyFloat ("My Float", Float) = 2.5
  10. //legacy,Int是由Float提供支持,不是真正的整型类型
  11. _MyInt ("My Int", Int) = 2
  12. //Integer是真正的整型类型
  13. _MyInt ("My Int", Integer) = 2
  14. _MyVector ("My Vector", Vector) = (1, 2, 5, 10)
  15. _MyCube ("My Cube", Cube) = "" {}
  16. }
  17. SubShader {
  18. Tags { "RenderType"="Opaque" }
  19. LOD 200
  20. CGPROGRAM
  21. #pragma surface surf Lambert
  22.  
  23. sampler2D _MainTex;
  24.  
  25. struct Input {
  26. float2 uv_MainTex;
  27. };
  28.  
  29. void surf (Input IN, inout SurfaceOutput o) {
  30. half4 c = tex2D (_MainTex, IN.uv_MainTex);
  31. o.Albedo = c.rgb;
  32. o.Alpha = c.a;
  33. }
  34. ENDCG
  35. }
  36. FallBack "Diffuse"
  37. }


shader-propertys.png


属性

Properties
{
    [PerRendererData]
    _MainTex("Albedo", 2D) = "white" {}
    _Color("Color", Color) = (1.0, 1.0, 1.0, 1.0)
    _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
    _Fade("Alpha Fade", Range(0.0, 1.0)) = 1.0
    [Toggle(_EMISSION)]
    _EnableEmission("Enable Emission", Float) = 0.0
    
    [HDR] _EmissiveColor("Emissive Color", Color) = (0.0, 0.0, 0.0, 1.0)

    [Enum(UnityEngine.Rendering.BlendMode)]
    _SrcBlend("Source Blend", Float) = 1  // "One"
    [Enum(UnityEngine.Rendering.BlendMode)]
    _DstBlend("Destination Blend", Float) = 10  // "OneMinusSrcAlpha"
    [Enum(UnityEngine.Rendering.BlendMode)]
    _SrcBlendAlpha("Source Blend Alpha", Float) = 1  // "One"
    [Enum(UnityEngine.Rendering.BlendMode)]
    _DstBlendAlpha("Destination Blend Alpha", Float) = 1 // "One"
    [Enum(UnityEngine.Rendering.BlendOp)]
    _BlendOp("Blend Operation", Float) = 0  // "Add"
    [Enum(UnityEngine.Rendering.CompareFunction)]
    _ZTest("Depth Test", Float) = 4
    [Enum(UnityEngine.Rendering.CullMode)]
    _CullMode("Cull Mode", Float) = 0   
    [Enum(UnityEngine.Rendering.CompareFunction)]
    _StencilComp("Stencil Comparison", Int) = 0
    [Enum(UnityEngine.Rendering.StencilOp)]
    _StencilOp("Stencil Operation", Int) = 0
    _StencilWriteMask("Stencil Write Mask", Range(0, 255)) = 255
    _StencilReadMask("Stencil Read Mask", Range(0, 255)) = 255
}

Pass
{
    Name "Main"
    Tags{ "LightMode" = "UniversalForward" }
    LOD 100
    Blend[_SrcBlend][_DstBlend],[_SrcBlendAlpha][_DstBlendAlpha]
    BlendOp[_BlendOp]
    ZTest[_ZTest]
    ZWrite[_ZWrite]
    Cull[_CullMode]
    Offset[_ZOffsetFactor],[_ZOffsetUnits]
    ColorMask[_ColorMask]

    Stencil
    {
        Ref[_Stencil]
        Comp[_StencilComp]
        Pass[_StencilOp]
        ReadMask[_StencilReadMask]
        WriteMask[_StencilWriteMask]
    }
} 

11111111.png

标签: Shader

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号