For any one interested I coded such a shader…
I added one extra combine to use the color as the ambient light from the render settings. So if you don’t need it delete it.
These are the lines:
SetTexture [_MainTex] {
constantColor [_Color]
combine previous*constant DOUBLE
}
you have to feed the ambient light through code though.
And while it works very good on desktop it is very slow on some mobile devices.
//change the _Color to use the Ambient light !!!!
Shader "VertexLit_Lightmap" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
//_Specular ("Specular", Color) = (1,1,1,1)
//_Shininess ("Shininess", Color) = (1,1,1,1)
//_Emission ("Emission", Color) = (1,1,1,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
}
// 2/3 texture stage GPUs
SubShader {
Tags { "RenderType"="Opaque" }
LOD 100
// Non-lightmapped
Pass {
Tags { "LightMode" = "Vertex" }
Material {
Diffuse [_Color]
//Specular [_Specular]
//Shininess [_Shininess]
//Emission [_Color]
}
Lighting On
//SeparateSpecular On
SetTexture [_MainTex] {
Combine texture * primary DOUBLE, texture * primary
}
}
// Lightmapped, encoded as dLDR
Pass {
Tags { "LightMode" = "VertexLM" }
Lighting On
BindChannels {
Bind "Vertex", vertex
Bind "normal", normal
Bind "texcoord1", texcoord0 // lightmap uses 2nd uv
Bind "texcoord", texcoord1 // main uses 1st uv
}
Material {
Diffuse [_Color]
//Specular [_Specular]
//Shininess [_Shininess]
//Emission [_Color]
}
SetTexture [unity_Lightmap] {
matrix [unity_LightmapMatrix]
constantColor (1,1,1,1)
combine texture * constant
}
SetTexture [unity_Lightmap] {
combine previous + primary
}
SetTexture [_MainTex] {
combine texture * previous, texture * primary
}
SetTexture [_MainTex] {
constantColor [_Color]
combine previous*constant DOUBLE
}
SetTexture [_MainTex] {
combine previous+primary
}
}
// Lightmapped, encoded as RGBM
Pass {
Tags { "LightMode" = "VertexLMRGBM" }
Lighting On
//Blend SrcColor SrcColor
BindChannels {
Bind "Vertex", vertex
Bind "normal", normal
Bind "texcoord1", texcoord0 // lightmap uses 2nd uv
Bind "texcoord", texcoord1 // main uses 1st uv
}
Material {
Diffuse [_Color]
//Specular [_Specular]
//Shininess [_Shininess]
//Emission [_Emission]
}
SetTexture [unity_Lightmap] {
matrix [unity_LightmapMatrix]
combine texture * texture alpha DOUBLE
}
SetTexture [unity_Lightmap] {
combine previous + primary
}
SetTexture [_MainTex] {
combine texture * previous
}
SetTexture [_MainTex] {
constantColor [_Color]
combine previous*constant QUAD
}
SetTexture [_MainTex] {
constantColor [_Color]
combine previous+primary
}
}
}
}