Master renderman procedural primitive DSO

Source: Internet
Author: User
Renderman provides a wide range Program Methods for generating ry, including rib Generation Based on external programs and direct interface call based on dso. I will create a PRT particle file that directly renders karakatoa to demonstrate how to make a similar plug-in to improve production efficiency. The DSO in this article is compiled under the vc8 32bit compiler, and the results obtained under RPS 13.5.2 and aqsis 1.6.0 are identical. The following is a starting DSO used to generate a 3D Sobol sequence and display it.

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 );

For ( Int 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 );
}

This is the particle model created in Maya, exported as a PRT file, and then directly rendered after reading it using 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 callagain. I will show you how to use this feature to render karakatoa participant 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 participant in Maya, exported it as PRT file, and then rendered it by DSO directly.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.