Signed add brightness shader

I was talking to Kaelis in the IRC channel, who explained an interesting idea for a shader. I’m not really sure what it’s for, but it’s basically a simple diffuse vertex lit shader that uses a second texture to either brighten or darken the results of the lighting equation. By default, the brightness map is 50% grey and doesn’t do anything.

It’s kind of a strange shader and I can’t think what I’d use it for, but here goes:

Shader "Brightness Map" {
	Properties {
		_Color ("Main Color", Color) = (1,1,1,1)
		_MainTex ("Base (RGB)", 2D) = "white" {}
		_BrightTex ("Brightness (RGB)", 2D) = "gray" {}
	}
	SubShader {
		Pass {
			Material {
				Diffuse [_Color]
				Ambient [_Color]
			}
			Lighting On
			SetTexture [_MainTex] {
				Combine texture * primary DOUBLE, texture * primary
			}
			//signed add brightness texture to lighting result
			SetTexture [_BrightTex] {
				Combine previous +- texture
			}
		}
	}
	FallBack "Diffuse"
}

Thank you! :slight_smile:

The purpose i have in mind is using both lightmaps and unity lights. Or, if you will, lightmap + shadowmap in one texture.

Oh… that is similar to the composite mode “Overlay” of the layers in Photoshop, mainly used for increases the color contrast of image, really useful :slight_smile:

Hm, on a second thought, may i ask for addition of specular highlights to this shader? I have just realized that i failed to mention this back when i requested it, silly me.

You can probably do this yourself by looking at the built-in VertexLit shader and comparing it with the one above. You need to specify Specular colour and exponent in the material block, which means you need to add a corresponding colour and floating point property to the properties block.