Fixed Function shaders实例

一、显示纯颜色物体

Shader "Example/FixedSolidColor" {
    Properties
    {
        _Color("MainColor (RGB)", Color) = (1,1,1,1)
    }

    SubShader
    {
        pass 
        {
            Lighting on
            Material
            {
                Diffuse[_Color]
            }
        }
    }
    FallBack "Diffuse"
}

二、各种颜色通道

Shader "Example/FixedFullColor" 
{
    Properties
    {
        _Color("Main Color", Color) = (1,1,1,0.5)
        _SpecColor("Spec Color", Color) = (1,1,1,1)
        _Emission("Emmisive Color", Color) = (0,0,0,0)
        _Shininess("Shininess", Range(0.01, 1)) = 0.7
    }
    SubShader
    {
        Pass
        {
            Lighting On
            SeparateSpecular On

            Material
            {
                Diffuse[_Color]
                Ambient[_Color]
                Shininess[_Shininess]
                Specular[_SpecColor]
                Emission[_Emission]
            }
        }
    }
}

三、显示一张贴图

Shader "Example/FixedOnePic" 
{
    Properties
    {
        _Color("MainColor(RGB)",Color) = (1,1,1,1)
        _MainTex("Base (RGB)", 2D) = "white" {}
    }

    SubShader
    {
        Pass
        {
            Lighting on
            Color(1,1,0,1)
            Material
            {
                Diffuse[_Color]
            }
            SetTexture[_MainTex]
            {
            //材质 * 定点颜色
                Combine texture * primary DOUBLE
            }
        }

    }
    FallBack "Diffuse"
}

四、多张贴图叠加

Shader "Example/FixedMulPic" 
{
    Properties
    {
        _Color("MainColor(RGB)",Color) = (1,1,1,1)
        _MainTex("Base (RGB)", 2D) = "white" {}
        _MainTex2("Base2 (RGB)", 2D) = "white" {}
        _MainTex3("Base3 (RGB)", 2D) = "white" {}
    }

    SubShader
    {
        Pass
        {
            Lighting on
            Color(1,1,0,1)
            Material
            {
                Diffuse[_Color]
            }

            SetTexture[_MainTex]
            {
                //第一张材质 * 定点颜色
                Combine texture * primary DOUBLE
            }

            SetTexture[_MainTex2]
            {
                //材质 * 之前累积(这里即第一张材质)
                Combine texture * previous DOUBLE
            }

            SetTexture[_MainTex3]
            {
                //材质 * 之前累积
                Combine texture * previous DOUBLE
            }
        }
    }
    FallBack "Diffuse"
}

五、透明通道贴图+双面显示

Shader "Example/FixedAlphaCull" 
{
    Properties
    {
        _Color("MainColor(RGB)",Color) = (1,1,1,1)
        _MainTex("Base (RGB)", 2D) = "white" {}
    }
    SubShader
    {
        Pass
        {
            Blend SrcAlpha OneMinusSrcAlpha
            Cull off
            Lighting on
            Color(1,1,0,1)
            Material
            {
                Diffuse[_Color]
            }
            SetTexture[_MainTex]
            {
                Combine texture * primary DOUBLE
            }
        }
    }
    FallBack "Diffuse"
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一零壹0

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值