mart1jn Posted November 20, 2015 Share Posted November 20, 2015 Hello, I'm still new to houdini so please bear with me. I have a question about the function noise(). In the help it states that the function can return a float or a vector. In the following example the noise function seems to return a vector with 3 the same values. I would like to get 3 different values. I could make 3 seperate values with a different seed and combine them, but I'm pretty sure that's not the best way. What can I do? vector distort = {0,0,0}; float seed = 0.0; seed = @ptnum*12.23 + @Frame * ch("speed"); distort = (noise(seed) - 0.5) * ch("scale"); @P += distort; // these are for troubleshooting: f@seed1 = seed; v@distort1 = distort; Quote Link to comment Share on other sites More sharing options...
yourdaftpunk Posted November 20, 2015 Share Posted November 20, 2015 Houdini has to decide which function to call. It's looking at these two function signatures: float noise(float) vector noise(float) And it has to pick one. The parameter in both is a float, so that doesn't help distinguish between the two. Houdini next looks at the return values. Do any of those possible return values make sense with the next operation? Your expression is: (noise(seed) - 0.5) And Houdini sees that you subtract a float, thus you must want a float back. Houdini chooses: float noise(float) That value then gets multiplied by a float, your "speed" parameter, then the float is assigned to the vector distort. When a float is assigned to vector, the behaviour is to set each component to the same value. It's an implicit cast. That's what you noticed. The solution is to explicitly tell Houdini you want a vector back, even though you're about to subtract a float from the result. The full line becomes: distort = (vector(noise(seed)) - 0.5) * ch("scale"); This is function casting. It's not a full cast from one variable type to another, so it's fast. Cheers, Shawn 2 Quote Link to comment Share on other sites More sharing options...
mart1jn Posted November 20, 2015 Author Share Posted November 20, 2015 That makes sense. Thanks for the explaination Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.