Unity Shader 21 Simple examples

Source: Internet
Author: User
Tags float range

Here is a simple shader code (the default code when creating a shader), which is analyzed in line with the code.

1Shader"Learnshaders/basicdiffuse" {2 Properties {3_maintex ("Base (RGB)", 2D) =" White" {4             }5     }6 Subshader {7 Tags {8             "Rendertype"="Opaque" }9Lod $Ten          One Cgprogram A         #pragmaSurface Surf Lambert -  - sampler2d _maintex; the         structInput { - float2 Uv_maintex; -         }; -  +         voidSurf (Input in, InOut surfaceoutput o) { -Half4 C =tex2d (_maintex, In.uv_maintex); +O.albedo =C.rgb; AO.alpha =C.A; at         } -  - ENDCG -     }  -FallBack"Diffuse" -}

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
    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 21 Simple examples

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.