Jump to content

Procedural Primitives for a Procedural Tool.


Recommended Posts

I have questions about Mantra procedures?

Are they written in hscript?

can anyone write his own procedures?

Is it possible to create procedural primitives like Renderman ones with Mantra (for example h-scripts ( if it is the right language) that are only executed when the BBOX of the procedural geometry is reached,in order to

defer the cooking of large amounts of geometry, taking for example the BBOX size in parameters or anything else that is meaningful for the procedure).

It seems that there's the equivalent of the Read-Delayed-Archived

with the Bound File Option in the Render Menu of Objects. but

no Mantra equivalent of a Renderman procedural primitive

It would be a good application of the procedural paradigm!!

:)

Anyway, Mantra is a very very good renderer... :) :)

Link to comment
Share on other sites

From the now defunct Houdini 6.0 Beta forum by jlait:

A Short Tutorial on Houdini's HscriptInstance Capability

This document aims to provide a short tutorial on how to use Mantra's new Procedural technology and OTLs to create arbitrarily complex render time geometry without writing a single line of code.

What are Mantra Procedurals?

While this is too big a topic to get into right now, a quick overview is in order.

When you tell mantra to render a scene from within Houdini, it creates a "ifd" which describes that scene and sends that to Mantra. This ifd has all of the geometry, textures, shaders, etc, baked out. If you want 5000 geometry objects, the ifd will have to contain 5000 copies of the geometry - a no small amount of space! To avoid this, several options were present in the past. You could use point instancing to stamp the same geometry to every point, which is memory and time efficient, but results in everything being identical. You can also tell Mantra to use an external geometry file. This allows mantra to only load that geometry file when it actually needs to be rendered - an improvement over the File SOP which is loaded whether it is needed or not. With Houdini 6 is another option: the procedural. A procedural is a reference to code that should be executed to generate the geometry to render. For example, the sprite procedural will create grids on top of every point in your geometry and orient them to the camera.

The hscriptinstance procedural is designed to instance arbitrary geometry on each point of an object. It gets its geometry by running hscript, adding the specified sop, and using the geometry of that sop. Needless to say, there is a fair bit of overhead with this, so it is best used where there is a lot of culling and the cost to generate a single piece of geometry is high.

What are OTLs?

Again, too large a topic for here. A brief overview:

OTL stands for Operator Type Library. An operator type library contains a group of custom operators, such as those created when you turn a subnet into an operator. Because they bundle all the information for the op into one file, you can have locked geometry, or networks within networks, all defined in a single SOP.

Simplest HscriptInstance Procedural

Enough reading, on with an example:

1. Open a standard Houdini.

2. Go to Objects, enter Model

3. Add a box, size 3x3x3

4. Go to Objects, in the Render tab for model, change Geometry to Procedural

5. Click on the + besides mantra procedure

6. Change it to Instance with Hscript

Note that the SOP is set to "platonic". This means that a platonic solid sop will be instanced to each point.

Everything here is good, so hit accept.

7. Rezoom your display so it is cool, and hit render.

8. If everything is good, you should have got 8 tetrahedrons on the points of the cube. Why tetrahedrons? That is the default of the platonic solid sop.

9. Let's orient it to the cube.

10. In /obj/model, append a Point SOP, set it to display & render.

11. Turn on normal creation

12. Go back to the + button beside mantra procedure

13. Toggle on Orient

14. Accept

15. Re-render. Each tetra hedron should now be oriented with it's z axis along the normal of the cube's vertex.

16. Go back into /obj/model

17. Append an AttribCreate SOP

Name: type

Type: integer

Value: $PT

18. Go back up to objects, re-render. You should now see lots of different platonic solids! This is because the platonic solid sop has a parameter named "type". Much like vex, any point attribute which matches a parameter attribute will override that parameter attribute.

Complicated example

This example shows how to build your object in OTLs and then use that OTL for your instancing.

1. Start a new Houdini.

2. Add a geometry object called instobj, turn off display

3. Go to /obj/instobj

4. Put down an lsystem.

5. Turn on "point attributes"

6. Change the thickness to .2 (under Tube tab)

7. Append a transform sop

8. Change the rotate value to be 90 0 0. This is so our z axis is "up". This is what will be rotated to the normal.

9. Append a polywire sop.

10. Wire Radius: $WIDTH

11. Do Vertex Textures: off

12. Put down a SHOPNET

13. Inside the SHOPNET, add a Vex Clay

14. Set the diffuse colour to something brownish.

15. After the polywire, append a shader sop

16. Set the Surface to ../shopnet1/v_clay1

17. Your tree should now be brown.

18. Select everything, hit C to collapse it into a subnet

19. Rename the subnet "tree"

20. RMB on the subnet, and choose "Create Type From..."

21. Change the name to "tree"

22. Change the OTL library to tree.otl in a path you will remember. Eg, for windows: c:/tree.otl.

23. Accept

24. Go to the parameters page.

25. In side the tree subnet, go to the lsystem sop and the generator page there. Drag the "Generatons" parm ino the parameter lister.

26. Change the name to "treeage"and label to "Tree Age". This will be the parameter we override with our point attribute.

27. Accept

28. Put down a new tree SOP, make sure it does what you want.

29. Go to /obj/model

30. Add a grid, set size to 4x4, rows/cols to 3x3.

31. Add a point sop

32. Turn on normal generation

33. Turn on Pscale, set it to $PT

34. Add an attrib create sop

Name: treeage

Type: float

Value: rand($PT) * 5 + 1

35. Go back to Objects and the param page for model

36. Set Render::Geometry to Procedural

37. Hit the + beside mantra procedure

38. Select instance with HScript

39. Change SOP to tree, your newly created OTL SOP

40. Leave the Basic size as 1,1,1. Your SOP will generate geometry of up to this size. If this is too big, mantra will generate your geometry even if not needed. If it is too small, it may not generate your geometry even if it is not present.

41. Turn on Size attribute, it defaults to pscale, the name of the attribute you use to scale your geometry. The size which mantra assumes your geometry is, is the points pscale * basic size. As the tree SOP doesn't generate anything other than unit size...

42. Turn on Scale. This will automatically scale each output geometry from hscript by the relevant particle scale, if present.

43. Turn on Orient.

44. Turn on OTL files. If you ran a default hscript, your tree.otl won't be loaded, so it won't be able to find your tree SOP. Enter here the path to the otl file, ie: c:/tree.otl.

45. Accept

46. Now, render!

47. Note that the trees are all white! Your shop shader wasn't properly applied. This is because Houdini didn't know it should output that shader to the ifd.

48. Go to Ouput drivers

49. Select mantra1

50. Go to the Specific tab

51. At the bottom is SHOP References. Set this to Declare All Shops. This will cause the ifd to contain every SHOP found in this .hip file. As our hip file contains a copy of the tree (inside instobj), it will contain a copy of the tree's shop.

52. Render with this output driver! Voila! Brown!

Link to comment
Share on other sites

Yeah! :P :P

Thank you!!!!!!!!!!!!

Great Help!

( the longest post i've ever read! a real lesson!)

I already knew about the instancing capabilities of Houdini ( watched a video tut about it), but they presented

another way to do it ( which is equivalent but it was looking a bit magic and there was no real explanation

of the process. they just said: do this, this, rename etc... without any explanation).

I now better understand the parameter override. It looks now really equivalent to the Renderman Procedural

Primitives, where you encode all the necessary informations in point attributes.

Mantra is very very similar to Renderman!!

( and what is better is that you create your procedural primitive without any coding!! )

It would be very very nice if Houdini could generate RMan C/C++ code for procedural primitives...

I'm looking forward to making fur objects, with procedural animation. Do you think

instancing curves with Mantra is a good process to create fur when there's more than

10000 curves for example. Or is Renderman definitely better for such expensive computations?

thx a lot!

Link to comment
Share on other sites

>>It would be very very nice if Houdini could generate RMan C/C++ code for procedural primitives...

Hmmmm not sure, but this should work.

You can write command line application in C++

This programm must accept some fur parameters

and output fur geometry to stdout in Geo format.

Now create OTL object which contain Unix SOP

Create all necessary fur parameters for this OTL

Parse this parameters to unix sop command:

MyFur.exe `ch("../FurLength")` `chs("../FurType")` e.t.c

(chs(....) - for string type)

Call this OTL as Mantra Procedure.

Link to comment
Share on other sites

> I'm looking forward to making fur objects, with procedural animation. Do you

> think instancing curves with Mantra is a good process to create fur when

> there's more than 10000 curves for example. Or is Renderman definitely

> better for such expensive computations?

Mantra, of course! But then I'm biased. :)

Link to comment
Share on other sites

Yeah !

Thanks Andrew.

I'm currently on Windows but things are gonna change!

I wasn't thinking about outputting .geo geometry but rather RI commands.

( a litle bit like VOP which creates Vex Code)...

To Edward:

Sure Mantra is very good but is it used in large productions for expensive

renderings, where Renderman is?

Is there comparisons between mantra and Prman?

Houdini is simply the best!

Link to comment
Share on other sites

  • 1 year later...

Hi,

I did the tutorials above and have one question.

Why does the rendering take so long to render? I understand it has to do the calculation of the geometry that is not presented in the viewports but... It is taking about 10 seconst just to start the rendering of the platonic solids, the actual rendering goes on for 1 or 2 seconds.

As for the trees, i tried a 30x30 divisions grid, and gave up... it never rendered.

Is this normal?

Link to comment
Share on other sites

That's not too surprising since:

- It trades off speed for memory

- Loading hscript is *slow*

18063[/snapback]

Hi Edward, I understand the speed/memory issue. Since hscript is *slow* to load. Could you tell me how would be an efective way of working with proceduraly rendering large amout of geometry?

Im thinking basicaly about the Infinity - Dusk tv ad. Where they mention the vegetation.

I saw a demo of Vue software and was wondering how it does the rendering so fast. Once you do the "populate" with the ecosystem tool, you only see cardboard or proxys of plants, rock, etc. on the viewport, afterwards it replaces them with actual gometry on rendering time. And it is real geometry, because it renders real shadows, reflections, even GI interacts well with it.

Link to comment
Share on other sites

We really can't compare a card-based system against generating real geometry for rendering.

I imagine most people deal with "crowd" scenes either as archived geometry or as optimized procedurals. Neither of these methods involve using hscript. HscriptInstance was intended as an easy way to trade off memory for speed and not meant to be efficient by any imagination.

If you're interested in this, you should read the MantraInstancing page on the odforce wiki.

Link to comment
Share on other sites

instancing is the way to go IMHO.. i'm actually doing it right now with a field of weeds and rocks..

i have my terrain. i'm painting on an attribute to control the density of points through the scatter sop..i then use those points as a basis for instancing 10,000 weed objects.. renders lickity-split. (although i will say using certain shadow types will cause it to slow down dramatically)..

Link to comment
Share on other sites

instancing is the way to go IMHO.. i'm actually doing it right now with a field of weeds and rocks..

i have my terrain. i'm painting on an attribute to control the density of points through the scatter sop..i then use those points as a basis for instancing 10,000 weed objects...

18068[/snapback]

I should study more about instancing then. If possible, post some images on your progress.

edward - I wasntt comparing card-based with actual geometry. Vue actualy renders real geometry, the cards are just for the openGL viewports. I was just amazed at how fast it can switch from one to another once you press the render button.

Link to comment
Share on other sites

hey andz,

this project is still very early on (in pre-vis stage) but you get the gist of things:

post-505-1115776699_thumb.jpg

post-505-1115776809_thumb.jpg

(btw, it's 6,000 weeds, not 10,000.. i had 10k or 12k originally but came back from that for visual sake.. they rendered just as quick when i had that many though)

Link to comment
Share on other sites

That's not too surprising since:

- It trades off speed for memory

- Loading hscript is *slow*

18063[/snapback]

hey, on that note,

is there any way when using point instancing, i can overwrite a file SOP entry or using a otl, just change the parameter before it renders for each instance?

much like what u would do with a copy sop, and param into the file sop.

i tried the traditional attcreate etc, but it doesnt seem to work.

any ideas?

aracid :blink:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...