How to make a Transparent/Diffuse shader Unlit?

Hello,

I’m in need of making this shader that I have unlit but so far my copy/paste attempts are failing to put both of them together. Any shader masters around to show me the way?

Shader "Transparent/Diffuse on top" {
Properties {
	_Color ("Main Color", Color) = (1,1,1,1)
	_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
}

SubShader 
{
	Ztest NotEqual
	Tags {"Queue"="Geometry+1" "IgnoreProjector"="True" "RenderType"="Transparent"}
	LOD 200

	CGPROGRAM
	#pragma surface surf Lambert alpha
	
	sampler2D _MainTex;
	fixed4 _Color;
	
	struct Input {
		float2 uv_MainTex;
	};
	
	void surf (Input IN, inout SurfaceOutput o) {
		fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
		o.Albedo = c.rgb;
		o.Alpha = c.a;
	}
	ENDCG
	}
	
	Fallback "Transparent/VertexLit"
}

What do you mean by “unlit”? Diffuse is a descriptor of reflectance, and doesn’t mean anything without light.

Yeah, but more often than not, in game graphics, “diffuse” is used to mean “albedo”.

What you’re after, though, is far simpler than a surface shader. This should (untested) work;

Shader "Transparent/Diffuse on top" {

	Properties {

		_Color ("Main Color", Color) = (1,1,1,1)

		_MainTex ("Diffuse (RGB) Alpha (A)", 2D) = "white" {}

	}



	SubShader {

		Blend SrcAlpha OneMinusSrcAlpha

		Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent"}

		LOD 200

		

		Pass {

			CGPROGRAM

				#pragma vertex vert

				#pragma fragment frag

				#pragma multi_compile_builtin

				#pragma fragmentoption ARB_precision_hint_fastest

				

				#include "UnityCG.cginc"

				

				struct v2f

				{

					float4	pos : SV_POSITION;

					float2	uv : TEXCOORD0;

				}; 



				v2f vert (appdata_base v)

				{

					v2f o;

					o.pos = mul(UNITY_MATRIX_MVP, v.vertex);

					o.uv = v.texcoord.xy;

					return o;

				}

				

				sampler2D _MainTex;

				float4 _Color;



				fixed4 frag(v2f i) : COLOR

				{

					fixed4 result = tex2D(_MainTex, i.uv) * _Color;

					return result;

				}

			ENDCG

		}

	}

	FallBack "Transparent/Cutout/VertexLit"

}
1 Like

thanks, i’ll give it ago. I was messing around adding unlit code to a diffuse shader with poor results.