Renderman + Masks

New video up on generating masks (mattes) in Renderman for Maya.

Here’s a quick script to connect up a single PxrMatteID node to many PxrMaterial nodes.

import pymel.core as pym
mynodes = pym.ls (sl=True, fl=True, dag=False, ni=True)

mybxdfs = []
myhairs = []
mymatteid = []

for x in mynodes:
    if isinstance(x , (pym.nodetypes.PxrSurface, pym.nodetypes.PxrLayerSurface)):
        mybxdfs.append(x)
    if isinstance(x , ( pym.nodetypes.PxrMarschnerHair)):
        myhairs.append(x)
    if isinstance(x , (pym.nodetypes.PxrMatteID)):
        mymatteid.append(x)

if len(mymatteid) == 1:
    for b in mybxdfs:
        mymatteid[0].resultAOV.connect(b.utilityPattern[0], force=True)
    for h in myhairs:
        mymatteid[0].resultAOV.connect(h.inputAOV, force=True)        
elif len(mymatteid) != 1:
    print 'too many PxrMatteID nodes selected, just try one'

Enjoy

Renderman – Batch Render tips

In the Batch Render options. Two useful settings.

  1. Checkpoint Interval. First number is how often to save the file when rendering. Second is when to finish rendering. Here I’ve set it to save a copy every 30 minutes and don’t render any longer than 24 hours.
  2. Renderer Arguments. This additional argument prints out the current memory and percentage of render complete. Handy to know where you are.

 

 

 

Renderman Commandline

A video about setting up and using Renderman on the commandline.

The rib example for the OSL section below comes from a question by rheiland on the Pixar forum https://renderman.pixar.com/forum/showthread.php?s=&threadid=35595 Thank you, it’s a really simple and helpful example.

Copy and paste the first bit of code into a file called balls.rib

Display "foo" "it" "rgba"
Format 400 400 1
Projection "perspective" "fov" 25

Translate 0.0 0.0 2.75
Rotate -120 1 0 0

WorldBegin
Sphere 100 -100 100 360
AttributeBegin

# this will use Pixar provided patterns
 Pattern "PxrPrimvar" "MyPxrPrimvar" "string varname" ["Cs"] "string type" ["color"] "string coordsys" [""]
 Bxdf "PxrDisney" "bxdf" "reference color baseColor" ["MyPxrPrimvar:resultRGB"]

# uncomment the next two lines to use a custom OSL pattern
 #Pattern "Primvar" "CustomPrimvar" "string PrimvarName" ["Cs"]
 #Bxdf "PxrDisney" "bxdf" "reference color baseColor" ["CustomPrimvar:OutColour"]

# This creates 4 fours, each of different sizes and colours.
 Points "P" [-0.5 0 0.0 -0.3 0 0 0.3 0 0 0.5 0 0 ]
 "width" [0.10 0.12 0.14 0.16]
 "varying color Cs" [1 0 0 0 1 0 0 0 1 1 1 0]

AttributeEnd
WorldEnd

Switch to commandline and use this following command.

prman -d it -t:-2 balls.rib

You should get the following image.

To use the OSL. Copy/paste the following text into a file called Primvar.osl

shader Primvar[[
 int rfm_nodeid = 110,
 string rfm_classification = "rendernode/RenderMan/pattern",
 string help = "Primvar"
]]
(
 string PrimvarName = "",
 output color OutColour = 0,
 output float OutFloat = 0
)
{
 color Cs;
 getattribute("primvar", PrimvarName, Cs);
 OutColour = Cs;
 OutFloat = Cs[0];
}

Then compile it from the commandline using the the following command..

oslc Primvar.osl

Copy the resulting Primvar.oso file into the same directory as your rib file, adjust the comments in there are try again. You should get the same image, you’ve just done it using your own OSL code which you can modify to do other things.

 

Playing around with PxrSeExpr

This got started from a question on the Renderman forums about the difference between ST and UV. Renderman uses UV and ST to differiate between “implicit” and “explicit” texture coordinates. Implicit is automatically defined by the geometric shape and explicit is manually defined by the user.

With polygons and subdivision geometry, Renderman uses ST coordinates for texture mapping (it converts Maya UVs to Renderman STs behind the scenes). But it also automatically assigns UV coordinates to each face on the geometry, you might ask why would you need this?

For fun and profit!

 

Heat Map

Useful if you ever want to better visualize data images.

Basic idea is to put the data in the red channel, normalize it between zero and one, then make sure the green and blue channel are both set to one and convert the colourspace from HSV to Linear.

Blackpoint and Whitepoint are set to the minimum and maximum samples from the render. Gain is set to 0.666667 so that the range is mapped from Red to Blue, rather than Red through to Red.

Renderman Denoising

A few little tips and tricks for Denoising stuff in Renderman…

Most of this comes from here… https://renderman.pixar.com/resources/current/RenderMan/risDenoise.html, you’ll need to make sure your environment variables are set correct to do this in the shell.

Note: This is using Windows, a lot of it is similar to Linux/Mac, there might be some syntax differences.

For all examples, we have a directory which contains the following image sequences…

RIS_denoised_variance.####.exr (the main render pass)
RIS_denoised_variance_directdiffuse1.####.exr (key light diffuse)
RIS_denoised_variance_directdiffuse2.####.exr (environment light diffuse)
RIS_denoised_variance_directspecular1.####.exr (key light specular)
RIS_denoised_variance_directspecular2.####.exr (environment light specular)

To denoise several frames (0001-0007) of the beauty render using single-frame denoising. Include the { } brackets around the frame numbers, wildcards * don’t seem to work for me in Windows.

denoise RIS_denoised_variance.{0001,0002,0003,0004,0005,0006,0007}.exr

To denoise the same seven frames (0001-0003) using cross-frame denoising.

denoise --crossframe -v variance RIS_denoised_variance.{0001,0002,0003,0004,0005,0006,0007}.exr

To denoise the AOVs as well, only on three frames this time…

denoise --override filterLayersIndependently true -- RIS_denoised_variance.{0001,0002,0003}.exr RIS_denoised_variance_directdiffuse1.{0001,0002,0003}.exr RIS_denoised_variance_directdiffuse2.{0001,0002,0003}.exr RIS_denoised_variance_directspecular1.{0001,0002,0003}.exr RIS_denoised_variance_directspecular2.{0001,0002,0003}.exr