# Vertex-color blending

The following sections contain examples on how to blend colors using vertex-colors. It is recommended to read Shading network concepts before proceeding.

# Vertex-color blending using InterpolateNode

This script sets up three vertex color nodes where the last one is used as blend weight. This example is based on the InterpolateNode.

DirectXShader = sgsdk_CreateMaterialMetadata MaterialName

DiffuseTexture1 = sgsdk_CreateShadingTextureNode "DiffuseTexture1"
sgsdk_AddAttributeToNode DiffuseTexture "DiffuseTexture1mapChannel" 3

DiffuseTexture2 = sgsdk_CreateShadingTextureNode "DiffuseTexture2"
sgsdk_AddAttributeToNode DiffuseTexture "DiffuseTexture2mapChannel" 3

BlendColor = sgsdk_CreateShadingVertexColorNode "BlendColor"
sgsdk_VertexColorNodeSetVertexChannel BlendColor 0

InterpolateNode = sgsdk_CreateShadingInterpolateNode "InterpolateNode"
sgsdk_ConnectNodes InterpolateNode 0 DiffuseTexture1
sgsdk_ConnectNodes InterpolateNode 1 DiffuseTexture2
sgsdk_ConnectNodes InterpolateNode 2 DefaultBlendColor

sgsdk_ConnectNodeToChannel InterpolateNode DirectXShader "Diffuse"
sgsdk_ConnectOutputToDirectXMaterial effectFile "Diffuse" "DiffuseTexture"