Using osl phong_ramp as a factor?

i found that in OSL there is a shader called phong_ramp that creates a color a ramp depending on the amount of light that a surface gets.

is there a way to use that phong_ramp as a factor output? or as any other thing, because working it as a shader is very clumsy, i would love to do a lot of things with it.

thanks!

Unfortunately, no.
The phong_ramp (and the diffuse_ramp) use a fixed array of 8 colors and those cannot change.
There are some ways to make the process of editing the colors a bit easier, like messaging between the nodes, or by using python… but it isn’t simple to do in just a few clicks.
If it’s just a gradient between two or three colors, you can interpolate them inside the OSL script to fill the 8 color array.

hey thanks for the answer!

i’m thinking more about the output. the 8 colors are ok for me but i would like to output the ramp as a factor, like as a layer weight, to use it in another shader. do you know is there a way to do that? i know some other osl shaders can output as different things but i’ve had no luck with this one.

thanks

Baking/Render and Composite.

True… But some outputs don’t allow certain transformations…
For example, you can output ‘Strings’… but it makes no sense to plug a string into a MixRGB. The same goes with Closures (like the ‘Phong_Ramp’).