Monday 21 November 2022

another way to cut or slice objects




Use 2 clip SOPs in a For Each loop. The "detail" function access the iteration number. These little expressions are pasted in the X, Y or Z origin boxes. The first cuts to the top of the division, The second cuts to the bottom of it (technically to the top of the previous iteration - which is what the "-1" is for.

 -8.26+detail("../foreach_count1", "iteration",0)*4

-8.26+(detail("../foreach_count1", "iteration",0)-1)*4

This does not create interior detail - but is good for troublesome geo.

Tuesday 15 November 2022

Cutting/slicing up an object in equal divisions

 Houdini Quick tip - slice equally - YouTube

Sometimes the Boolean Fracture lets you down, so use the Voronoi Fracture, and feed a line into the second input. That is pretty much the gist of the video.

Thursday 27 October 2022

GLSL style textures with COPS

 Create a COP network.

Create a VOP Generator

Inside this, make a snippet.

below is an example of what you could do inside the texture. This fills the image with pink and has blue borders on the left and right side of the image. The Step function doesn't exist in vex, so I define it in the beginning. So at least functions are code-able. Annoyingly chf("blabla" aren't possible, but you can add parameter inputs to the node.
The bottom line is the important part. It assigns the red, green, blue and alpha to the output (you don't need to plug anything into the output nodes of the VOP network).

Instead of U and V, you have X and Y.
You can still do things like multiply X and the modulo it to achieve tiling. I need to test out things like matrix rotations next. Much excite

float step(float a, b){

float jog=0;

if(a<b){jog=1;

}

else{jog=0;}


return jog;

}


float are=step(0.1,X)*(1-step(0.9,X));


vector4 rgba=set(are,0,1,1);

assign(R,G,B,A,rgba);



ROTATION UPDATE

so I couldn't figure out the matrix stuff...but handily a maths site mentioned that the resultant x' and y'

were: x'= x*cos(angle)-y*sin(angle) AND y'=x*sin(angle)+y*cos(angle)

doing some crap maths in vex gives you this:

vector2 uv=set(X,Y);

vector2 uvN=uv;

uvN.x=uv.x*cos(angle)-uv.y*sin(angle);

uvN.y=uv.x*sin(angle)+uv.y*cos(angle);


so now when you use uvN for any coordinate references the image will be rotated! I think the pivot is broken though...so that's next on the list of things

number padding and clamping file sequences

padding file names and clamping at the same time -


  `padzero(7,clamp($F4,1091,1256))`

 Think I've shown this snippet before, but maybe not combo'd with the clamp. Remember to use the back ticks to evaluate the expression when using it in a file name...And use all relevant brackets

accessing COP outputs in textures

use this expression to get to COP stuff - 


 op:/obj/cop2net1/out


the "op:/" is key!

"shrinkwrap" push faces from one object towards another

More Julian scripting
Use case - an object lying on the floor is not quite touching the surface - so lets pull points of the floor toward the surface. The floor object would go into the first input and the object to "wrap" to goes into the 2nd input. Put this code into a point wrangle -

 i@prim;

v@uvw;

@dist = xyzdist(1, @P, @prim, @uvw);

@bias = fit(@dist, 0, .01, .79, 0);

@P = lerp(@P, primuv(1, "P", @prim, @uvw), @bias);


It might be necessary to play with the "fit" values & ensure the objects are kinda close to each other to begin with! This is good for bodge fixing stuff!


Wednesday 26 October 2022

using a transform that relies on $CEX $CEY $CEZ with a differently shaped/sized object

Use the julian matrix - (point wrangle)

matrix M=detail(1,"xform");

@P=@P*M;

plug the transform you want to "copy" into input 2 ("1") and the object you want to transform with said transform into input 1 ("0"). 

MAKE SURE the transform node has the xform ticked at the bottom, so the wrangle can actually access the "xform"

This is especially relevant for when you overuse $CEX etc bounding box for pivots & you suddenly change the geo size. Eg you rotate your thing into place, and do so using the centre of a short object, but suddenly you need to substitute it with a much taller thing.

Wednesday 12 October 2022

exporting alembics or fbx from houdini with transforms

 Didn't realise this...and wasted about half an hour figuring it out..
If you, for example, are using a FETCH node or a rivet and need to export an object with the transforms you can a) use the bake animation ROP (must be used in ROP context!) b) click File>export as FBX or Alembic.

For the latter to work, you must place your stuff into a SUBNETWORK, or it will not export correctly. VERY ANNOYING. It's a bit like putting things into a group before exporting an alembic in Maya, just much less obvious.

Monday 26 September 2022

@scale

 I can't believe I've never used @scale....

@pscale is useful for uniformly scaling the instance/copied object onto a point. But what if you need to adjust the scale on a per-axis basis?

@scale=set(1,2,3);

this will scale the object by 2 in the Y, and 3 in the Z

woop woop

Thursday 22 September 2022

camera projection uv, texture reference object a la Maya

A simple thing..

In Maya, you can project UVs from a camera. To prevent textures from swimming if you do animate the object, you must create a Texture Reference Object. Here's how you do it in Houdini.

The gist is - 

  • use the UVTEXTURE node to project your uv's. Set the texture type to Perspective from Camera and specify the projection camera in the appropriate box.
  • freeze the object on the frame you want the projection to occur at, using a TIMESHIFT.
  • copy the uv attribute back onto the moving object, using the ATTRIBUTE COPY node.

Wednesday 14 September 2022

filename using digits of the node

 use case - you have many texture nodes, eg. Texture1, Texture2,Texture3.....

You want to automate the filename being loaded & use the number contained within the node name.

To do this we can use a combo of expressions -

//server/jobs/build/ion/textures/flooring/tile_`padzero(2,opdigits("$OS"))`.jpg

where the texture node is Texture5 becomes

//server/jobs/build/ion/textures/flooring/tile_05.jpg

So if we copy and paste this many times, it will update to tile_06, tile_99 etc...


padzero(2, SOMETHING) - pads the value SOMETHING with up to TWO zeroes. 5 becomes 05, 99 stays as 99.

opdigits("whatever") - returns the numbers of "whatever". In the example above, I use the $OS expression to get the name of the node itself-  ie; Texture5, so we get back 5. The padzero makes it 05.

these bits are enclosed with backticks  ` `, to execute the expressions.

Tuesday 22 March 2022

un pinning vellum constraints

in a pop wrangle, inside the vellum solver, do something like this


 if(@Frame>1175){i@stopped=0;}

as far as i know it works on Pin constraints, set to "stopped".


this vid from Sidefx explains it towards the end, sort of.

https://youtu.be/t_lyBo1U1t8

Tuesday 22 February 2022

Getting Point Attributes in CHOPS

Scenario - Had some points that were moving in unison, I wanted to stretch/squash each point's animation individually so they'd move at different rates. 
I made a point attribute for each called "shift" and gave them a random value between a min and max.

Then I made a CHOPNET and imported the geometry with the tx,ty,tz and shift channels.
Next we need a foreach chop node, be sure to specify all the channels in the parameter box.


Now dive into the foreach node and make a Stretch node.

I just wanted to use the shift attribute in the main Length Scale parameter, so I use the "chopi" function which seemed the simplest out of all the chop_ functions available. It evaluates the channel specified in quotes at the index you give it. This index is meant to be along the timeline, I believe - but since our value is a constant you can throw in any number.

chopi("../Foreach_Iteration/shift",10)

The Stretch node goes to the built in output node...make sure that one is being exported.

This should work now...each point's transform animation stretched according to the shift attribute.

Another thing I found whilst trying to figure this out was the Reorder node. It lets you sort the channels according to different rules. So if you use the number suffix, then it will "group" all the same point channels together. shift0, tx0,ty0,tz0, shift1,tx1,ty1,tz1....etc.... Could be useful if you have some sort of nth based logic going in a script or something, although I really think this for each method works much better.

I'm sure there are better ways to get point attributes in CHOPS.....I just can't figure them out haha. Let me know in the comments, if I've remembered to enable them.