码迷,mamicode.com
首页 > 编程语言 > 详细

Unity Shader 2 一个简单的示例

时间:2015-03-01 00:20:57      阅读:290      评论:0      收藏:0      [点我收藏+]

标签:

下面是一段简单的Shader代码(创建一个Shader时的默认代码),下面对照代码逐行分析。

 1 Shader "LearnShaders/BasicDiffuse" {
 2     Properties {
 3         _MainTex ("Base (RGB)", 2D) = "white" {
 4             }
 5     }
 6     SubShader {
 7         Tags {
 8             "RenderType"="Opaque" }
 9         LOD 200
10         
11         CGPROGRAM
12         #pragma surface surf Lambert
13 
14         sampler2D _MainTex;
15         struct Input {
16             float2 uv_MainTex;
17         };
18 
19         void surf (Input IN, inout SurfaceOutput o) {
20             half4 c = tex2D (_MainTex, IN.uv_MainTex);
21             o.Albedo = c.rgb;
22             o.Alpha = c.a;
23         }
24 
25         ENDCG
26     } 
27     FallBack "Diffuse"
28 }

1. Shader "LearnShaders/BasicDiffuse" { ... }

2. Properties { ... }

  2.1 Surface Shader property type

    Float Range: Range(min, max)
    Defines a float property, represented as a slider from min to max in the inspector.
    name ("display name", Range (min, max)) = number

    Color: Color
    Defines a color property.
    name ("display name", Color) = (number,number,number,number)

    Texture 2D: 2D
    Defines a 2D texture property.
    name ("display name", 2D) = "name" { options }

    Rectangle: Rect
    Defines a rectangle (non power of 2) texture property.
    name ("display name", Rect) = "name" { options }

    Cubemap: Cube
    Defines a cubemap texture property.
    name ("display name", Cube) = "name" { options }

    Float: Float
    Defines a float property.
    name ("display name", Float) = number

    Vector: Vector
    Defines a four-component vector property.
    name ("display name", Vector) = (number,number,number,number)

Unity Shader 2 一个简单的示例

标签:

原文地址:http://www.cnblogs.com/x5lcfd/p/4306363.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!