Skip to content
On this page

Texture blending

The following sections contain examples on how to blend textures using shading networks. It is recommended to read Shading network concepts before proceeding.

Texture blending using InterpolateNode

This script sets up two texture nodes that are blended using the InterpolateNode.

MaxScript
DirectXShader = sgsdk_CreateMaterialMetadata MaterialName

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

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

    BlendColor = sgsdk_CreateShadingColorNode "BlendColor"
    sgsdk_SetDefaultParameter BlendColor 0 0.5 0.5 0.5 1.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"
python
from pymxs import runtime as rt

DirectXShader = rt.sgsdk_CreateMaterialMetadata(MaterialName)

DiffuseTexture1 = rt.sgsdk_CreateShadingTextureNode('DiffuseTexture1')
rt.sgsdk_AddAttributeToNode(DiffuseTexture, 'DiffuseTexture1mapChannel', 3)

DiffuseTexture2 = rt.sgsdk_CreateShadingTextureNode('DiffuseTexture2')
rt.sgsdk_AddAttributeToNode(DiffuseTexture, 'DiffuseTexture2mapChannel', 3)

BlendColor = rt.sgsdk_CreateShadingColorNode('BlendColor')
sgsdk_SetDefaultParameter(BlendColor, 0, 0.5, 0.5, 0.5, 1.0)

InterpolateNode = rt.sgsdk_CreateShadingInterpolateNode('InterpolateNode')
rt.sgsdk_ConnectNodes(InterpolateNode, 0, DiffuseTexture1)
rt.sgsdk_ConnectNodes(InterpolateNode, 1, DiffuseTexture2)
rt.sgsdk_ConnectNodes(InterpolateNode, 2, DefaultBlendColor)

rt.sgsdk_ConnectNodeToChannel(InterpolateNode, DirectXShader, 'Diffuse')
rt.sgsdk_ConnectOutputToDirectXMaterial(effectFile, 'Diffuse', 'DiffuseTexture')