RenderMan export

Developers
2008-08-11
2013-05-28
  • Moritz Moeller

    Moritz Moeller - 2008-08-11

    Hello structure synthesizers,

    I just stumbled upon this nice toy. Funny enough I had been contemplating with writing a 3D version of Context Free a while back myself. Anyway, that task's off the list now. :-P
    Thanks heaps for this cool tool! :)

    I hacked a little RenderMan (RMan) export script. Needs polishing certainly. Supports all primtives that currently work.

    I have some suggestions:
    * Currently the origin of box & grid primitives is one corner of the primitive. I'd make that the center.
    * Spheres get defined by a translation and the radius. Given the fact that you could texture them (so orientation starts to matter) and the prospect of elliposoid support in a future version, how about making that a 4x4 matrix transforming a origin-centered unit-sphere instead?

    There are also other problems with the width of points and lines vs that of grids.

    Script is attached. Feek free to add it to the trunk or make me a dev and I check it into SVN myself. :)

    Beers,

    --Moritz

     
    • Moritz Moeller

      Moritz Moeller - 2008-08-11

      <template name="RenderMan Template" inherits="">

          <substitution name="begin">

              <![CDATA[

      ##RenderMan RIB-Structure 1.1

      ##Creator StructureSynth 0.85

      version 3.03

      # Define instances for primitives

      # What StructureSynth calls a "grid" -- a very confusing name

      ObjectBegin "unitsquare"

          Curves "linear" [ 4 ] "periodic" "P" [ .5 .5 0  .5 -.5 0  -.5 -.5 0  -.5 .5 0 ] "constantwidth" [ .01 ]

      ObjectEnd

      ObjectBegin "unitline"

          Curves "linear" [ 2 ] "nonperiodic" "P" [  .5 .5 -.5  .5 .5 .5 ] "constantwidth" [ .01 ]

      ObjectEnd

      ObjectBegin "box"

          TransformBegin

              Translate 0.5 0.5 0.5

              TransformBegin

                  Translate 0 0 -.5

                  ObjectInstance "unitsquare"

                  Translate 0 0 1

                  ObjectInstance "unitsquare"

              TransformEnd

              TransformBegin

                  ObjectInstance "unitline"

                  Rotate 90 0 0 1

                  ObjectInstance "unitline"

                  Rotate 90 0 0 1

                  ObjectInstance "unitline"

                  Rotate 90 0 0 1

                  ObjectInstance "unitline"

              TransformEnd

          TransformEnd

      ObjectEnd

      # What StructureSynth calls a "box"

      ObjectBegin "filledunitsquare"

          Patch "bilinear" "P" [ .5 .5 .5  .5 -.5 .5  -.5 .5 .5  -.5 -.5 .5 ]

      ObjectEnd

      ObjectBegin "solidbox"

          TransformBegin

              Translate 0.5 0.5 0.5

              TransformBegin

                  ObjectInstance "filledunitsquare"

                  Rotate 90 0 1 0

                  ObjectInstance "filledunitsquare"

                  Rotate 90 0 1 0

                  ObjectInstance "filledunitsquare"

                  Rotate 90 0 1 0

                  ObjectInstance "filledunitsquare"

                  Rotate 90 0 1 0

              TransformEnd

              TransformBegin

                  Rotate 90 1 0 0

                  ObjectInstance "filledunitsquare"

              TransformEnd

              TransformBegin

                  Rotate -90 1 0 0

                  ObjectInstance "filledunitsquare"

              TransformEnd

          TransformEnd

      ObjectEnd

      # Global settings

      Option "render" "bucketorder" [ "spiral" ]

      PixelSamples 8 8

      PixelFilter "catmull-rom" 4 4

      ShadingRate 0.75

      # Camera

      Projection "perspective" "fov" [ 60 ]

      # Here goes the camera transform (once StructureSynth can export it)

      Translate 0 0 15

      # Flip handedness

      ConcatTransform [ 1 0 0 0 0 1 0 0 0 0 -1 0 0 0 0 1 ]

      WorldBegin

          # Ensure outwards-pointing normals

          ReverseOrientation

              ]]>

          </substitution>

         

          <substitution name="end">

              <![CDATA[

      WorldEnd

              ]]>

          </substitution>

          <substitution name="dot">

              <![CDATA[

          AttributeBegin

              Color {r} {g} {b}

              Opacity {alpha} {alpha} {alpha}

              Points "P" [ {x} {y} {z} ] "width" [ .01 ]

          AttributeEnd

              ]]>

          </substitution>

          <substitution name="line">

              <![CDATA[

          AttributeBegin

              Color {r} {g} {b}

              Opacity {alpha} {alpha} {alpha}

              Curves "linear" [ 2 ] "nonperiodic" "P" [ {x1} {y1} {z1}  {x2} {y2} {z2} ] "constantwidth" [ .01 ]

          AttributeEnd

              ]]>

          </substitution>

             

          <substitution name="grid">

              <![CDATA[

          AttributeBegin

              Color {r} {g} {b}

              Opacity {alpha} {alpha} {alpha}

              Transform [ {matrix} ]

              ObjectInstance "box"

          AttributeEnd

              ]]>

          </substitution>

          <substitution name="box">

              <![CDATA[

          AttributeBegin

              Color {r} {g} {b}

              Opacity {alpha} {alpha} {alpha}

              Transform [ {matrix} ]

              ObjectInstance "solidbox"

          AttributeEnd

              ]]>

          </substitution>

                 

          <substitution name="sphere">

              <![CDATA[

          AttributeBegin

              Color {r} {g} {b}

              Opacity {alpha} {alpha} {alpha}

              Translate {cx} {cy} {cz}

              Sphere {rad} -{rad} {rad} 360

          AttributeEnd

              ]]>

          </substitution>

      </template>

       
    • Mikael Hvidtfeldt Christensen

      Hi Moritz,

      Looks very interesting - I've never used anything RenderMan based myself, though.

      The forum messed up the indentation and carrige returns of your template file, but please add it to the SVN repository (I've added you as a dev) or mail it to me (mikael - at - hvidtfeldts.net).

      You are absolutely right with regard to the spheres - at some point it becomes necessary to supply a transformation matrix of a unit-sphere. As of now the OpenGL renderer in Structure Synth is not able to draw ellipsoids either, though (it does not respect the non-uniform scaling operator). Wrt to the origin of box and grids, yes, it might have been more natural to make supply a transformation matrix for a cube centered at origo, instead of one going from (0,0,0) to (1,1,1). I will consider this.

      If you make some example pics with the RenderMan template, please upload them to the flickr group: http://www.flickr.com/groups/structuresynth/

      Best regards, Mikael.

      BTW: what is the problem with the widths or points vs grids?

       
    • Moritz Moeller

      Moritz Moeller - 2008-08-11

      Hey Mikael,

      thanks for making me a dev. I'll try to check the template in tomorrow.

      Regarding your question: lines (aka curves) and point primitives in RenderMan naturally have width that is specified in the space theiy're defined in. So they're don't have, like OpenGl lines, a width in pixels, but a width in units, like any any other primitive. And naturally, this width undergoes any transforms, the primitive itself undergoes.

      The problem now is that points & lines get defined in "world" space in Structure Synth (by supplyin actual coordinates for the vertices making up these primitives). I.e. their coordinates are absolute, so the "constantwdith" paramater you see in the template defines the width of the primtive in "world" space. Grids get defined by a unit wire cube transformed by a 4x4 matrix. Naturally, this matrix can contain a scale. So the width of the lines making up a gird is not guaranteed to be 'in synt' with taht of lines & points.

      If you want to try the template yourself, I suggest the Pixie renderer. Or Aqsis. Both are hosted on sourceforge and are RenderMan-compliant. Pixie supports global illumination, Aqsis doesn't. Or you can use 3Delight, a full-blown commercial renderer with quite a few feature film credits. That one, though closed source, comes with a full blown dual CPU license for free (including commercial work).

      All three renderers support an immediate mode interface. So you can send data directly to the renderer from C/C++, no need to write out to an ASCII file and have the renderer parse that back in.

      Cheers,

      Moritz

       
    • Mikael Hvidtfeldt Christensen

      Hi Moritz,

      Did you ever submit that template? :-)

      Regards, Mikael.

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks