Thursday, October 25, 2012

GoalTo generate cards of random people to give scale to a scene. IntroductionSo I need human sized characters in my scene to give it some scale, there are various ways to do this, but I thought it'd be fun to write a little script that generates card people in various poses, heights etc. Doing a quick search on silhouette on Google Image search turns up this image at Deposit Photos, original link HERE,

Image 1: Various Silhouettes

I did a quick edit of the image to make it a square. Not too concerned with the watermarks.Concept1. Create shader using image 1 as opacity map2. Create a polyplane with a dimension of 1x2 meters3. Map the polyplane UV randomly to a person in image 1Mel Script

Monday, October 8, 2012

In pic 2, we have the shader network. The top blinn is for the wooden base, the bottom material is for the porcelein/ceramic material. It consists of a fast_SSS connected to a mia_material, the color correction is to vary the front SSS color from the back SSS color.Seperating the PassesTo reiterate, the goal is to recreate Pic 1 from passes. Step 1: Create PassesFirst lets go into Render Settings > Passes

Pic 3: Passes Window

Click on the first button on the right. It'll show a window with a list of different available passes. We'll just click on custom color, there are options to enter a prefix if needed. Rename the pass as "Diffuse". Do this another 3 times and name it as, "Refl", "SSS", "Spec". Once created, select all the passes and press the green check button in the middle of the Passes window. This will activate the passes.Step 2: Rebuild the Shader NetworkLets do the wooden base shader first. This is simple blinn shader that consists of diffuse, specularity, and reflectivity. Step 2A: Base Section1. So let us create 3 writeToColorBuffer nodes in the hypershade. It can be found under the hypershade>create>mental ray>miscellaneous. Rename them as diffuse, spec, and refl. The custom color drop down list will contain a list of color passes we created in Step 1. Select the corresponding color passes for each writeToColorBuffer node.2. Let us duplicate the blinn shader as well, since we can't output individual shading components from the blinn shader, we will need to re-create the shading components.

Diffuse: For the original blinn, turn reflectivity to 0 and specular color to black, and rename it diffuse.

Reflection: For reflection, create a mib_reflect under Sample Compositing

Specular: For the duplicated blinn, change diffuse to black and reflectivity to 0 and rename it to spec.

3. Now connect each of the blinn shader output to their corresponding writeToColorBuffer input. If you select all the nodes and graph it now, it'll show the pass nodes in the hypershade as well, as shown in pic 4.

Pic 4

4. If you render now, only the diffuse pass will show up since only the diffuse shader is connected to a shading group. One way for the other writeToBuffer node to evaluate is have the blinn somehow connect to the shadingGroup. But the official method is to use the evaluation passthrough of each writeToBuffer node.

Connect the refl node to the spec node, and the spec node to the diffuse node.

Upgrade the shaders,the vase part, I have a misss_fast_shader for diffuse and SSS, and a mia_material for the reflection. The misss shader is connected to the mia_material through additional colors. However, it would not matter once we use passes. These shaders are much easier to ouput passes since you can upgrade them to their respective X_passes shaders. The connections will be a little messed up but its easy to fix.

Once upgraded, have the misss output front and back SSS results into to color buffers.

Output diffuse result into the diffuse color buffer

Output the reflection result from mia_material into the refl color buffer

Disconnect materials from the shading group

Create a surface shader and connect the last buffer node to the surface shader

pic 7

The final layout.

Step 3: Render

Diffuse

Reflection

Specular

SSS

Combining the Passes

Once combined, you will notice that the combined passes will NOT look like the master beauty pass, this is due to the exposure mental ray adds to the beauty pass that is not added to the buffers.

Comped Image

Master Beauty

To correct for this, we will need to upgrade our workflow to linear workflow.

Color correct ALL texture/color swatch with a gamma correct node set to 0.4545

Comped Image

Master Beauty

The final shader network looks like this,

Final Shader Network

To have both master beauty and final passes rendered out, I connect the last outEvaluation to outMatteOpacity of the surface shader, doesn't effect anything but it will let it evaluate the passes.

Notes I

There are limitations to custom color buffer workflow, some shading components from maya shaders will not output correctly and some might even interfere with other shading components. The safest way to ensure a consistent workflow would be to stick with mental ray shaders and keep it simple, after all, we're pretty much offloading the light tweak stage to the compositing department in this workflow.

Notes II

To improve the workflow it is advisable to standardize/limit the shaders used and also automate the pass and gamma correction process. Mel scripts will be provided.... when i get around to it.