置灰公式: value=color.r x 0.299 +color.g x 0.587 + color.b * 0.114
color.rgb = lerp(color.rgb, Luminance(color.rgb), _Factor);
或文章来源:https://www.toymoban.com/news/detail-512467.htmlcolor.rgb = dot(color.rgb, fixed3(0.299, 0.587, 0.114));文章来源地址https://www.toymoban.com/news/detail-512467.html
Shader "UI/Custom/UIGray"
{
Properties
{
[PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {}
_Color("Tint", Color) = (1,1,1,1)
_StencilComp("Stencil Comparison", Float) = 8
_Stencil("Stencil ID", Float) = 0
_StencilOp("Stencil Operation", Float) = 0
_StencilWriteMask("Stencil Write Mask", Float) = 255
_StencilReadMask("Stencil Read Mask", Float) = 255
_ColorMask("Color Mask", Float) = 15
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip("Use Alpha Clip", Float) = 0
}
SubShader
{
Tags
{
"Queue" = "Transparent"
"IgnoreProj
到了这里,关于Unity3d 图片Image置灰shader的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!