Jump to content
Marcola

Sine waves color

Recommended Posts

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

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)

DiscreteRings.jpg

Edited by Noobini

Share this post


Link to post
Share on other sites

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

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 by Noobini

Share this post


Link to post
Share on other sites

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.

img.png

Share this post


Link to post
Share on other sites

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

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

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

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.

img1.png

  • Thanks 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×