Hi, there!
If P being shaded belongs to a hair strand,
then we have a node in Cycles that gives us the intercept of said P.
But if P belongs to a curve, then it belongs to a spline,
and there is a u coordinate associated with it.
How do I symbolically refer to the value of u? :eek:
I’ll have to check the OSL guide…
But anyway, P is global, so it will be the same in OSL as in the Geometry>Position output. (I remember to read that P is readonly; the only way to alter the P value would be with the displacement shader, which is not yet fully implemented in cycles)
There is always u and v as global variables, but they don’t give you want you want in the hair case.
You have you use the getattribute function for that.
shader test(
output color Color = color(0.8, 0.8, 0.8))
{
float curve_u;
if (getattribute("geom:curve_intercept",curve_u)){
// for hair curves
Color = color(curve_u);
}
else {
// for non hair curves do something clever
Color = color(.9,.1,0);
}
}
Ah, yes --thank you-- I tried that, a couple of years ago,
and it didn´t work, but after two years of improvements,
I should definitely revisit that.
Thanks for the code!
:eek: Pop? You mean, the cleverness has not yet been found??
:ba: Urgh! All I really want is a color ramp, from root to tip,
that maps along the length of the/each spline,
independent of orientation and shape keys.
(Otherwise, the Y component of generated coordinates, will do.)
P.S. Brute force: convert the beveled curves (representing wool strands)
to mesh, and UV ! Poor computer. :no:
shader test(
output color Color = color(0.8, 0.8, 0.8))
{
float curve_u;
if (getattribute("geom:curve_intercept",curve_u)){
// for hair curves
Color = color(curve_u,0,0);
}
else {
// P[0] , or x gives you what you want.
Color = color(P[0],0,0);
}
}
Equivalent node setup is just take the position from geometry node, separate XYZ, take X and plug into a color ramp.
At least as far back as Blender 2.61 (before Bmesh),
there has been, for curves, under the curve tab,
a panel called Texture Space, with a button
–I just noticed it-- called