VertexColorUnlit

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
(ShaderLab - VertexColorUnlit.shader)
(ShaderLab - VertexColorUnlit2.shader)
 
Line 45: Line 45:
  
 
==ShaderLab - VertexColorUnlit2.shader==
 
==ShaderLab - VertexColorUnlit2.shader==
<syntaxhighlight lang="shaderlab">Shader "Vertex color unlit2" {
+
<syntaxhighlight lang="cpp">Shader "Vertex color unlit2" {
 
Properties {
 
Properties {
 
_Color ("Color", Color) = (1,1,1,1)
 
_Color ("Color", Color) = (1,1,1,1)

Latest revision as of 09:51, 24 April 2016

Author: Eric Haines (Eric5h5)

Contents

[edit] 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.

[edit] 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

[edit] 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
			}
		}
	}
}
}

[edit] 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
Toolbox