Unity3d Tutorial Shader Chapter: The second fixed Function Shader

Source: Internet
Author: User

original articles should be reproduced please specify: Reproduced from the Wind Yu Chong Unity3d Tutorial College


Fixed function Shader Introduction: Belongs to the stationary rendering pipeline Shader, which is basically used for advanced Shader when the old video card cannot be displayed. Using the Shaderlab language, the syntax is similar to Microsoft's FX files or Nvidia's CGFX.

Example one: show a single color
Let's take a look at the first example, show a single color, the comments are written in detail, according to the format can be written.

Root Shadershader "Custom/1_1color" {   //attribute Properties    {        //define a color        _color ("Main color", color) = (1,.5,. 5,1)    }    //child shader    Subshader {        Pass {            Material {                ///Display the color                diffuse [_color]            }            //Turn on the light switch, i.e. accept the light            Lighting on        }}}    

  


Example two: displaying a decal


Shader "Custom/1_2show1texture" {    Properties {        _maintex ("Base (RGB)", 2D) = "White" {}        _color ("Main Color", Color) = (1,1,1,1)    }    subshader {        Pass        {            Material            {                diffuse[_color]            }            Lighting on            Settexture[_maintex]            {                //combine color section, Alpha part                //      material * Vertex color                Combine Texture * Primary,texture * constant            }}}    

  

Example three: overlay of two posting graphs


Shader "Custom/1_3merge2texture" {    Properties {        _maintex ("Base (RGB)", 2D) = "White" {}        _maintex2 ("Tex2 (RG B) ", 2D) =" White "{}        _color (" Main Color ", color) = (1,1,1,1)    }    subshader {        Pass        {            Material            {                diffuse[_color]            }            Lighting on            Settexture[_maintex]            {                //      First material * Vertex color                Combine Texture * Primary            }            SETTEXTURE[_MAINTEX2]            {                //      second material * Accumulated before (this is the first material)                Combine texture * Previous            }        }    }}

  

Unity3d Tutorial Shader Chapter: The second fixed Function Shader

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.