# ColorMaterial:AmbientAndDiffuse equivalent for CG\HLSL

I have this shader written on shaderlab, which replaces Ambient and Diffuse values of the material, because I need to tweak vertices colors from the script.

Shader "VertexSimple"
{
Properties
{
_MainTex ("Base (RGB)", 2D) = "white" {}
}

{
Pass
{
ColorMaterial AmbientAndDiffuse
Lighting Off

SetTexture [_MainTex]
{
Combine texture * primary
}
}
}
Fallback "VertexLit"
}


I need to write an equivalent of this shader on CG\HLSL to do some other routines in it. Ideally it should be vertex\pixel shaders, not surface one. How can I do this?

• I just don't know how to begin because I don't know how to write the ColorMaterial:AmbientAndDiffuse equvalent on CG. – Netherwire Jan 28 '14 at 20:01
• I can help you with HLSL. This is the simplest PixelShader function you can have: float4 PixelShaderFunction(float2 coords: TEXCOORD0) : COLOR0 { return float4(1, 0, 0, 1); } this would output a red colour to any vertices you pass to the pixel shader. However I suggest you google vertex/pixel shader tutorial and either HLSL/CG and you'll get plenty of results. – TheWanderer Jan 28 '14 at 20:13