rohandalvi Posted November 21, 2007 Share Posted November 21, 2007 Hi, Is there any way to mix 2 colours based on light angle. I am primarily a 3dsmax user. Max has a Falloff map, which has various options, including "Shadow/Light" which allows the user to blend 2 colors based on the light direction. Is there anything similar in VOPS. I find it quite useful for faking certain effects like backlighting and translucency. with regards Rohan Dalvi Quote Link to comment Share on other sites More sharing options...
Mario Marengo Posted November 21, 2007 Share Posted November 21, 2007 Is there any way to mix 2 colours based on light angle. I'm guessing you mean the angle between the light direction and the surface normal, right? Yes there is, but it would have to live inside an illuminance() loop. The typical thing is a cosine falloff raised to some power -- here's the skeleton: surface blah ( vector color1=1,color2=0; float falloff = 1 ) { vector n = normalize(frontface(N,I)); vector C = 0; illuminance(P,nn) { shadow(Cl); vector l = normalize(L); float d = abs(dot(n,l)); float w = pow(d,falloff); C += Cl * lerp(col1,col2,w); } Cf = C; } d (for "distance") is the cosine of the angle between the two vectors you're comparing (in this case, the direction of the light land the surface normal n). w (for "weight"), is the falloff calculation, which in this case, is just that same cosine-angle raised to some power. As an aside, the EdgeFalloff VOP uses the same calculation but does the lerping for you. However, you can look inside it so see how the expressions for d and w that I wrote above translate into VOPs. One possible drawback with the above approach is that, as you can see, the thing you're raising to some power is not a straight-lined decay, but a cosine curve. If you wanted to start with a straight line, you'd change d to: d = 2*asin(abs(dot(n,l)))/M_PI; ... and once you have a linear distance in [0,1] you can do whatever you want. Sorry I didn't give you a VOP-based answer, but hopefully you can do the translation. HTH 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.