OSL Diffuse Shader (closure)to RGB

Hello Everyone,

I’m using a link between the material and the light based on the light position to get an effect similar to the diffuse shader that interacts with the light. It’s working good but I can’t receive any shadows with this setup because it’s directly connected to the light. (I’m using this setup because in cycles we can’t convert shader to RGB like Evee). This is a test to get what I mean

so I searched and found that OSL might help in this situation either by

  1. converting the shader data (closure) to RGB or
  2. obtaining in the received shadows as RGB mask inside the shader itself.

I’ve got an OSL script that uses the diffuse toon shader inside the osl all I need to do is converting the output type from closure to RGB.

shader simple_material(

color Diffuse_Color = color(0.6, 0.8, 0.6),

normal Normal = N,

output closure color BSDF = 0



BSDF = Diffuse_Color * diffuse_toon(normalize(Normal),1.1,0.0);


Thanks in advance!

OSL does not support such a conversion, and Cycles doesn’t either. It’s not an arbitrary limitation in the shader nodes, but relates to fundamental design decisions in the renderer that are not easy to work around.

1 Like

Thanks, Brecht for the fast reply :slight_smile:!
So How about the second method about using OSL to get the received shadows as mask inside the material? Is it possible?

Shadows can’t be computed as RGB either for the same reason.

1 Like

Thanks, Brecht. I will try to find a workaround in compositing.

Hello Timberman,

Sorry but I didn’t get what you mean by you reply. Is it a hint for something related to my question?


@Timberman @Crutchman Both your posts seem a little out of place. Please edit them to make them relevant to the topic at hand or they might get removed as they are currently off-topic.

Similar images were posted on a different topic I was following (about caustics)

before it ended up closed, it looked weird that they popped up again here, I think it is some kind of troll, the profile of the user on the caustics thread was created on January 19 (just a few days ago)

and the profile of the two users posting the images here are probably from the same person (who can’t wait for the ban on his 1st profile to be lifted) created one after another 5 hours ago…