Marcola 6 Report post Posted April 6 Hi, I have a very basic question. I have a black and white sine wave function applied to a grid and i would like to change the color of each ring (black and white). How can i achieve that? Attached is the file i'm talking about. Thanks! VEX_SineWaves_ODF.hipnc Share this post Link to post Share on other sites
Noobini 213 Report post Posted April 7 (edited) not sure if I'm on the right track...is this what you want ? vector pos = @P * chv("Position"); vector center = chv("Center"); float d = distance(vector(pos), center); d *= ch('Scale'); @Cd = fit(sin(d - @Time*4), -1, 1, 0, 1); if(@Cd.r>0.5){ @Cd = set(1,1,1); } else{ @Cd = set(0,0,0); } (it's crisper if you change your wrangle to run over prims) Edited April 7 by Noobini Share this post Link to post Share on other sites
Marcola 6 Report post Posted April 7 Thanks for your reply Noobini. I also tried the if statement but as you can see the float fade color is lost when the if statement is applied. I keep getting a warning sign in Houdini stating that i should cast the line where the if sits. I tried casting it but i still couldn't get a smooth color as the original black and white rings, if that makes sense. SideFX, would be very nice if you guys implement in H17 a better debugging system other than very basic error messages. People want to learn VEX and Houdini is awesome! Share this post Link to post Share on other sites
Noobini 213 Report post Posted April 7 (edited) i get NO warning. Are you sure you're using @Cd.r ? because that is a float....so it's correct to compare a float with 0.5. If you use @Cd, that's a vector...so it's telling you to cast it properly (if you were comparing to a float) (odd that if I use @Cd, I get the warning...correctly...but then if I scrub...the warning goes away, incorrectly !! Dunno...) Edited April 7 by Noobini Share this post Link to post Share on other sites
Marcola 6 Report post Posted April 7 Ok, thanks for the info again. It makes sense. What i meant by saying "fade color" is a color transition that is not jagged, like the attached img. I can change one ring color but not the second. Share this post Link to post Share on other sites
Noobini 213 Report post Posted April 7 add a Smooth but instead of working on P, work on Cd instead...also i think your @Cd.z = 255 is superfluous....1 is max I think. Share this post Link to post Share on other sites
Marcola 6 Report post Posted April 7 Alright, will try switching the P for Cd. The @Cd.z, in my mind, was because every value under 50 grey i wanted colored, as i used the fit function from 0 to 1. Probably, that is not the best approach for the problem but somewhat, it works. Share this post Link to post Share on other sites
Noobini 213 Report post Posted April 7 there's also attribblur...I'm fooling around with it...not an expert with it tho... Share this post Link to post Share on other sites
mestela 541 Report post Posted April 7 http://www.tokeru.com/cgwiki/index.php?title=JoyOfVex13#Exercises but more generally http://www.tokeru.com/cgwiki/index.php?title=JoyOfVex In your case you could do something like float sin = fit(sin(d - @Time*4), -1, 1, 0, 1); vector col_hi = chv('col_high'); vector col_lo = chv('col_lo'); @Cd = lerp(col_lo, col_hi, sin); Share this post Link to post Share on other sites
Marcola 6 Report post Posted April 8 Oh man! The master himself! Matt, thank you so much for the amazing material that you posted a few weeks ago in your website. Learning a lot with it! Some challenging exercises but i suppose that programming is supposed to make people think smart before implementing it. We should have a section in the odforce forum dedicated to the Joy of Vex. I bet that a lot of people have questions about the exercises. Thanks for your help on my question. "Lerp" is a good friend. Cheers. 1 Share this post Link to post Share on other sites