VertexColorUnlit

From Unify Community Wiki
Jump to: navigation, search

Author: Eric Haines (Eric5h5)

Contents

Description

Two shaders that use per-vertex colors and no lighting. Works fine using Unity as well as Unity iPhone; both shaders will run on really ancient cards, though the second one won't use vertex colors in that case.

Usage

Both shaders allow for overbrightening, so using (.5, .5, .5) as vertex color values results in 100% brightness, and values above that brighten the texture accordingly, as shown by the VertexColorUnlit shader:

Vertexcolor1.jpg

The VertexColorUnlit2 shader has a color variable, so that as the vertex color alpha goes below 1.0, the vertices become more influenced by the color rather than the texture:

Vertexcolor2.jpg

The color can be something other than white, and vertices will be tinted thusly. Vertices with an alpha of 0 are always 100% color and 0% texture:

Vertexcolor5.jpg

ShaderLab - VertexColorUnlit.shader

Shader "Vertex color unlit" {
Properties {
	_MainTex ("Texture", 2D) = "white" {}
}
 
Category {
	Tags { "Queue"="Geometry" }
	Lighting Off
	BindChannels {
		Bind "Color", color
		Bind "Vertex", vertex
		Bind "TexCoord", texcoord
	}
 
	SubShader {
		Pass {
			SetTexture [_MainTex] {
				Combine texture * primary DOUBLE
			}
		}
	}
}
}

ShaderLab - VertexColorUnlit2.shader

Shader "Vertex color unlit2" {
Properties {
	_Color ("Color", Color) = (1,1,1,1)
	_MainTex ("Texture", 2D) = "white" {}
}
 
Category {
	Tags { "Queue"="Geometry" }
	Lighting Off
	BindChannels {
		Bind "Color", color
		Bind "Vertex", vertex
		Bind "TexCoord", texcoord
	}
 
	// ---- Dual texture cards
	SubShader {
		Pass {
			SetTexture [_MainTex] {
				combine texture * primary
			}
			SetTexture [_MainTex] {
				constantColor [_Color]
				combine previous lerp (previous) constant DOUBLE
			}
		}
	}
 
	// ---- Single texture cards (does not do vertex colors)
	SubShader {
		Pass {
			SetTexture [_MainTex] {
				constantColor [_Color]
				combine texture lerp(texture) constant DOUBLE
			}
		}
	}
}
}
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Tools