Houdini orient to rotation

Posted by

I thought my collection of SOuP walkthroughs was a nice gentle intro for the average maya artist.

houdini orient to rotation

Now that I've been using Houdini for a little while, and knowing that SOuP is heavily influenced by Houdini, it seemed like a good idea to try and port those tutorials over. I've become the Houdini evangelist I always despised, and I apologise for nothing.

It really is a great piece of software, warts and all, and it's easier to get into than ever. Do it!

houdini orient to rotation

If you've landed here and you're totally new to Houdini, maybe head to HoudiniGettingStarted first, has a quick overview of how to use this site, and how to get comfy with Houdini as quickly as possible. Same as before, just type 'Cd' in the list of transferred attributes.

Using @orient attribute with instances

If you want more than one attribute transferred, separate them with a space. Eg, you want to transfer colour, normal, and pscale, you'd type "Cd N pscale". I added a colour node to the grid to make it red, another to make the sphere green, so you can see what's going on.

Why 'Cd'? Houdini uses a lot of naming conventions derived from prman. Cd is 'colour diffuse'. This was for the point sop in H It's been replaced with a vex equivalent, but its so fiddly to use, you're better off using the vop and vex versions of this below. I rant a bit further down that no-one should use a point sop anyway, the 'improved' point sop is so strange and fiddly to use, it seems SideFx agreed. Houdini, as well as having the renderman style parameters, often uses variables with capital letters and a dollar sign, called local variables to be used in hscript expressions.

These can usually be found by looking at the help for that node, and scroll down to the 'local variables' section. Some older or esoteric nodes don't have any local variables defined. Usually Houdini folk see these expressions and say 'ah, hscript'. Strictly speaking, houdini expression language and hscript are two different things in the way that maya MEL and maya expression language are two different thingsbut no-one can be bothered to say 'houdini expression language' out loud, and HEL sounds wrong.

Houdini defines global, standard and local variables as different things, but again, local variable is the usual short-form. If you look in the scene above, you'll see next to the point sop is a point vop that does the same thing in H13 and earlier called a vopsop, or an attribvop depending on what you needed to do.

I explain vops a little more in Houdini Vopsbut basically vops is a way to write very very fast operators. Maya expressions, python, hscript are all interpreted scripting languages, and can run into performance problems as scene complexity rises. Vops are compiled multithreaded code, and scale much better. The closest Maya equivalent would be trying to write your own deformers in hypershade nodes, but more versatile.

Point sops and hscript are how people traditionally used houdini, but the more you can push stuff into vops and vex, the better you'll be. In this case, it kind of helps to think of the vop network like a flowchart, reading left to right. First, the setup:. They flow left to right rather than top to bottom. In a vops network, the houdini chant that 'everything is points' becomes very important. Anything you do in this graph is run on all the points of your geometry simultaneously, or at least as simultaneously as your computer will allow.

The leftmost node represents a single point, and all its standard built-in attributes; position, colour, normal, id etc. The rightmost node represents the final output of a point. With no other nodes in the graph, attributes are implicitly passed through, so input P goes to output P, input N to output N etc; ie, the geometry is unchanged.

Once you start to wire in extra nodes, you change the state of the point. Because this graph runs not on one point, but ALL the points at once, the geometry too will be changed.On the Houdini Discord server s I keep seeing the same kinds of questions over and over again, mostly related to instancing. The most common questions asked seem to be:.

houdini orient to rotation

Aside from the obvious position of each point, P, there are a few other attributes with obvious effects. First things first. Next, some template point attributes.

If Houdini finds these attributes, it will try to orient each copy so that its Z-axis points towards Nand its Y-axis points towards up. Note that you can sometimes get away with only providing Nbut you might get unpredictable results. Edit: Something worth noting here is the dihedral VEX function. If you only provide an N attribute to the Copy SOP, Houdini has to guess what your up vector might be in order to build a complete orientation matrix. It does this by calculating the rotation necessary to rotate the world Z-axis onto your N vector, and then applying that same rotation to the Y-axis to figure out the up vector.

The dihedral function does exactly this… given two vectors, it computes the rotation matrix necessary to get from one to the other.

Hp pagewide pro 577dw manual

Basically, the matrix is telling you which way is up, right, and forward. This is how we rotate objects in CG. The third axis can be inferred by computing the cross product of the other two axes.

Take a look at the instances on this deforming mesh:. Note how they sometimes flip around.

A Long-Winded Guide to Houdini Instancing

The same movement, using quaternions for orientation. Note how the copies are much more stable. A matrix3 can easily be converted to a quaternion these are of type vector4 in Houdini using the VEX quaternion function. Quaternions themselves can easily be blended from one to the next using slerpor spherical linear interpolation. Quaternions are used all over computer graphics, especially in video game engines due to their ability to predictably rotate vectors.

Our point wrangle code for rotating this geometry or any old geometry at the origin looks like this:. If we run this, the object should just sit and spin slowly. Easy enough, right? We need to make sure each matrix, then, is oriented to that N, along with an up vector for stability. The maketransform function used here instead of ident means our starting matrix is already pointing the way we want it to be before we start rotating.

We define an axis and angle, exactly as before, and spin that matrix around. The last step is just converting the matrix to a quaternion and naming it orientwhich the Copy SOP knows to read. The output result looks like this:. Now to answer those second two questions… how to vary the objects copied per-point, and how to do it without copy stamping? The first point to take home here is that copy stamping is dead. The second point is that the copy stamping functionality can be rebuilt in a slightly different way using For-Each blocks, and Spare Inputs.

Spare Inputs are a relatively new trick that allows for some pretty amazing performance tweaks, and occasionally more readable networks. The first spare input you create, Spare Input 0, can be somewhat counter-intuitively referred to in an Hscript expression as So to grab P. Connect three different shapes into a Switch SOP, then create some points and give them a random integer attribute named index this name is arbitrary with a value between 0 and 2.

Our loop will run once per point, discarding all other points during each iteration, then merging everything back together again at the end.Create a primitive sphere as in the default sphere type, none of the poly or nurbs types. Well yes and no. That's the modifier that caused this deformation, but we could write this geo out to disk, read it back in, and it would still look like this without the transform sop. So where is it being stored on the geo itself, in the geo spreadsheet?

Translate is obvious, that's P. But rotation? If this were a polygon sphere then obviously it doesn't matter, as the rotation is baked into each point's P, but this is a primitive sphere. It's acting like a big standalone particle, so there's no 'outer skin' of points to rotate. If this were a packed primitive then rotation might be stored on orient, but no, its not there.

Neither is scale nor pscale. The answer is over on the primitives view of the geo spreadsheet. Switch over, click the 'intrinsics' drop down, choose 'Show All Intrinsics':. Hidden attributes! You can scroll across the entire list as shown above, or use the dropdown to view a subset:. Ok, so these are important base characteristics of a primitive. For example, if you look in the intrinsics list there's one for 'typename'.

Faster rcnn tensorflow object detection github

Enable it, you can see that it's 'sphere' in this case. Throw a bunch of random objects together, merge them, view the typename intrinsics attribute, this is how Houdini knows what kind of geo to draw for each primitive:.


Another intrinsic you'll find in there is 'transform'. View it for the sphere, you'll see its an array of numbers. Well, more than an array, its a 3x3 matrix. As I alluded to in the previous chapter, a 3x3 matrix is a compact way to store the rotation and scale of an object. I used to remember why it combines rotation and scale, but I've forgotten, and its not important in the context of this tutorial I'll find some links on matricies later if you're interested. Anyway, you can think of a default matrix called an identity matrix as a fresh transform sop; it has scale at 1 1 1, and applies no rotation.

The 3x3 set of numbers that represents this 'do nothing' state has a recognisable form, similar to the 'no rotation' form of orient :. Now, notice that if you view all the intrinsics in the geo spreadsheet, most are dark gray?In the previous lesson we went learned how you can use N and up to define a stable rotation. There's another way to do this, which involves jumping to scary quaternion land, 4 dimensional values, unintuitive concepts. Or is it? When I first heard about quaternions many years before getting into Houdini, I tried to understand the maths and got myself hopelessly confused, gave up.

When I came back to it via Houdini and instance attributes, I took some advice from Matt Ebb; don't try and understand whats happening under the hood, just care about the end result, and what it can do for you. So some of this intro stuff you'll have to take on faith, I'll explain details later This is probably gonna be way over 30 mins today, but I think it's useful to have all the orient related stuff on a single page. Maybe break it over 2 days On the instance attribtutes page you'll see that orient is at the top of the list.

That means it takes priority over everything else. The reason is that its the most unambiguous way to define rotation. Orient is a 4 value vector, so it's nice and compact to store. Try this on the usual grid, but put a transform sop before the wrangle. You can now rotate the grid however you want, and the boxes will always maintain their rotation.

That 'no rotation' orient is pretty much the only time you set an orient vector manually. Most of the time you construct an orient through vex functions. Vex offers several ways, each can be handy depending on the problem you're trying to solve.

Daphne emv software

Most of these are done via the quaternion function. Set the axis channel to 0,1,0and slide the angle slider around, all the boxes will rotate around their y-axis. This is a much easier way to have smooth animated rotation compared to the N and up method from yesterday.New to Vex?

You might want to read JoyOfVex first. So you've pushed past hscript, ignored python for now, and seen the awesomeness of vops.

You'll also probably start to get curious as to why there's at least 4 different ways to define point attributes, all with various idosyncrasies. Time to sweep all that away with Vex, specifically with the Wrangle Sop. Wrangle Sops let you write little bits of Vex code, and come with a few UI niceties to make them quick and efficient to use. Best way to get into vex and wrangle nodes is to put down a 40x40 grid, append a point wrangle, and follow along:.

Hit ctrl-enter, look in the geometry spreadsheet, there you go, float attribute. The tells houdini that you want this to be an attribute, the default type is float. You want a vector attribute? Prepend 'v' before the ' '. To initialise, use curly braces if its just numbers, or use set if you're doing something with functions or other attributes:. You can set the attribute type using the appropriate prefix. The default is float, so you rarely need the f prefix.

The symbol is used to get attributes as well as set them. All the attributes you see in the geometry spreadsheet, you can access them by sticking in front of their name. To access an individual attribute of a vector or colour, use attribute.

Eg to get just the y value of each point and divide in half:. To set it is similar. Eg to set the red channel of each point to the sine of double the x position:. Vector attributes like Cd or P let you refer to components in several ways, use whatever is convenient. Note that wrangles implicitly know certain common attribute types P, Cd, N, v, orient, id, name, several othersbut if you have your own attributes, Houdini will assume its a float unless told otherwise, easy mistake to make.

To ensure Houdini does the right thing, prepend the type. Eg, you've set mycolour as a vector, and try to use it in a wrangle:. I always forget to do this, shout at my wrangles for a bit, then finally remember to stick 'v' in front of my attribute names. No doubt you'll do the same. If you've used other programming languages, you might be thinking 'Ok, but how does Vex know which point to process? How do I iterate through the geometry?

There's too much voodoo here!Discussion in ' Scripting ' started by liquidgraphMay 9, Search Unity. Log in Create a Unity ID. Unity Forum. Forums Quick Links. Asset Store Spring Sale starts soon! Unite Now has started! Come level up your Unity skills and knowledge. Joined: Feb 26, Posts: I have a tank object whose normal tracks my terrain, so when the tank moves up a mountain, it's X and Z rotation is flush with the terrain normal. Doing that was easy, but now I need to have the tank facing the proper direction as it moves.

This means I need to rotate it along the terrain normal so that it faces where the player clicked. I'm using two sets of quaternion rotations one to align to the terrain and another to align in the direction of travel but they seem to be conflicting with one another. Take a look: Assuming I have the first part right -- terrain alignment -- how would I then add to it rotation along the local y-axis so as to align in the direction of motion the x,z difference between where the player clicked and where the tank is now?

Code csharp :. Distance startPos, movePos. Raycast castPosition,ray,hit, ,layerMask. FromToRotation Vector3. Lerp startPos, Vector3 movePos.

LookRotation posDifference. Angle transform. MoveTo movePos. Joined: Nov 28, Posts: 1, Just make the tank turn towards the desired point first and insert the code for terrain alignment after that. FromToRotation transform. Thanks Rune. Yeah, I just figured out that using Quaternion components isn't smart. I was trying to set the direction of motion prior to aligning the normal, but the normal rotation always ended up overriding any direction the object was previously set in.

I'm going to try doing what you say, but how would I got about animating this. Ideally I don't want the normal to snap when the tank drives over a hill -- the normal should animate smoothly, and while that's happening, it should also be possible to animate a change in direction.

Cpu temp linux

I've got it working pretty well now, but I can't figure out how to LERP between two quaternions along an axis. When I use this Code csharp :. Lerp fromQuat,toQuat, i. Joined: Feb 21, Posts: 7. AlbazcytheMay 1, Ignacii likes this. Joined: Jun 29, Posts: 6. Thank you! I've got my Spiderobot walking over the whole asteroid's surface!Also please see new Packed Primitives in Houdini.

Now reference the object in the instance node under the instance tab:. Note that Fast point instancing is recommended for H You will now have a box at every point. These are not copies but instances. Suppose now that you want to manipuate the instances so that each has different characteristics much the same way you used the copy number and copy stamping to manipulate copies.

In this case we need to associate attributes with the points. If you go to "help" and search "copying and instancing", click on the Copying and instancing page and you will see at the bottom Guru level. This has a list of all the copying and instancing point attributes.

Instances in Houdini - The Why and How

Instead of a point sop you could add an attribute node and write the values into pscale. Another method that is more versatile and introduces vopsop is to create a vopsop. Vops are very handy. We will concentrate on vops inbut they are also a handy thing to know in Essentially vops manipulate data.

Your vop network looks similar to your sop network in some ways.

Kontakt 5 808 library free

Replace the point node with a vopsop node. Dive into the vopsop you have put down. Hit tab and type random. Wire the point number from global1 into random1. Create an "add attribute" node.

This may seem like more work, however there are many cases where it can be an invaluable shortcut. To access existing parameters, left mouse click the gear symbol next to the parameter and select "Promote Parameter". You can either expose the input, or left mouse click again and select "Jump to Input", or click on the circles.

One way to manipulate the direction would be to manipulate the normals. Instancing will align to the normal. We could add a point sop again, and this time under the standard tab, add normal and set the x, z values to rand expressions.


Leave a Reply

Your email address will not be published. Required fields are marked *