【ShaderLab】Unity Shader学习:固定渲染管线

固定渲染管线基本用在高级的Shader在比较辣鸡的显卡上无法显示的情况。


一.显示单一的颜色

Shader "Unlit/Myshader"
{
    Properties
    {
        _Color("Main Color",Color)=(1.0,1.0,1.0,1.0)
    }
        SubShader
        {
            Pass
            {
                Material
                {
                    Diffuse[_Color]
                }
                Lighting On
            }
        }
}

效果如下:
这里写图片描述
其中,Diffuse[_Color]即赋予材质颜色。而Lighting On表示开启光照。如果没有开启光照,则效果如下:
这里写图片描述
诶!为啥啊!为什么关掉光照反倒变亮了!


二.显示一张贴图

Shader "Unlit/Myshader"
{
    Properties
    {
        _Tex1("Tex1(RGB)",2D)="white"{}
        _Color("Main Color",Color)=(1.0,1.0,1.0,1.0)
    }
        SubShader
        {
            Pass
            {
                Material
                {
                    Diffuse[_Color]
                }
                Lighting On
                SetTexture[_Tex1]
                {
                    //combine color部分,alpha部分
                    //材质 * 顶点颜色
                    Combine texture * primary,texture * constant
                }
            }
        }
}
Combine texture * primary,texture * constant
//↑ 这句还不太懂

效果如下:
这里写图片描述
然而为什么是这样黑乎乎的啦!


三.两张贴图叠加

Shader "Unlit/Myshader"
{
    Properties
    {
        _Tex1("Tex1(RGB)",2D)="white"{}
        _Tex1("Tex1(RGB)",2D)="white"{}
        _Color("Main Color",Color)=(1.0,1.0,1.0,1.0)
    }
        SubShader
        {
            Pass
            {
                Material
                {
                    Diffuse[_Color]
                }
                Lighting On
                SetTexture[_Tex1]
                {
                    Combine texture * primary
                }
                SetTexture[_Tex2]
                {
                    Combine texture * previous
                }
            }
        }
}

效果如下:
这里写图片描述
这里写图片描述
暂时还不太懂的就是Combine的作用和为什么黑乎乎的,之后再来填这个坑(:з」∠)

猜你喜欢

转载自blog.csdn.net/Dango_miracle/article/details/79578094