【Houdini教程】Pixar RenderMan for Houdini(GI、Caustics、SSS)相关渲染练习.

13 九月, 2014
303
0

Pixar RenderMan for Houdini GI,Caustics,SSS相关渲染练习.
Pixar RenderMan for Houdini global illumination,Caustics,Subsurface
scattering相关渲染练习.

————————————————————————————————–

                                 
Global illumination

1.Generating the global photon map 
生成全局光子图

2.Precomputing radiosities
使用ptfilter工具处理光子图,使用brickmake工具将ptc点云转换成brick
map.达到光能传递的效果.

通用格式:ptfilter -photonmap -nphotons 100 E:/cornell.gpm
E:/cornell_rad.ptc

Pixar RenderMan for Houdini GI,Caustics,SSS相关渲染练习.

通用格式:brickmake E:/cornell_rad.ptc
E:/cornell_rad.bkm

Pixar RenderMan for Houdini GI,Caustics,SSS相关渲染练习.
3.Rendering global
illumination  渲染全局光.多次反弹.

Pixar RenderMan for Houdini GI,Caustics,SSS相关渲染练习.
基本代码如下:

surface matte_finalgather(uniform string
filename = “”;
                            
float Kd = 1, samples = 64, maxvariation = 0.02)
   {
    
color irrad = 0, radio = 0;
    
normal Nn = normalize(N);
    
uniform float maxddepth, ddepth;

    
attribute(“trace:maxdiffusedepth”, maxddepth);
    
rayinfo(“diffusedepth”, ddepth);

    
if (ddepth == maxddepth) { // brick map lookup
      
// Lookup in 3D radiosity texture
      
texture3d(filename, P, Nn, “_radiosity”, radio);
      
Ci = radio;
      
Oi = 1;
    
} else { // shoot final gather rays
      
irrad = diffuse(Nn)
            
+ indirectdiffuse(P, Nn, samples, “samplebase”, 0.1,
                              
“maxvariation”, maxvariation);
      
Ci = Kd * Cs * irrad;
      
Ci *= Os; // premultiply opacity
      
Oi = Os;
    
}
   }
转换成otl进houdini:

Pixar RenderMan for Houdini GI,Caustics,SSS相关渲染练习.

————————————————————————————————-

                                           caustics

pixar renderman渲染焦散速度还是满快的.估计用的地方不多.Pixar RenderMan for Houdini GI,Caustics,SSS相关渲染练习.

Pixar RenderMan for Houdini GI,Caustics,SSS相关渲染练习.

light causticlight(
    
color filter = color(1);
    
output float __nonspecular = 1;)
   {
    
normal Ns = shadingnormal(N);

    

    
illuminate (Ps + Ns) { 
Cl = filter * caustic(Ps, Ns);
    
}
   }
Pixar RenderMan for Houdini GI,Caustics,SSS相关渲染练习.

 

————————————————————————————————–

                                     
Subsurface
scattering

1.Baking direct illumination  烘焙直接照明
,生成点云文件

surface
  
bake_radiance_t(string filename = “”, displaychannels = “”; color
Kdt = 1)
   {
      
color irrad, rad_t;
      
normal Nn = normalize(N);
      
float a = area(P, “dicing”); // micropolygon area

      

      
irrad = ambient() + diffuse(Nn);

      

      
rad_t = Kdt * irrad;

      

      
bake3d(filename, displaychannels, P, Nn, “interpolate”, 1,
             
“_area”, a, “_radiance_t”, rad_t);

      
Ci = rad_t * Cs * Os;
      
Oi = Os;
   }
Pixar RenderMan for Houdini GI,Caustics,SSS相关渲染练习.
Pixar RenderMan for Houdini GI,Caustics,SSS相关渲染练习.

2.Diffusion simulation using ptfilter
使用ptfilter工具处理点云数据.

通用格式三种,可选其一

I:ptfilter -ssdiffusion -material marble E:/direct_rad_t.ptc
E:/ssdiffusion.ptc

II:ptfilter -ssdiffusion -scattering 2.19 2.62 3.00
-absorption 0.0021 0.0041 0.0071 -ior 1.5 E:/direct_rad_t.ptc
E:/ssdiffusion.ptc

III:ptfilter -ssdiffusion -albedo 0.830 0.791 0.753
-diffusemeanfreepath 8.51 5.57 3.95 -ior 1.5 E:/direct_rad_t.ptc
E:/ssdiffusion.ptc
Pixar RenderMan for Houdini GI,Caustics,SSS相关渲染练习.

3.Creating a brick map
将ptc格式转换成bkm

通用格式:brickmake -maxerror 0.002 E:/ssdiffusion.ptc
E:/ssdiffusion.bkm
Pixar RenderMan for Houdini GI,Caustics,SSS相关渲染练习.

4.Rendering subsurface
scattering

surface
  
read_ssdiffusion(uniform string filename = “”; float Ka = 1, Kd =
1)
   {
      
normal Nn = normalize(N);
      
color direct = 0, ssdiffusion = 0;

      

      
direct = Ka*ambient() + Kd*diffuse(Nn);

      

      
texture3d(filename, P, N, “_ssdiffusion”, ssdiffusion);

      

      
Ci = (direct + ssdiffusion) * Cs * Os;
      
Oi = Os;
   }
Pixar RenderMan for Houdini GI,Caustics,SSS相关渲染练习.
Pixar RenderMan for Houdini GI,Caustics,SSS相关渲染练习.
Pixar RenderMan for Houdini GI,Caustics,SSS相关渲染练习.天使模型:http://www-static.cc.gatech.edu/data_files/large_models/angel/angel.obj.gz

葡萄模型:http://www.3d66.com/model-liuliuid-10636.html

暂时先这样.Pixar RenderMan for Houdini GI,Caustics,SSS相关渲染练习.