@Cd = {0,0,0}; ch("ctrl",@Cd = {0,0,0};
Recast required in vex ?
3438 9 2-
- _Christopher_
- Member
- 767 posts
- Joined: April 2014
- Offline
-
- tamte
- Member
- 9121 posts
- Joined: July 2007
- Offline
-
- _Christopher_
- Member
- 767 posts
- Joined: April 2014
- Offline
-
- malbrecht
- Member
- 806 posts
- Joined: Oct. 2016
- Offline
Moin, Christopher,
I think your question is ambiguous - you ask about “recasting a vector to a float”, but if you want to “cast” a vector with 3 components to a float with, obviously, only one component, it is unclear which component you want to extract.
One possible interpretation of your question could be “I want to get the luminance value of a RGB color that is stored as a vector” - and for that there are various solutions, depending on color space and whitepoint.
The example you gave:
… doesn't work in VEX: You seem to be trying to set a parameter from VEX, which - unfortunately - Houdini does not support (it's not clear what you actually want to do, since the closing “)” bracket is missing).
If you want to extract a single channel from a vector, you can access it through .x/.y/.z. I think that is what Thomas meant: If the color is grayscale, it only has one channel (the x-channel), then “casting” is simply done by accessing that single channel's x-value, which is a float (or could be an integer). If the color has more than one channel, you need to define *how* you want to “recast”, because there is no such thing as “recast a 3 component value to a 1 component value” (think of imaginary numbers, which consist of two components).
Marc
I think your question is ambiguous - you ask about “recasting a vector to a float”, but if you want to “cast” a vector with 3 components to a float with, obviously, only one component, it is unclear which component you want to extract.
One possible interpretation of your question could be “I want to get the luminance value of a RGB color that is stored as a vector” - and for that there are various solutions, depending on color space and whitepoint.
The example you gave:
Christopher_R@Cd = {0,0,0}; ch("ctrl",@Cd = {0,0,0};
… doesn't work in VEX: You seem to be trying to set a parameter from VEX, which - unfortunately - Houdini does not support (it's not clear what you actually want to do, since the closing “)” bracket is missing).
If you want to extract a single channel from a vector, you can access it through .x/.y/.z. I think that is what Thomas meant: If the color is grayscale, it only has one channel (the x-channel), then “casting” is simply done by accessing that single channel's x-value, which is a float (or could be an integer). If the color has more than one channel, you need to define *how* you want to “recast”, because there is no such thing as “recast a 3 component value to a 1 component value” (think of imaginary numbers, which consist of two components).
Marc
Edited by malbrecht - Feb. 13, 2017 10:32:40
---
Out of here. Being called a dick after having supported Houdini users for years is over my paygrade.
I will work for money, but NOT for "you have to provide people with free products" Indie-artists.
Good bye.
https://www.marc-albrecht.de [www.marc-albrecht.de]
Out of here. Being called a dick after having supported Houdini users for years is over my paygrade.
I will work for money, but NOT for "you have to provide people with free products" Indie-artists.
Good bye.
https://www.marc-albrecht.de [www.marc-albrecht.de]
-
- tamte
- Member
- 9121 posts
- Joined: July 2007
- Offline
-
- tamte
- Member
- 9121 posts
- Joined: July 2007
- Offline
-
- malbrecht
- Member
- 806 posts
- Joined: Oct. 2016
- Offline
I agree with Thomas, the code snippet you posted makes it way harder to grasp what you want to do. Maybe a screenshot of your desired result, with some scribbling, would help. Or if you can write your code in any other programming language (JS, Java, C, C++, Python, Perl, PHP, Basic, Fortran, Pascal, Logo - we figure it out, just let it make sense, as Thomas puts it).
*If* you should mean “how can I adjust the color by three separate floating point sliders”, then you could do something like this:
Marc
*If* you should mean “how can I adjust the color by three separate floating point sliders”, then you could do something like this:
v@Cd.r=chf("path-to-r"); v@Cd.g=chf("path-to-g"); v@Cd.b=chf("path-to-b");
Marc
---
Out of here. Being called a dick after having supported Houdini users for years is over my paygrade.
I will work for money, but NOT for "you have to provide people with free products" Indie-artists.
Good bye.
https://www.marc-albrecht.de [www.marc-albrecht.de]
Out of here. Being called a dick after having supported Houdini users for years is over my paygrade.
I will work for money, but NOT for "you have to provide people with free products" Indie-artists.
Good bye.
https://www.marc-albrecht.de [www.marc-albrecht.de]
-
- _Christopher_
- Member
- 767 posts
- Joined: April 2014
- Offline
-
- malbrecht
- Member
- 806 posts
- Joined: Oct. 2016
- Offline
Cool - but what has “lerp” to do with “casting a vector to a float”?
(confused)
Marc
(confused)

Marc
---
Out of here. Being called a dick after having supported Houdini users for years is over my paygrade.
I will work for money, but NOT for "you have to provide people with free products" Indie-artists.
Good bye.
https://www.marc-albrecht.de [www.marc-albrecht.de]
Out of here. Being called a dick after having supported Houdini users for years is over my paygrade.
I will work for money, but NOT for "you have to provide people with free products" Indie-artists.
Good bye.
https://www.marc-albrecht.de [www.marc-albrecht.de]
-
- _Christopher_
- Member
- 767 posts
- Joined: April 2014
- Offline
-
- Quick Links