This example demonstrates how to create two texture nodes and blend them together.
It demonstrates how to:
- Blend the textures using a Float node
- Blend the textures by painting your vertices
- Multiply your texture so that it repeats itself and produces a different effect
Example: Create a ShaderFX shader and open the ShaderFX editor:
- In the Perspective viewport, create a Plane object.
- Open the Material Editor and apply a DirectX Shader material to the plane.
If you use the Slate Material Editor, double-click the DirectX Shader node so you can see its parameters.
- On the DirectX Shader rollout, choose ShaderFX from the drop-down list and then click Open ShaderFX.
3ds Max opens the ShaderFX editor.
Example continued: Create two textures and blend them using a Float node:
- Right-click the ShaderFX work area. From the Right-click menu, choose Hw Shader Nodes Textures Texture Map.
ShaderFX adds a TextureMap node to the graph.
- Click the TextureMap node to display its settings in the Properties panel to the right of the work area.
- On the Properties panel, click the browse button beside MyTexture / Path.
In the file dialog that opens, choose a texture file. In this example, a concrete texture is used.
- Repeat steps 1 and 2 for the second texture. In this example, a grass texture is used.
Textures courtesy of www.cgtextures.com.
- Right-click the work area and choose Hw Shader Nodes Math Linear Interpolate Mix to create a LerpOp node to combine the two textures.
- Right-click and choose Hw Shader Nodes Values Float to create a Val node that contains a Float value.
- Connect the Color attribute of the first Texture Map to the first Value attribute of LerpOp.
- Connect the Color attribute of the second Texture Map to the second Value attribute of LerpOp.
- Connect the Float attribute of the Val node to the Mix attribute of LerpOp.
The Float value controls the amount that each texture contributes to the blended result. For example, if set at 0.2, the resulting texture is dominated by the concrete texture. If set at 0.8, the resulting texture is dominated by the grass texture. If set at 0.5, it is an equal mix of the two.
- To see a swatch of the results, click the Render Swatch icon , on top of the Linear Interpolate node, until a large preview appears.
Float set to 0.2
.
The Linear Interpolate Mix preview swatch shows that the concrete texture is dominant.
Float set to 0.5
.
The concrete and grass textures are evenly mixed together.
Float set to 0.8
.
The grass texture is dominant.
- Connect the Result attribute of the LerpOp to the Diffuse Color attribute of the TraditionalGameSurfaceShader node.
Now you can visualize your shader in Realistic or Shaded viewports.
Example continued: Blend the textures using a Vertex Color node:
- Right-click and choose Hw Shader Nodes Inputs Common Vertex Color.
Instead of using the Float node, you will use the vertex color to blend the textures.
- Click to highlight the wire that connects the Float node from Linear Interpolate, then press Delete.
- Connect the Red attribute of VertexColor to the Mix attribute of LerpOp. This way, you use the Red channel to blend your textures.
- In a viewport, make sure the Plane object is selected. On the Modify panel, increase the value of Length Segs and Width Segs to 20. This adds more vertices to your plane to increase definition for vertex painting.
- Also on the Modify panel, apply a VertexPaint modifier to the Plane.
3ds Max opens the VertexPaint Paintbox.
Now you will paint some of your vertices red. The vertices that are painted red will display your grass texture.
- On the Paintbox, click to activate (Disable vertex color display).
- The default color swatch should show black. (If it isn't black, click it and use the Color Selector to change it to black.) Click (Paint All) to make the Plane black.
With vertices assigned the black channel, the plane shows the concrete texture.
- Click the color swatch and change the color to a bright red.
- Click (Paint) and paint on your plane. The vertices that you paint as red take on the grass texture values. You have now blended your textures by painting your vertices.
Example continued: Multiply your texture to repeat it in a tile pattern to create a different, more dense effect:
- On the modifier stack, click to highlight the VertexPaint modifier and then click (Remove Modifier From The Stack).
- In the ShaderFX editor, disconnect the VertexColor node by clicking its wire and pressing Delete, then reconnect the Val node's Float value to the Mix attribute of LerpOp.
- Click to highlight the VertexColor node and press Delete.
- Right-click and choose Hw Shader Nodes Inputs Common UV Set to create a UV Set node.
- Right-click and Hw Shader Nodes Math Multiply to create a MulOp node.
- Right-click and choose Hw Shader Nodes Values Float to create another Val node.
- Connect the UV attribute of the UV Set node to the first Value attribute of MulOp.
- Connect the Float attribute of the new Val node to the second Value attribute of MulOp.
- Connect the Result attribute of the MulOp node to the UV attribute of the TextureMap whose pattern you would like to tile.
- Click to select the new Val node, and on the Properties panel, change its Float value. Set Float to a higher value so that the pattern repeats more often and is more dense, and a lower value so that the pattern does not repeat as often. You can preview the resulting pattern by clicking the Render Swatch icon of the TextureMap node.
Value=0.5
Value=2.0