Remember earlier how I said I didn't think C4D could do vertex shading? Well, I found a way. But it's not easy. This lesson is for those who know how to use C4D efficiently.
19. Vertex Weight Maps and Vertex Shading
As I have just recently figured out, Cinema 4D a way assigning vertex weights to the points on a model. It can only store values of 0%-100%, but you can have multiple weight maps per model. Weight maps are much like selections, in that they are represented by a Weight Map tag. While this tag is selected, the object it belongs too will display the weight values in the form of color gradients. Red means 0% and Yellow is 100%. The points on the model are also colored, which hinders visibility. Any changes you make to the weights will affect the selected weight map. If the weight map is not selected, any changes will result in a new map. In order to set weights to points, first make your selection. With the points selected, go to Selection -> Set Vertex Weight... from the top menu. A little dialogue box will pop up for you to enter the percentage. It keeps the last value you entered, so things will go faster if you do similar regions at the same time instead of jumping around.
So how does one go about using these weight maps? If you render the scene, the vertex maps won't show at all. This is because they are only information. In order to see them, you have to tie them to a channel in the material. For the texture of the desired channel, choose Effects -> Vertex Map. It will display a white square, which is normal. Hitting render will still display nothing, however, as you need to link it to a vertex map first. Go into the shader properties and you'll have two fields. Simply drag the desired weight map icon to the Vertex Map field. Whether or not you need to check the Invert option is up to you and how you set up your weight map. So the map is linked up and you hit render. What do you see? The The object has now been colored with black and white gradients based on the map! So how can you make use of it and actually have color? The map can only have one value at a time. This requires a bit of ingenuity and clever utilization of C4D's shaders. Because of its simplicity, vertex maps become a powerful tool, because they can be applied to any channel. It is worth noting that the method I've just demonstrated can be used in Alpha channels with no further modification.
[img width= height=]http://img831.imageshack.us/img831/8641/picture1knz.png[/img]
Getting your model from a simple gradient to something like the image above is quite simple once you grasp the concept of it. To start with, let's color that map. With the Vertex Map already in place, set the texture to the Colorizer shader. What the Colorizer does is that it takes in a bitmap or shader and recolors it according a user-specified property. The default input is Luminance, which is just what you want for black-and-white ranges such as this. The shader is also set up to automatically take in any shaders already present and put it as the associated texture, which is quite handy. If you render now, you'll see that it is already now red and yellow instead of just black and white. You can now mess with the colors as you would a regular gradient.
[img width= height=]http://img38.imageshack.us/img38/6702/picture4fi.png[/img]
That's nifty, yes, but what if you want more than just two colors? This is where another shader, the Layer comes into play. Layer is similar to the Fusion object I've mentioned before, but with slightly different behavior and an unlimited number of layers instead of just two and a mask. Like the colorizer, it will take in any present shader as the first layer when selected. The information presented on each layer is pretty self-explanitory, and in fact will seem very familiar to anyone who has used Fireworks/Photoshop. The only one that isn't entirely straightforward is the Layer Mask setting, which causes the layer to mask the layer above it. Just like in Photoshop, you can create a folder to store layers in, which you'll be using in a bit. One of the downsides to the Layer shader is that you can't simply paste layers, so you must first create a dummy layer of any kind and paste over it.
Remember, color on the computer is represented by a trio of values, a range of 0-255 for each red, green, and blue. Adding these various amounts of red, green, and blue is how we get all the other colors, and this is exactly the same principle we'll be using. The idea is to create three different vertex maps: one for red, one for green, and one for blue. What do you set for the values? Black being 0% and white being 100% is obvious, but what about the middle values? This is a good time to mention that C4D can do math. Yes, you can input mathematical statements in for values, and it will automatically calculate them for you. This means it is perfectly fine to enter, say, 100*137/255 as a value, and it will give you the percentage you need. After the three meshes have been set up, it's time to combine them. Inside the Layer shader you have, create additional Colorizers and assign one to each mesh, using a gradient from black to pure red/green/blue, as shown in the above image. Once that is done, set the top two layers from Normal to Add and hit render. If you did it right, the colors will blend together and create new colors! Note that if you accidentally set the bottom layer to Add as well, it will show up black instead.
Selecting the colors to use for this is harder than it sounds. If you're used to working with faces like I am, you'll find yourself wanting to look at the middle of the polygon faces for color. Remember, however, that vertex maps are based on the points of the models and not what is inbetween. Because of this, you'll want to choose from the corners of those faces. If the point on a model is not immediately discernable, look at the color gradients. You'll see trends in the color and direction of the gradients. Look for points where the gradient lines form corners, as this is a good indication of a point. Remember that each vertex can only have one color, so if you see a three-or-four-color gradient, you can probably find the points on the object where the color reaches the highest concentration of the middle color. The higher the polygon count of the model, the harder it will be to reproduce, so this will work well with N64 models.
[img width= height=]http://img708.imageshack.us/img708/4403/picture2yh.png[/img]
What about textures, though? This puts another level of complexity on fixing up the model. Adjusting the example above to accomodate textures is quite easy. Create a folder in the Layer shader, put all three Colorizers in it, and set the blend mode to Multiply. Then, simply add the bitmap you want to affect as the bottom-most layer. You can also work to this point in the other direction, by starting with the bitmap layer in place and adding in the Colorizers second. Either way, you'll end up with something like this:
[img width= height=]https://img230.imageshack.us/img230/5771/picture3vm.png[/img]
Picking the right colors for the weight map is trickier than untextured objects, however. The bitmap is mixed in with the shading and messes with the colors, so using a screenshot is no good. You could try using complex image voodoo to try and figure out the difference in color between the original and displayed images, but there are two easier options. Remember how each material in the ripped scene comes with a color? This is guaranteed to be one of the colors in the vertex map. However, it is only one of them. If anything, this is a good place to start before moving to the other option, which is to just guess. Just use an image editing program and test out what colors multiply out to look like the screenshot. It will be a lot less of a headache than trying to use crazy color math, and will still look good, even if it's not 100% accurate.
And that's all there is to it! I've already put this technique to use in the Gold Leaf Galaxy wallpapers I made, as a way to fade the edges of the rain puddles and the glow on Octoguy's antenna. It's somewhat subtle, but that's what you want. As a way to practice, I recommend getting any random simple scene, ripped or custom, and trying things out. Paper Mario is a good source of things to play with. I look forward to seeing any progress you guys make!