How to make a custom material Unlit

Hi, How can I go about making this material Unlit.

I have tried different things like “Lighting Off” and tried merging the existing Unlit shader but I don’t have much experience in writing shaders, so any help will be highly appriciated.

About the shader:

This shader takes 2 images:
Map 1: RGB (this is used for adding an additive decal to the second texture).
Map 2. RGBA (This is the main texture+transparency)

Map 1 will take Map 2’s alphamap into account.

Shader "AlphaDecal2" {
Properties {
	_Color ("Main Color", Color) = (1,1,1,1)
	_MainTex ("Base (RGB)", 2D) = "white" {}
	_DecalTex ("Base (RGB) Trans (A)", 2D) = "white" {}
}

SubShader {
	Tags { "RenderType"="Opaque" }
	Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
	LOD 200

	
	
CGPROGRAM
#pragma surface surf Lambert alpha

sampler2D _MainTex;
sampler2D _DecalTex;
fixed4 _Color;

struct Input {
	float2 uv_MainTex;
	float2 uv_DecalTex;
};

void surf (Input IN, inout SurfaceOutput o) {
	fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
	half4 decal = tex2D(_DecalTex, IN.uv_DecalTex);
	
 c.rgb = c.rgb + decal.rgb;
 c.a *= decal.a; 
 c *= _Color;
 o.Albedo = c.rgb;
 o.Alpha = c.a;
	
}
ENDCG




}

Fallback "Diffuse"
}

putting Lighting Off before the CGPROGRAM line should do the trick.

Surface shaders are meant to be used with lighting though, so the most efficient thing you could do is to make a make a vertex/fragment shader. If you really don’t want to do that, you can also make your own lighting model and simply return the input. Check Unity - Manual: Custom lighting models in Surface Shaders and this How to write unlit surface shader? - Questions & Answers - Unity Discussions as an example.

The whole point of surface shaders is that they handle lighting.
So the best option is to write a vertex/fragment shader. You could start by modifying Daniel Brauer’s example from the Unity3d wiki.

In those types of shaders, the output is indicated semantics. In this example, for the fragment shader it’s : COLOR, and it’s the float4 return value of the frag function. That output value contains both rgb and a.

You can leave the vertex shader as it is; it simply calculates the position of the vertex on screen, and the uv coordinates that vertex has.

[Edit] The easiest way to change it in a surface shader, by the way, is writing to .Emission in stead of Albedo. Emission is add after the rest of the lighting calculations. But as I explained above, if you’re not using the Albedo output, you might as well replace the surface shader entirely.

The Lighting command in Shaderlab is only for fixed function lighting. It has no effect on surface shaders, or vertex/fragment shaders in general.

As RC-1290 says, your best bet is to write a vertex/fragment shader, starting with that template from the wiki.

Thanks a lot guys, I will give it a try today.

It worked, I know it’s a hack but my experience writing shaders is not good enough to rewrite the entire shader Im afraid.

“o.Emission = +c.rgb;” - at least it’s working now :slight_smile:

Thanks.

Figured that, that’s why I also suggested writing the vertex/fragment shader or the not proper custom lighting way. I tend to stay away from surface shaders and fixed function stuff, so I relied on an unity answer topic where the lighting off was suggested and was marked as answered.