Understanding how the Render Tree’s Mix2colors node works
Author: David, created in: 05 March 2001, last updated in March 2010.
Note: this article is for the defunct Softimage XSI.
Subject:
Sometimes, while using a software, we might perform some usual tasks, because we know they will give us the expected result, although we do not always understand how they work.
After using the “mix2colors” render tree shader for a long period of time, I asked myself some questions, and I got the answers from the french speaking Softimage forum. Thanx to Softguy for his explanations.
Goal:
This tutorial shows how to superpose 2 images while keeping them opaque.
A very easy task with Xsi. But the true aim of this page is to explain how does the mix2colors works.
To run this tut, we’ll use that London image (see image 01),
and this photo of Vega the Strong (see image 02).
The result we want to get is the superposition of the two pictures as a texture on an object. The two pictures have to stay opaque (in Photoshop, it would be two layers with 100% opacity each). Take a look at the image number 03 :
Modeling and texturing:
1) Start by a grid (model > get…).
2) On this grid, we will put two “texture projection” : one big (grande) and one smaller (petite).
To do so, select the grid, then go to render > get > property > texture projection > create new projection.
3) Start by the big projection, and enter the following values, as in the image 04.
4) Click ok, then do the same stages for “tp_xz_petite” and “ts_xz_petite”.
5) We’ll now decrease the size of the “ts_xz_petite” texture support : Go to the top view, press the space bar of your keyboard, to switch to selection mode, then select the texture support.
6) Press “X” on the keyboard, then keep the shift key down, while dragging the mouse, to bring down the size of the object, in every directions (see image 05).
Now the two texture supports are at the expected size (see image 06).
7) Putting up the textures : Start by copying the two pictures of the top of this web page in your database, sub folder “pictures”.
8) Go in render > get > clip > create clip from file, and find the 2 images.
9) Select the grid. No material was applied on it yet (except the default scene material), do render > get > material > phong. Close the property page.
Render Tree:
10) We’ll now open the render tree, my fave way to apply textures.
11) Clic the “update” button in the render tree. We can see the freshly applied material, now let’s add textures.
12) Add every useful nodes :
nodes > mixers > mix2 colors
nodes > texture > image (twice)
clips > image01.jpg
clips > image02.jpg
13) Connect the nodes in order to build the render tree below :
Our render tree uses the mix2colors, to superpose the two images.
At the back : a picture of London, it’s the base_color,
On front, Vega the Strong himself, it is color1
The original files DO NOT have any alpha layer (see image 07).
14) in each image node, select the right texture projections.
Mix2colors basics:
15) If you double clic on the shader mix2colors from the render tree, and if you draw a render region (keyboard’s “Q”) you can see the default settings of the mix2colors, and its effects on the object (see image 08).
On the render region above, we can see that each of the the two pictures have an opacity of 50% : weight is set at 0.5. As a result, they are mixed together.
How should we do if we want each image to have an opacity of 100%, and one of the picture to partly hide the other one?
In the following stage, let’s experiment…
Here are the settings which will allow us to get the expected result (see image 09) :
16) Put the “weight” of the mixing at 1 : this will make the foreground image (Vega) opaque.
17) Check the box “multiply weight by alpha” : this will reveal the background image (base_color). When this box is unchecked, the background image stays black.
Hence one question :
Why do I have to take into acount the alpha to reveal the background image, although none of the image has an alpha layer?
Well, first, you have to know that it is not really 2 pictures we are speaking about. It is more the result of a calculation. For each pixel, the calculation takes the two textures into account. Thus, it is a “texel” calculation. The Mix2colors isn’t a mini compositing software, and does not really work as such.
Then, it is certain that simply adding up two RGB images won’t create a result where the two pictures will be fully visible in places, if you do not have recourse to alpha.
So how did it worked?
Xsi will put kind of an implicit alpha layer on the picture of vega the Strong. Everything that is inside the boundaries of this picture will be considered as the white part of the alpha, meaning that in this area, alpha = 1. Everything outside those boundaries is the black part of the alpha : alpha = 0 (see image 10).
The mix2colors render tree shader mixes 2 colors, originating from two pictures, for each pixels.
The basic color is in base_color layer, the added color is in color1, and the mixing is in the “mix layer”.
When we switch on “multiply weight by alpha”, Xsi will take into account the alpha factor, in order to reveal or hide the result of the mixing (“mix layer”).
Inside the limits of the Vega picture, alpha = 1, the mixing will be visible (mix layer has an opacity of 100%). What’s happening in this mixing? Color1’s weight is at 1, meaning that only Vega is visible.
Outside the limits of the Vega image, alpha = 0, the mixing is not visible, and as a result, only the background color is visible : London.
For computer graphic software engineers, these things are evidences, but for us… This explanation should be useful.
Texture Layers:
Update: March 2010: since several Softimage versions, I find myself using more and more the texture layers, and less and less the “mixXcolors” nodes. Both methods co-exist in Softimage now. Texture layers allow you to mix everything together, not only textures, but also materials. The blending of layers works exactly as in Photoshop, and in my opinion, the texture Layers workflow is more straight forward than the mixXcolors workflow.
Comments? Suggestions? Errors? write me.
David