常量颜色(constantColor)

作者:追风剑情 发布于:2018-12-26 21:00 分类:Shader

示例: 演示constantColor的使用
一个粒子效果Shader
Shader "Custom/ParticlesTest"
{
	Properties {
		_IlluminCol ("Self-Illumination color (RGB)", Color) = (1,1,1,1)
    	_MainTex ("Particle Texture", 2D) = "white" {}
		_Cutoff ("Base Alpha cutoff", Range (0,.9)) = .5
	}

Category {
    Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
    //Alpha混合
	Blend SrcAlpha OneMinusSrcAlpha
	//Alpha测试
	AlphaTest GEqual [_Cutoff]
    Cull Off Lighting Off ZWrite Off Fog { Color (0,0,0,0) }

    BindChannels {
        Bind "Color", color
        Bind "Vertex", vertex
        Bind "TexCoord", texcoord
    }

    SubShader {
        Pass {
            SetTexture [_MainTex] {
				constantColor [_IlluminCol]
				//combine rgb, alpha
				//combine 纹理的rgb与constant的rgb相乘, 纹理的alpha与constant的alpha相乘
                combine texture * constant, texture * constant
            }
        }
    }
}
}

效果

3333.png

222.png1.gif

标签: Shader

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号