for example :
v@Cd = {0,0,0}; v@Cd = set(0,0,0);
When using {} , why can't I use math expression or function such as :
@Cd = {rand(1) *2 , 0 , 0};
Thanks
animatrix_
Hi,
{} only works when you use literal values inside. The {} syntax is designed for static, compile-time assignments rather than dynamic, runtime evaluations.
Use set() when you need to initialize vectors with dynamic values, computations, or function calls.
metaclay2
Thanks, my next question is : if set() can also use static value the what is the benefit of using {} ? or If the value is just static then what makes the {} preferable compared to set() ?
ObeidaZakzak
When working with static values, curly braces {} are preferred as they do compile-time evaluation.
vector @up = {2,0,5};
vector @up = set(2,0,5);
vector up = set(2,0,5);
vector @up = {2,0,5} * 2;
BabaJthat's not allowed in any wrangle, since that's the default value for the prototype and that has to be constant
In a 'detail' wrangle this is allowed:This is not:vector @up = {2,0,5};vector @up = set(2,0,5);
vector @up = {2,0,5};
v@up = {2,0,5};
v@up = set(a,0,5) * 2;
tamteIt wasn't meant to imply in only detail set wrangle, it was only meant to inform of the context the points being made are from.
that's not allowed in any wrangle,
tamteWhich is what I was saying - the function set() is a computation.
since that's the default value for the prototype and that has to be constant
tamteIt's 100% a vex thing in terms of how the compiler/pre-compiler or even some special 'stage' of processing; Which takes into account 'attributes' as defined uniquely in Houdini with the '@'
it's not necessarily a VEX thing, it is the snippet syntax, but because it translates to the CVEX shader argument, it can't contain anything else than literal constants
tamte
just note that defining the prototype with default constant value:
vector @up = {2,0,5};
is a different thing from assigning a value to the attribute:
v@up = {2,0,5};
where you can use variables and any sort of runtime expressions
v@up = set(a,0,5) * 2;
BabaJ@ binding is not part of VEX, it's a snippet syntax that gets translated into VEX as an argument of the shader
It's 100% a vex thing in terms of how the compiler/pre-compiler or even some special 'stage' of processing; Which takes into account 'attributes' as defined uniquely in Houdini with the '@'
tamteIt is VEX in terms of the context it was presented. That's why I put 'detail' as I did in quotes, so it would be understood as that.
@ binding is not part of VEX,
tamteIt most definitely did.
My post meant just to expand
tamteYes that certainly was made clear.
clarify more why that's not allowed
#define Example_A set(5) #define Example_B {3,5,6} #define Example_C 10.2 * 5
Example_B += 2;
int @Att_Example = 5; @Att_Example += 2;
int @Att_Example = set(5); @Att_Example += 2;
int @binding_name = 5;
cvex my_shader(export int binding_name = 5) { }
i@binding_name = 5;
cvex my_shader(export int binding_name = 0) { binding_name = 5; }