- Home /
Question by
jason-yi-kai · Jun 07, 2013 at 01:45 AM ·
shadertransparentunlitgrayscale
Unlit / Transparent / Adjustable Grayscale shader
Hi Can some one give me a hand to create a Unlit / Transparent / Adjustable Grayscale shader?
I'm half way through... I just can't get the unlit work without causing an error message. :(
Here is my script so far. It is a Transparent/Adjustable Grayscale Shader.
Shader "Custom/Grayscale" {
Properties {
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_EffectAmount ("Effect Amount", Range (0, 1)) = 1.0
}
Category
{
ZWrite On
Alphatest Greater 0.5
Cull Off
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 200
CGPROGRAM
#pragma surface surf Lambert alpha
sampler2D _MainTex;
uniform float _EffectAmount;
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
half4 c = tex2D(_MainTex, IN.uv_MainTex);
o.Albedo = lerp(c.rgb, dot(c.rgb, float3(0.3, 0.59, 0.11)), _EffectAmount);
o.Alpha = c.a;
}
ENDCG
}
}
Fallback "Unlit/Transparent"
}
Comment
Answer by Imawizrd · Jun 24, 2013 at 01:13 AM
I think this shader was written by Jessy. It was posted here: http://forum.unity3d.com/threads/115455-Unlit-with-adjustable-Alpha
Shader "Somian/Unlit/Transparent" {
Properties{
_Color ("Main Color (A=Opacity)", Color) = (1,1,1,1)
_MainTex ("Base (A=Opacity)", 2D) = ""
}
Category {
Tags {"Queue"="Transparent" "IgnoreProjector"="True"}
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
SubShader {Pass {
GLSLPROGRAM
varying mediump vec2 uv;
#ifdef VERTEX
uniform mediump vec4 _MainTex_ST;
void main() {
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
uv = gl_MultiTexCoord0.xy * _MainTex_ST.xy + _MainTex_ST.zw;
}
#endif
#ifdef FRAGMENT
uniform lowp sampler2D _MainTex;
uniform lowp vec4 _Color;
void main() {
gl_FragColor = texture2D(_MainTex, uv) * _Color;
}
#endif
ENDGLSL
}}
SubShader {Pass {
SetTexture[_MainTex] {Combine texture * constant ConstantColor[_Color]}
}}
}
}
Unlit shaders I use (scroll down to Unity iPhone Shaders ) : http://owlchemylabs.com/content/
Your answer
![](https://koobas.hobune.stream/wayback/20220613103654im_/https://answers.unity.com/themes/thub/images/avi.jpg)