博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Master RenderMan Procedural Primitive DSO
阅读量:4624 次
发布时间:2019-06-09

本文共 2071 字,大约阅读时间需要 6 分钟。

RenderMan提供了丰富的程序化生成几何体的方法,包括基于外部程序的RIB生成、基于DSO的直接RI接口调用等。我将通过制作一个直接渲染Karakatoa的PRT粒子文件来演示如何制作类似的插件提高制作效率。本文的DSO在VC8 32bit编译器下编译,在RPS 13.5.2以及Aqsis 1.6.0下得到的结果完全相同。下面是一个起步的DSO用来生成3D Sobol序列并显示出来。
ContractedBlock.gif
ExpandedBlockStart.gif
Code
// PRTRENDER
#ifdef WINDOWS
    
#define PRTRENDER extern "C" __declspec( dllexport )
    
#pragma comment(lib,"prman.lib")
    
#pragma comment(lib,"libgsl.lib")
#else
    
#define PRTRENDER extern "C"
#endif
#include 
<stdlib.h>
#include 
<stdio.h>
#include 
<string.h>
#include 
<math.h>
#include 
<time.h>
#include 
<ri.h>
#include 
<gsl/gsl_qrng.h>
PRTRENDER 
RtPointer ConvertParameters(RtString ParamStr)
{
    
// RtString FilePath = strdup(ParamStr);
    
// fprintf(stdout,"PRTRENDER DSO INFO : Import PRT @ [%s]\n",FilePath);
    
// return (RtPointer)FilePath;
}
PRTRENDER
RtVoid Subdivide(RtPointer Data, RtFloat Detail)
{
    RtInt N 
= 1024;
    RtToken VarP 
= {
"P"};
    RtToken VarCWidth 
= {
"constantwidth"};
    
    gsl_qrng
* QRNG = gsl_qrng_alloc(gsl_qrng_sobol,3);
    
    RtFloat
* P = (RtFloat*)malloc( sizeof(float)*N*3 );
    
    
forint i=0; i<N; ++i )
    {
        
double SingleSobol[3];
        gsl_qrng_get(QRNG,SingleSobol);
        
        
int j = i*3;
        P[j
+0= SingleSobol[0* 2.0 - 1.0;
        P[j
+1= SingleSobol[1* 2.0 - 1.0;
        P[j
+2= SingleSobol[2* 2.0 - 1.0;
    }
    
    RtFloat CWidth 
= 0.01f;
    RtToken DataVar[
2= {VarP,VarCWidth};
    RtPointer DataPointers[
2= {P,&CWidth};
        
    RiPointsV(N,
2,DataVar,DataPointers);
    
    free(P);
    gsl_qrng_free(QRNG);
}
PRTRENDER
RtVoid Free(RtPointer Data)
{
    
// free(Data);
}
这是在Maya中建模的粒子模型,导出为PRT格式的文件,而后使用DSO读取后直接渲染之。
RenderMan supports to generate procedural primitives dynamically, based on both external stdin/stdout execute or DSO. The first is less efficient because the render has to parse the RIB into RI calls again. I will show you how to use this feature to render Karakatoa particles from an PRT file in RenderMan-like render. This DSO has been tested in RPS 13.5 and Aqsis 1.6. Let's begin from an tiny DSO which generate 3D Sobol quasi-random sequence. We made the particles in Maya, exported it as PRT file, and then rendered it by DSO directly.

转载于:https://www.cnblogs.com/Jedimaster/archive/2009/10/12/1582070.html

你可能感兴趣的文章
Sublime Text 3 build 3103 注册码
查看>>
删与改
查看>>
SAP 中如何寻找增强
查看>>
spi驱动无法建立spidev问题
查看>>
ANDROID开发之SQLite详解
查看>>
如何依靠代码提高网络性能
查看>>
Zookeeper要安装在奇数个节点,但是为什么?
查看>>
discuz 微社区安装记录
查看>>
[BZOJ4824][Cqoi2017]老C的键盘 树形dp+组合数
查看>>
配置的热更新
查看>>
MySQL事务的开启与提交,autocommit自动提交功能
查看>>
PriorityQueue
查看>>
CODEVS1403 新三国争霸
查看>>
iOS 环信离线推送
查看>>
WPFTookit Chart 高级进阶
查看>>
雷云Razer Synapse2.0使用测评 -第二次作业
查看>>
django上传文件
查看>>
CVPR2013-papers
查看>>
PHP之时间函数
查看>>
Python open()完整参数
查看>>