Monday 9 March 2020

Rotation in vex

Rotation round an arbitrary axis, in vex

nicked from Rich Lord's handy notes and scenes - https://www.richlord.com/tools/
Placed here, jusssst in case it all vanishes!
The general gist is -


  1. define an axis to rotate around
  2. specify the angle of rotation
  3. create an identity matrix
  4. rotate the matrix by the angle, along the axis
  5. multiply the Position of each point by the transformed matrix

Here's the code -
vector axis = normalize(chv("rotate_axis"));
float angle = radians(chf("rotate_angle"));
// create the matrix representing the rotation, and rotate the points
matrix3 m = ident();
rotate(m, angle, axis);
@P *= m;
Be sure to press the create slider/input button!

A separate example Rich provided has the points rotate around a point in space -

The same technique applies, except a little bit of subtraction/addition of the point position (we move the points-to-be-rotated to the position-of-the-rotation-origin first). Pretty useful, as you're probably not just doing everything at the origin :D

Code -
vector rotate_point = chv("rotate_point"); //this is the origin of the rotation
vector axis = normalize(chv("rotate_axis")); //the axis
float angle = radians(chf("rotate_angle")); //the angle of rotation...
// move the points before the rotation
@P -= rotate_point;
// build the matrix that does the rotation and apply it to the points
matrix3 m = ident();
rotate(m, angle, axis);
@P *= m;
// move the points back to their original position
@P += rotate_point;

Friday 21 February 2020

time shifting copy stamps

Needed to time offset an alembic which was being copy-to-points.
The methodology is the same as a previously posted thing, but the copy-to-points node needs to be situated inside the For Each loop



if you squint, you'll see there's an attribrandomize node. I've made an integer attribute called TimeOffset and ..randomised it..
In the timeshift node, I make a spare input and point it to ../PT, which holds said TimeOffset values

The value for the timeshift is : $FF+point(-1, 0, "timeOffset", 0)

so, we take the current frame and add the individual time offset value to it.

Shweet.

Wednesday 12 February 2020

cryptomatte AOV with arnold/HTOA

Another simple thing, which I always forget.

The most common crypto attribute I use is crypto_asset.
It seems to work best assigned at primitive level. So - in a primitive wrangle for example -

s@crypto_asset="poop"+itoa(@primnum);


The next part is to create an Arnold Shader Network, call it something like "CRYPTO"
Inside this, make an AOV Output  node. Create a cryptomatte node and hook this up to the aov_shader input. You may need to create a user_data_string with "crypto_asset" and plug that into the "crypto_asset" input of the cryptomatte node.


The last bit, is in the Arnold ROP you're using. In the AOV section, where it says "AOV Shaders", point it to they CRYPTO shop you made earlier -  /shop/CRYPTO

then add a new AOV and select "crypto_asset" from the list.

Hopefully this works!

Crypto_object is used when things are in different Houdini Objects... it isn't something that I usually do though..

Friday 7 February 2020

distort undistort stmap

This stuff is so boring.

original source 4448x3096
plug into undistortion node to get undistorted res 4560 x 3174 - ST MAP will be this res

plug 4560x3174 into redistort node to get 4448x3096 - ST MAP will be this res

Friday 31 January 2020

Getting the name of the parent node

Sometimes you'll need the name of the parent/container node that you're working in. It might be a "car_01" or something like that.

What you need to do is trick a wrangle into using houdiniscript. We do this by creating a parameter/channel and then typing in the script we wish to run, enclosed with backticks ` `

opname is the function we want to run and .. will get us up a level.
so in the wrangle use

s@string_name=chs("whatever");

hit the create-channel-box button, then type this in it

`opname("..")`

you now have a string value of the parent node that you could strip/atoi, whatever.

Tuesday 28 January 2020

transparent points/ points with alpha, Arnold

Plug Alpha attribute using User Data Float into OPACITY of Standard shader (in geometry section)

Monday 27 January 2020

POP streams, for POPs or even RBDs.

Bit of a waffly post here.. mostly for my own ref..

I had a case where there were a bunch of colour swatch cards in a display case of sorts. They needed to fly out of their resting position, but also had to vibrate and wiggle a little before this.
For context - I chose to use RBDs & the Bullet Solver, packed primitives for all of this, as there didn't need to be any clothy/plastic Vellum defomations.

So-

1) 10-15 frames run-up sim to settle
2) Cards gradually wiggle, not all at once.
3) Some cards shoot out of their position, not all at once.

The challenge is to effectively create an activation for the individual forces that effect the cards.

At first I was using the RBD-branded wind and fan forces - which did provide the necessary dynamic effect, but I couldn't figure out a way to use groups, or to trigger their activations on a per-packed-piece-point basis. These forces were connected one after another in a chain.


The solution is to use POP-Streams. In my case, we can plug this into an Rigid Body Solver (the 3rd input), as it already has a multi-solver, bullet solver and some other clever bits built into it.
We need to create a master POP stream with the rule set to include all the calculated points. You can/should initialise any values in this stream to account for any points that aren't picked up by the other streams. This might include making them active or not...
From this we can then connect secondary POP streams, each with their own rules and POP force nodes.

I tended to use the random stream option as a way to gradually and naturally add points to the stream.
Something I tried to get working was splitting streams one step further.. eg. A splits off to B ...but B then splits into C & D. This didn't quite go as planned.

I was trying to achieve a slow random addition to a stream/group and then for the cards to go either to the Left or Right, using POP forces. A bit of an inelegant solution, but I ended up creating two streams instead of B producing it's own two, (A divides into B AND C) using SOP bounding boxes. To achieve the random addition effect, I animated a threshold, which determined when the cards would activate. Each stream would then have its own POP forces. Much more control overall.