Square shading 2D

On a ground made of several chunks of customized planes, like this =>

where the smallest unit of space is the square, what would be the best way to darken some squares ?
like that (ugly screenshot but you get the idea) ==>


where i could say this square has this level of darkness, this square has another one, etc.

I’d like not to use multiples materials of the same texture atlas with various predefined darkness levels even if it would be a solution.
I’d prefer something more dynamic because i don’t want to make x versions of the same textures.

I don’t want to use something like a transparent plane level in front of the ground because i think it would be too much loss of performance for such a humble result.

EDIT: found that i must use lightmaps →

if think i’ve found a solution, please just tell me if you think it’s a good one =>

I’ve made a fast test with a “legacy shader/lightmap/vertex lit” shader
and a simple lightmap texture
then use mesh.uv1 to set some random uv to the lightmap texture ==>

Is it a good solution ?
Is it the right shader to use ? (i only need a very simple one but it must work on android as well as on pc)

It seems Legacy shaders are deprecated…

PS: i’m a compleat noob with such things…

I don’t have much experience in these techniques for 2d-games, but if the scripting wouldn’t be too heavy, i guess you could just adjust a standard shader to take an additional float “_LightLvl” and have that multiply your Albedo output? (per object)

(Take a look at surface shaders, they’re really easy to make/configure!)

i have a trouble with the legacy lightmap shader => there is no transparency and really i need some (not for the ground but for everything else…)

in this code, what could i add for transparency ?

Shader "Custom/NewShader" {
	Properties {
		
		_Color ("Main Color", Color) = (1,1,1,1)
		_SpecColor ("Spec Color", Color) = (1,1,1,1)
		_Shininess ("Shininess", Range (0.01, 1)) = 0.7
		_MainTex ("Base (RGB)", 2D) = "white" {}
		_LightMap ("Lightmap (RGB)", 2D) = "lightmap" { LightmapMode }
	
	
	}
// ------------------------------------------------------------------
// Three texture cards (Radeons, GeForce3/4Ti and up)

SubShader {
	LOD 100
	Tags { "RenderType"="Opaque" }

	Pass {
		Name "BASE"
		Tags {"LightMode" = "Vertex"}
		Material {
			Diffuse [_Color]
			Shininess [_Shininess]
			Specular [_SpecColor]
		}

		Lighting On
		SeparateSpecular On

		BindChannels {
			Bind "Vertex", vertex
			Bind "normal", normal
			Bind "texcoord1", texcoord0 // lightmap uses 2nd uv
			Bind "texcoord1", texcoord1 // lightmap uses 2nd uv
			Bind "texcoord", texcoord2 // main uses 1st uv
		}
		
		SetTexture [_LightMap] {
			constantColor [_Color]
			combine texture * constant
		}
		SetTexture [_LightMap] {
			constantColor (0.5,0.5,0.5,0.5)
			combine previous * constant + primary
		}
		SetTexture [_MainTex] {
			combine texture * previous DOUBLE, texture * primary
		}
	}
}

// ------------------------------------------------------------------
// Dual texture cards - draw in two passes

SubShader {
	LOD 100
	Tags { "RenderType"="Opaque" }

	// Always drawn base pass: texture * lightmap
	Pass {
		Name "BASE"
		Tags {"LightMode" = "Always"}
		BindChannels {
			Bind "Vertex", vertex
			Bind "normal", normal
			Bind "texcoord1", texcoord0 // lightmap uses 2nd uv
			Bind "texcoord", texcoord1 // main uses 1st uv
		}
		SetTexture [_LightMap] {
			constantColor [_Color]
			combine texture * constant
		}
		SetTexture [_MainTex] {
			combine texture * previous, texture * primary
		}
	}
	
	// Vertex lights: add lighting on top of base pass
	Pass {
		Name "BASE"
		Tags {"LightMode" = "Vertex"}
		Blend One One ZWrite Off Fog { Color (0,0,0,0) }
		Material {
			Diffuse [_Color]
			Shininess [_Shininess]
			Specular [_SpecColor]
		}

		Lighting On
		SeparateSpecular On
		
		ColorMask RGB

		SetTexture [_MainTex] {
			combine texture * primary DOUBLE, texture
		}
	}
}

// ------------------------------------------------------------------
// Single texture cards - lightmap and texture in two passes; no lighting

SubShader {
	LOD 100
	Tags { "RenderType"="Opaque" }

	// Base pass: lightmap
	Pass {
		Name "BASE"
		Tags {"LightMode" = "Always"}
		BindChannels {
			Bind "Vertex", vertex
			Bind "texcoord1", texcoord0 // lightmap uses 2nd uv
		}
		SetTexture [_LightMap] { constantColor [_Color] combine texture * constant }
	}
	
	// Second pass: modulate with texture
	Pass {
		Name "BASE"
		Tags {"LightMode" = "Always"}
		BindChannels {
			Bind "Vertex", vertex
			Bind "texcoord", texcoord0 // main uses 1st uv
		}
		Blend Zero SrcColor
		Fog { Color (0,0,0,0) }
		SetTexture [_MainTex] { combine texture }
	}
}

Fallback "VertexLit"
}

i’ve tried replacing Tags { “RenderType”=“Opaque” } by Tags { “RenderType”=“Transparent” }, it doesn’t work.