- Home /
Custom shader with unlit textures is too bright
I don't know the first thing about shaders, but I'm trying to write one that wil let me show only a specific part of a texture by using another texture specifying the area in black and white.
I got this working, but I can't get my unlit textures to be lighted as other unlit shaders do in Unity. I added the o.Emission = c.rgb, but now the result is too bright.
Also, Unity keeps complaining about "The shader wants normals". Any pointers on how to fix that are also much appreciated. Thanks.
Shader "Custom/DiffTrans" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_TransTex ("Transparent (A)", 2D) = "white" {}
}
SubShader {
Tags { "IgnoreProjector"="True" "RenderType"="Transparent" }
LOD 100
Lighting OFF
ZWrite Off
CGPROGRAM
#pragma surface surf Lambert alpha
sampler2D _MainTex;
sampler2D _TransTex;
struct Input {
float2 uv_MainTex;
float2 uv_TransTex;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
fixed4 d = tex2D (_TransTex, IN.uv_TransTex);
o.Albedo = c.rgb;
o.Alpha = d.rgb;
o.Emission = c.rgb;
}
ENDCG
}
FallBack "Transparent/VertexLit"
}
Using emission is really not the way to go about this. You don't want light on a surface. Don't use a surface shader.
Thanks, I was afraid of that. Any pointers on how to achieve this the proper way?
As for the 'shader wants normals' thing, presumably the mesh you are applying the material on doesn't have normal data on its vertices.