Rival Consoles Posted April 6, 2018 Share Posted April 6, 2018 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 Quote Link to comment Share on other sites More sharing options...
Noobini Posted April 7, 2018 Share Posted April 7, 2018 (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, 2018 by Noobini Quote Link to comment Share on other sites More sharing options...
Rival Consoles Posted April 7, 2018 Author Share Posted April 7, 2018 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! Quote Link to comment Share on other sites More sharing options...
Noobini Posted April 7, 2018 Share Posted April 7, 2018 (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, 2018 by Noobini Quote Link to comment Share on other sites More sharing options...
Rival Consoles Posted April 7, 2018 Author Share Posted April 7, 2018 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. Quote Link to comment Share on other sites More sharing options...
Noobini Posted April 7, 2018 Share Posted April 7, 2018 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. Quote Link to comment Share on other sites More sharing options...
Rival Consoles Posted April 7, 2018 Author Share Posted April 7, 2018 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. Quote Link to comment Share on other sites More sharing options...
Noobini Posted April 7, 2018 Share Posted April 7, 2018 there's also attribblur...I'm fooling around with it...not an expert with it tho... Quote Link to comment Share on other sites More sharing options...
mestela Posted April 7, 2018 Share Posted April 7, 2018 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); Quote Link to comment Share on other sites More sharing options...
Rival Consoles Posted April 8, 2018 Author Share Posted April 8, 2018 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 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.