Array promotion and demotion RFE?

   4917   11   1
User Avatar
Member
337 posts
Joined: June 2013
Offline
Would it be too of a system breaking thing if single values were automatically promoted to arrays when using reguar operations with arrays, without having to loop for each of them? Feels cumbersome when you want to do something as simple as to decompose and compose something.


Inversly when something can only take a single value it could take the first element of the array for demotion.

Let's say I want to multiply the values of an array by the values of another array. Would be cool if I could just do
array1 * array2
, without having to do pseudo

empty_array = []
for i in xrange(array1):
empty_array.append(array1[i] * array2[i])

every time I want to do a simple operation with two arrays.

again, there could be automatic demotion of the longest array, say when array1 lenght is 4 and array2 length is 10, the resulting array length would be 4.

Cheers
Edited by probiner - June 12, 2017 18:38:48
User Avatar
Member
337 posts
Joined: June 2013
Offline
I guess the issue is to implement this in VEX…

But hey, I guess some people would appreciate to be able to do
var = [0,1,2] * [3,4,5]
var = [0,4,10]
Python has list comprehensions which makes these quite customizable while “short” although somewhat hard to read and maybe not appropriate for this context, but at least they are quicker than setting up a loop,
[x + y for x, y in zip(list1, list2)]
(but even so…)
A loop should only be required for a very customized operation step.

Cheers
Edited by probiner - June 20, 2017 13:34:22
User Avatar
Member
2036 posts
Joined: Sept. 2015
Offline
I usually work in vex…so when there is no function that does something like ‘array1 * array2’ I just make the function, use an include statement(for the file/s that have the function/s)….

and simply call the function just providing the argument/s… My_Array_Multiplier(array1, array2);

Question is, because I have little vops experience…can we do something similar?

Create a function, ‘wrap’ it as a vop node, and put it in the vop ‘list’, so that we can simply lay it down when needed?
Edited by BabaJ - June 20, 2017 14:24:37
User Avatar
Member
7741 posts
Joined: Sept. 2011
Offline
BabaJ
Question is, because I have little vops experience…can we do something similar?

Create a function, ‘wrap’ it as a vop node, and put it in the vop ‘list’, so that we can simply lay it down when needed?

That's literally what VOPs are.
User Avatar
Member
337 posts
Joined: June 2013
Offline
“just do a function” is a practical and working solution but feels a bit like told to do a function to vector * vectorbecause *only works with floats and not vectors
Specially because then you have all other operations to do and deal with data type issues…
Can you drive a constant node type to change according to a connection made else where?…

I ask this because I've made this VOP HDA to build an array of indices and linearly interpolated floats.


I've made signatures to have the float flip to other types:


But how would I change the constant node being used in the loop to match the signature?…


Anyways I was looking for blind spots in my request. As of now I didn't see any pointed here.
float array * float arraydoesn't interfere with anything VEX does at the moment, same for float array * single float
This is a push to extend Array functionalities, same with the problems I've mentioned and already done an RFE about visualizing Arrays.


Cheers
Edited by probiner - June 23, 2017 16:54:26
User Avatar
Member
2036 posts
Joined: Sept. 2015
Offline
That's literally what VOPs are.

Yeah ok. But can we create our own custom VOP nodes?

If it is possible,

Would it be with Python and digging into Hou; Or/and something we would have to do in HDK?

“just do a function” is a practical and working solution but feels a bit like told to do a function to vector * vector because *only works with floats and not vectors

Then in your function don't do
vector * vector
.

You do whatever it is that you need your function to do.

Then when ever you call your function you only have to give it the two arguments (two vectors), and it multiplies the two vectors in the way you wrote your function to give you what you inteded.

And you only had to write that ‘procedure’ once(in your function). That's the point of the function. I wasn't implying your function to literally just do - vector * vector.
Edited by BabaJ - June 23, 2017 17:51:10
User Avatar
Member
337 posts
Joined: June 2013
Offline
Submited



Summary of points:
- Ease up operations with arrays by allowing simple arithmetic with them: array + array or array + single.
- Allow operations to accept arrays and single values together (in the same signature?) and promote the output to arrays if an array is present.
- In vex, sum, product, average, min, max work with arrays, but there's no corresponding nodes in VOPs. (forgot to mention in the video).
- Visualize Array Data with visualizers without having to do geometry workarounds so it's visualized on explicit points.
User Avatar
Member
337 posts
Joined: June 2013
Offline
BabaJ
Then in your function don't do
vector * vector
.

You do whatever it is that you need your function to do.

Then when ever you call your function you only have to give it the two arguments (two vectors), and it multiplies the two vectors in the way you wrote your function to give you what you inteded.

And you only had to write that ‘procedure’ once(in your function). That's the point of the function. I wasn't implying your function to literally just do - vector * vector.

I think I'm not making my point across. There's no way to predict all procedures one will use and build functions before hand for all possible combinations, but if the building blocks allow certain rules, then nobody even needs to make knee-jerk functions for these and be delayed every time they try something new but only loop for something custom.
Edited by probiner - July 5, 2017 22:31:33
User Avatar
Member
2036 posts
Joined: Sept. 2015
Offline
I think I'm not making my point across. There's no way to predict all procedures one will use and build functions before hand for all possible combinations, but if the building blocks allow certain rules, then nobody even needs to make knee-jerk functions for these and be delayed every time they try something new but only loop for something custom.

Whether you do the changes in a specific function or you do the changes with building blocks. Essentially it is both same - Semantics otherwise.

I think you might be mis-understanding my intent and taking my suggestion for creating your own functions as something more akin to writing a lengthy script that is only specific to your task at hand. But I wasn't.

Your functions can be the ‘building blocks’ where you combine the different functions which ever unique way you want to without ever having to build a new function.

The key to doing that effectively is to recognize what operations are you doing often and repeatedly. In such cases when you see something pop up like that often - it becomes a great canditate for a function.

Like your mentioning of ‘vector * vector’ . Not having used vops much I was assuming your always having to do ‘extra’ work repeatedly to get the result. So why not put that into a function was my suggestion.

But all this may be moot if you can't eassily ‘wrap’ those functions you create as a ‘node’ you can just drop down in a vops network like the other Houdini default selections.

Of course I am aware of the inline and vex smippet nodes. If it's possible the same way as with wrangle nodes;

You could externalize reference to those functions by just using #include <Cwhatever folder/yourfunctionfile.h>
and call up your function whenever needed.
User Avatar
Member
9 posts
Joined: March 2014
Offline
Hey there Probiner, did you manage to get the indices back from an array ?
How comes when I do this loop, it does takes the index of the loop and fills the array with it.
Edited by olivier_jeannel - Sept. 15, 2017 04:17:58

Attachments:
pb-build-array.jpg (430.9 KB)

User Avatar
Member
9 posts
Joined: March 2014
Offline
but when I need to writes these values to each point, I cannot ? (the index value of the for begin outputs a constant instead of (0,1,2,3…)

Attachments:
pb-build-array2.jpg (483.8 KB)

User Avatar
Member
337 posts
Joined: June 2013
Offline
Hmm maybe that's offtopic, Olvier, and worth its own thread in Softimage forum, but see if the attached scene helps:


Basically I set color attrib in prims, then convert to vert, then convert back to prims.
In each Attribute node there's a SetCd option in the bottom so you can see that indeed the attrib is coming through.

There's some things I can't seem to do in VOPS, like primvertices() to generate an array of global vertex IDs per prim, or vertexindex() to get vertices local ID (relative to its prim).

Let me know how it goes. But like I said this would probably be a good thread in Softimage forum about PolygonToVertices, PolygonToNodes, NodesToPolygons, etc, like we were used to.

Cheers
Edited by probiner - Sept. 20, 2017 01:47:06

Attachments:
Transport.hipnc (117.3 KB)

  • Quick Links