May 7, 2009

Painting Your 3d World with a Camera Projection!

  1. To begin painting a world from a camera projection in maya you first need to create the camera.   Make sure the camera you create is either a duplicate of the camera for the shot you are painting or a similar camera that catches all the objects you need to paint.  Make sure the settings on your camera correspond to your render settings and your shot camera.  They need to be identical except for the location.  Lock your projection camera.  Once everything is set, render an image from your projection camera.  You can add any lights and shadows you would want to have for a reference image.  Open the image in photoshop.

  2. Once you are in photoshop with your rendered image there a few things you need to do before you begin painting.  Those are create photoshop groups for each object you are painting in your scene.  For example, say you are painting a kitchen you will probably have modeled a sink, stove, frig, walls and floor.  In photoshop you should have groups for each one of those objects with the name of the group corresponding to the object. Once this is done you can begin painting each object.  Paint them with all the information you want to see in your final scene, that may include lights, shadows, reflections and texture.

  3. This step is the tricky part because we are going to build the shader you are going to use in maya to project your world.  You should begin by creating a surface shader for each projection camera you created.  Name the shader to the camera it corresponds to in order to avoid confusion.  Apply the shader to the objects you want it to paint.  The next step is to create 2 projections nodes in the hypershade.   One is for the color you painted and one is for the alpha if you have any (if you do not have alpha you do not need the 2nd shader).

    Name them projections so you will remember what each one corresponds to you.  Example: The shader you have is called kitchenShader and your projection camera is called Kitchen Projection.  You should name your projection nodes something to the effect of: kitchenColor and kitchenAlpha.  Trust me, keeping the names cohesive is very important.   For both of these files set the projection attributes to prespective and under Camera Projection Attributes link it to your projection camera.

    Next you want to create PSD node for the Photoshop Group that you want to apply to your object in maya.  Once the node is created, go to the file attributes of your PSD node and click the folder icon next to image name to load your photoshop file.  Now set your Link to Layer Set from Composite to whatever layer you want to be applied to the object.

    Now for the very tricky part.  You are going need to create 2 more nodes, a multiply and a reverse.  These are so we can get the alpha channel you created in your photoshop document working on the surface shader.  In your hypershade you should now have, 2 projection nodes, a PSD node, a Multiply/Divide node, a Reverse node and your surface shader node. 

    The first thing to do is to link the outColor of your PSD node to your Color projection node's image input.  After that link your PSD node's outAlpha to your Alpha Projection node's imageR input.  

    Next link your color projection's outColor to input1 of your multiply/divide node.  Then link your alpha projection's outColorR to the input2x, input2y, and input2z of your multiply divide node.

    After this link your multiply divide node's output to your projection shader's outColor.

    Now take your alpha projection node's outColorR and link it to your reverse node's inputX.

    Then take your reverse node's outputX and link it to your projection shader's outTransparencyR, outTransparencyG, and outTransparencyB.

That is all.  Whew.

2 comments:

  1. Good job on the making sure the camera settings and the render settings are the same. FFF what a mistake to make.

    ReplyDelete
  2. Extra notes for the archive:

    The reason we need to treat the alpha and color in a unique way is because Maya's surface shaders do exactly what you tell them to do. That is, if you say "color = white" and "alpha = 0.5" Maya will NOT pre-multiply the color by 0.5 the way you might expect. The output buffer will have the final color be (1, 1, 1, 0.5).

    In fact, it's different from the way a Lambert shader works (where the pre-multiplication actually happens).

    So, the reverse is there to turn alpha (which is opacity) into transparency, and the multiply is there to make sure the color is scaled by the alpha, so that the same hypothetical example I gave above turns into (0.5, 0.5, 0.5, 0.5) in the final render.

    ReplyDelete