【渲染教程】Pixar RenderMan for Houdini 点云及分层渲染相关练习

1 九月, 2014
317
0

Pixar RenderMan for Houdini 1-1 模型来自:http://www.3drender.com/challenges/index.htm
主要参看了pixar renderman自带帮助文档的Point-Based Approximate Ambient Occlusion and Color Bleeding章节.点云渲染的速度到是快,只是刚开始还真不习惯.Pixar RenderMan for Houdini 点云及分层渲染相关练习..
1.先烘焙点云,将下面的代码保存为文档,修改txt格式为sl格式,然后转成otl在houdini载入.

surface
    bake_areas( uniform string filename = "", displaychannels = "" )
    {
      normal Nn = normalize(N);
      float a = area(P, "dicing"); // micropolygon area
      float opacity = 0.333333 * (Os[0] + Os[1] + Os[2]); // average opacity
a *= opacity; // reduce area if non-opaque

if (a > 0)
bake3d(filename, displaychannels, P, Nn, "interpolate", 1, "_area", a);

Ci = Cs * Os;
Oi = Os;
}

Pixar RenderMan for Houdini 1-2 对比sl代码和houdini里节点界面可以观察到sl文件的格式:
代码里的:surface是shader的类型,
:bake_areas是shader的名称,
:( uniform string filename = “”, displaychannels = “” )括号里的内容将显示在节点上,
:{….}大括号里的内容就是shader的相关参数了。
烘焙好点云数据后可以用软件安装目录里的\Pixar\RenderManProServer-13.5.2\bin\ptviewer.exe查看。
2.使用这类点云数据渲染ambient occlusion,reflection occlusion,environment illumination.
模型下载:http://www-static.cc.gatech.edu/data_files/large_models/happy.ply.gz
Pixar RenderMan for Houdini 1-3 调用点云数据渲染 ambient occlusion所用的shader如下:

#include "normals.h"
surface
pointbasedocclusion (string filename = "";
string hitsides = "front";
float maxdist = 1e15, falloff = 0, falloffmode = 0,
samplebase = 0,
clampocclusion = 0, maxsolidangle = 0.05; )
{
normal Ns = shadingnormal(N);
float occ;

occ = occlusion(P, Ns, 0, "pointbased", 1, "filename", filename,
"hitsides", hitsides,
"maxdist", maxdist, "falloff", falloff,
"falloffmode", falloffmode,
"samplebase", samplebase, "clamp", clampocclusion,
"maxsolidangle", maxsolidangle);

Ci = (1 - occ) * Os;
Oi = Os;
}

转换成otl进houdini.
Pixar RenderMan for Houdini 1-4 调用点云数据渲染reflection occlusion所用的shader如下:

surface
    pointbasedreflectionocclusion (string filename = "";
       string hitsides = "both";
     string distribution = "cosine";
                     float clamp = 1;
                     float maxdist = 1e15, falloff = 0, falloffmode = 0;
                     float coneangle = 0.2;
                     float maxsolidangle = 0.01;
                     float samplebase = 0.0;
                     float bias = 0.0001; )
    {
        normal Nn = normalize(N);
        vector refl = reflect(I, Nn);
        float occ;
occ = occlusion(P, refl, 0, "pointbased", 1, "filename", filename,
"hitsides", hitsides, "distribution", distribution,
"clamp", clamp,
"maxdist", maxdist, "falloff", falloff,
"falloffmode", falloffmode,
"coneangle", coneangle,
"maxsolidangle", maxsolidangle,
"samplebase", samplebase, "bias", bias);

Ci = 1 - occ;
Ci *= Os;
Oi = Os;
}

转换成otl进houdini.
Pixar RenderMan for Houdini 1-5 调用点云数据渲染environment illumination所用的shader如下:

 #include "normals.h"
surface
pointbasedenvcolor (string filename = "";
string hitsides = "both";
float maxdist = 1e15, falloff = 0, falloffmode = 0;
float samplebase = 0, bias = 0;
float clampocclusion = 1;
float maxsolidangle = 0.05;
string envmap = "" )
{
normal Ns = shadingnormal(N);
color envcol = 0;
vector envdir = 0;
float occ;

occ = occlusion(P, Ns, 0, "pointbased", 1, "filename", filename,
"hitsides", hitsides,
"maxdist", maxdist, "falloff", falloff,
"falloffmode", falloffmode,
"samplebase", samplebase, "bias", bias,
"clamp", clampocclusion,
"maxsolidangle", maxsolidangle,
"environmentmap", envmap,
"environmentcolor", envcol,
"environmentdir", envdir
);

Ci = envcol;
Oi = Os;
}

转换成otl进houdini.
Pixar RenderMan for Houdini 1-6 3.渲染color bleeding和glossy reflection效果。
Pixar RenderMan for Houdini 1-7

Pixar RenderMan for Houdini 1-8 烘焙这类点云所需的shader:

 surface
    bake_radiosity(string bakefile = "", displaychannels = "", texfile = "";
                    float Ka = 1, Kd = 1)
    {
      color irrad, tex = 1, diffcolor;
      normal Nn = normalize(N);
      float a = area(P, "dicing"); // micropolygon area
// Compute direct illumination (ambient and diffuse)
irrad = Ka*ambient() + Kd*diffuse(Nn);

// Lookup diffuse texture (if any)
if (texfile != "")
tex = texture(texfile);

diffcolor = Cs * tex;

// Compute Ci and Oi
Ci = irrad * diffcolor * Os;
Oi = Os;

// Store area and Ci in point cloud file
bake3d(bakefile, displaychannels, P, Nn, "interpolate", 1,
"_area", a, "_radiosity", Ci, "Cs", diffcolor);
}

转换成otl进houdini.
Pixar RenderMan for Houdini 1-9 调用点云数据渲染color bleeding所用的shader如下:

#include "normals.h"
surface
pointbasedcolorbleeding (string filename = "", sides = "front";
float clampbleeding = 1, sortbleeding = 1,
maxdist = 1e15, falloff = 0, falloffmode = 0,
samplebase = 0, bias = 0,
maxsolidangle = 0.05;)
{
normal Ns = shadingnormal(N);
color irr = 0;
float occ = 0;

irr = indirectdiffuse(P, Ns, 0, "pointbased", 1, "filename", filename,
"hitsides", sides,
"clamp", clampbleeding,
"sortbleeding", sortbleeding,
"maxdist", maxdist, "falloff", falloff,
"falloffmode", falloffmode,
"samplebase", samplebase, "bias", bias,
"maxsolidangle", maxsolidangle);

Ci = Os * Cs * irr;
Oi = Os;
}

转换成otl进houdini
Pixar RenderMan for Houdini 1-10 调用点云数据渲染glossy reflection所用的shader如下:

surface
    pointbasedglossyreflection (string filename = "", sides = "front";
              float clampbleeding = 1, sortbleeding = 1,
                                maxdist = 1e15, falloff = 0, falloffmode = 0,
                                coneangle = 0.2,
                                samplebase = 0.0, bias = 0.01,
                                maxsolidangle = 0.01;)
    {
      normal Nn = normalize(N);
      vector refl = reflect(I, Nn);
      color irr;
irr = indirectdiffuse(P, refl, 0, "pointbased", 1, "filename", filename,
"hitsides", sides, "clamp", clampbleeding,
"sortbleeding", sortbleeding,
"maxdist", maxdist, "falloff", falloff,
"falloffmode", falloffmode,
"coneangle", coneangle,
"samplebase", samplebase, "bias", bias,
"maxsolidangle", maxsolidangle);

Ci = Os * Cs * irr;
Oi = Os;
}

转换成otl进houdini
Pixar RenderMan for Houdini 1-11 详细内容参看帮助文档了。Pixar RenderMan for Houdini 点云及分层渲染相关练习.
4.练习了一下pixar renderman在houdini里的分层渲染:

Pixar RenderMan for Houdini 1-12